适配链接管理插件1.4.0版本

detailed:
1.适配链接管理插件1.4.0版本,解决前台索引查询链接报错问题。
2.当爱发电接口超时未返回内容时,显示默认数据。
This commit is contained in:
UPToZ 2024-06-17 09:38:08 +08:00
parent 236e0d6547
commit 66417cb511
3 changed files with 18 additions and 6 deletions

View File

@ -379,10 +379,24 @@ let halo = {
function getPower() { function getPower() {
const url = GLOBAL_CONFIG.source.power.url; const url = GLOBAL_CONFIG.source.power.url;
let powerStar = document.getElementById("power-star")
powerStar.href = GLOBAL_CONFIG.source.power.powerLink
fetch(url) fetch(url)
.then(res => res.json()) .then(response => {
// 检查响应状态码
if (!response.ok) {
// 如果响应状态码不是 200抛出一个错误
powerStar.innerHTML = `
<div id="power-star-image" style="background-image: url('/themes/theme-hao/assets/images/afadian/afadian.webp')">
</div>
<div class="power-star-body">
<div id="power-star-title">还没有人赞助</div>
<div id="power-star-desc">为爱发电点击赞助</div>
</div>`;
}
return response.json(); // 只有在状态码为 200 时才解析 JSON
})
.then(data => { .then(data => {
console.log(data)
if (200 === data["ec"]) { if (200 === data["ec"]) {
const values = data["data"]["list"]; const values = data["data"]["list"];
saveToLocal.set('power-data', JSON.stringify(values), 10 / (60 * 24)) saveToLocal.set('power-data', JSON.stringify(values), 10 / (60 * 24))
@ -390,8 +404,6 @@ let halo = {
} }
}) })
.catch(error => { .catch(error => {
let powerStar = document.getElementById("power-star")
powerStar.href = GLOBAL_CONFIG.source.power.powerLink
powerStar.innerHTML = ` powerStar.innerHTML = `
<div id="power-star-image" style="background-image: url('/themes/theme-hao/assets/images/afadian/afadian.webp')"> <div id="power-star-image" style="background-image: url('/themes/theme-hao/assets/images/afadian/afadian.webp')">
</div> </div>

View File

@ -115,7 +115,7 @@ var heo = {
function getLinks() { function getLinks() {
const fetchUrl = const fetchUrl =
"/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links?keyword=&sort=priority,asc" "/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links?keyword="
fetch(fetchUrl) fetch(fetchUrl)
.then(res => res.json()) .then(res => res.json())
.then(json => { .then(json => {

View File

@ -51,5 +51,5 @@ spec:
repo: https://gitea.uptoz.cn/UPToZ/halo-theme-hao repo: https://gitea.uptoz.cn/UPToZ/halo-theme-hao
settingName: "theme-hao-setting" settingName: "theme-hao-setting"
configMapName: "theme-hao-configMap" configMapName: "theme-hao-configMap"
version: "1.0.1-ce" version: "1.0.2-ce"
require: ">=2.10.0" require: ">=2.10.0"