This commit is contained in:
2024-10-31 18:23:39 +08:00
parent 4b04c1863b
commit 34a41f50ac
31 changed files with 561 additions and 223 deletions

View File

@@ -6,4 +6,23 @@ function createUi(html){
.then(htmlText=>{
return htmlText;
})
}
function getParam(name){
console.log(window.location.href)
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null) {
return null;
} else {
return decodeURI(results[1]) || 0;
}
}
function showImage(url, imgElement) {
getHttpImage(url)
.then(imageUrl => {
imgElement.src = imageUrl;
})
.catch(error => {
console.log("Error loading image:", error);
// 可以在这里设置一个默认图片或者显示错误信息
});
}

View File

@@ -40,24 +40,7 @@ function post(url,formData,isJSON) {
throw error; // 重新抛出错误以便外部捕获
});
}
function getLiveVideoList() {
return get("/live/video/list");
}
function getHttpImage(url) {
const encode = encodeURI(url);
const formData = new FormData();
formData.append("url", encode);
return post("/file/img",formData,false)
.then(blob=>{
return blob;
})
}
function getBiliAllUser(){
return get("/user/list")
}
function addRoomConfig(json){
function buildFormData(json){
const formData = new FormData();
Object.keys(json).forEach(key => {
@@ -73,5 +56,56 @@ function addRoomConfig(json){
formData.append(key, value);
}
});
return post("/live/config/set",formData)
}
return formData;
}
//----------------直播配置相关接口
function getLiveVideoList() {
return get("/live/video/list");
}
function getHttpImage(url) {
const encode = encodeURI(url);
const formData = new FormData();
formData.append("url", encode);
return post("/file/img",formData,false)
.then(blob=>{
return blob;
})
}
function getBiliAllUser(){
return get("/user/list")
}
function addRoomConfig(json){
const formData=buildFormData(json)
return post("/live/config/set",formData,true)
}
function getRoomConfig(roomId){
return get("/live/config/get?roomId="+roomId)
}
function deleteRoomConfig(roomId){
return get("/live/config/delete?roomId="+roomId)
}
//----------------直播配置相关接口end
//----------------首页相关接口
function getAllLive(){
return get("/live/list")
}
//----------------首页相关接口end
//----------------视频相关接口
function startLiveVideo(roomId){
return get("/live/video/start?roomId="+roomId)
}
function stopLiveVideo(roomId){
return get("/live/video/stop?roomId="+roomId)
}
//----------------视频相关接口end
//----------------弹幕相关接口
function startLiveDanmu(roomId){
return get("/live/danmu/start?roomId="+roomId)
}
function stopLiveDanmu(roomId){
return get("/live/danmu/stop?roomId="+roomId)
}
//----------------弹幕相关接口end

View File

@@ -101,12 +101,3 @@ function Base64() {
return string;
}
}
function getParam(name){
console.log(window.location.href)
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null) {
return null;
} else {
return decodeURI(results[1]) || 0;
}
}