update
This commit is contained in:
@@ -25,4 +25,14 @@ function showImage(url, imgElement) {
|
||||
console.log("Error loading image:", error);
|
||||
// 可以在这里设置一个默认图片或者显示错误信息
|
||||
});
|
||||
}
|
||||
function showTmpImage(url, imgElement) {
|
||||
getHttpTmpImage(url)
|
||||
.then(blob => {
|
||||
imgElement.src ="data:image/jpeg;base64,"+blob;
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("Error loading image:", error);
|
||||
// 可以在这里设置一个默认图片或者显示错误信息
|
||||
});
|
||||
}
|
||||
@@ -32,7 +32,6 @@ function post(url,formData,isJSON) {
|
||||
return blob;
|
||||
}
|
||||
const imageUrl = URL.createObjectURL(blob);
|
||||
console.log("Image URL:", imageUrl);
|
||||
return imageUrl;
|
||||
})
|
||||
.catch(error => {
|
||||
@@ -40,6 +39,27 @@ function post(url,formData,isJSON) {
|
||||
throw error; // 重新抛出错误以便外部捕获
|
||||
});
|
||||
}
|
||||
|
||||
function post2blob(url,formData) {
|
||||
return fetch(url, {
|
||||
method: "POST",
|
||||
body: formData
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(blob => {
|
||||
return blob;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("There was a problem with the fetch operation:", error);
|
||||
throw error; // 重新抛出错误以便外部捕获
|
||||
});
|
||||
}
|
||||
|
||||
function buildFormData(json){
|
||||
const formData = new FormData();
|
||||
|
||||
@@ -73,6 +93,15 @@ function getHttpImage(url) {
|
||||
return blob;
|
||||
})
|
||||
}
|
||||
function getHttpTmpImage(url) {
|
||||
const encode = encodeURI(url);
|
||||
const formData = new FormData();
|
||||
formData.append("url", encode);
|
||||
return post2blob("/file/imgTmp",formData)
|
||||
.then(blob=>{
|
||||
return blob;
|
||||
})
|
||||
}
|
||||
function getBiliAllUser(){
|
||||
return get("/user/list")
|
||||
}
|
||||
@@ -89,8 +118,8 @@ function deleteRoomConfig(roomId){
|
||||
|
||||
//----------------直播配置相关接口end
|
||||
//----------------首页相关接口
|
||||
function getAllLive(){
|
||||
return get("/live/list")
|
||||
function getAllLive(page,limit){
|
||||
return get("/live/list?page="+page+"&limit="+limit)
|
||||
}
|
||||
//----------------首页相关接口end
|
||||
//----------------视频相关接口
|
||||
|
||||
Reference in New Issue
Block a user