From 66417cb5118bd78e3c8435bc60252c4204945678 Mon Sep 17 00:00:00 2001 From: UPToZ Date: Mon, 17 Jun 2024 09:38:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E9=93=BE=E6=8E=A5=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8F=92=E4=BB=B61.4.0=E7=89=88=E6=9C=AC=20detailed?= =?UTF-8?q?=EF=BC=9A=201.=E9=80=82=E9=85=8D=E9=93=BE=E6=8E=A5=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8F=92=E4=BB=B61.4.0=E7=89=88=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=89=8D=E5=8F=B0=E7=B4=A2=E5=BC=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=93=BE=E6=8E=A5=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82=202.=E5=BD=93=E7=88=B1=E5=8F=91=E7=94=B5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B6=85=E6=97=B6=E6=9C=AA=E8=BF=94=E5=9B=9E=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=97=B6=EF=BC=8C=E6=98=BE=E7=A4=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/assets/js/halo.js | 20 ++++++++++++++++---- templates/assets/js/heo.js | 2 +- theme.yaml | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/templates/assets/js/halo.js b/templates/assets/js/halo.js index 3fcb56f..b0cecbf 100644 --- a/templates/assets/js/halo.js +++ b/templates/assets/js/halo.js @@ -379,10 +379,24 @@ let halo = { function getPower() { const url = GLOBAL_CONFIG.source.power.url; + let powerStar = document.getElementById("power-star") + powerStar.href = GLOBAL_CONFIG.source.power.powerLink fetch(url) - .then(res => res.json()) + .then(response => { + // 检查响应状态码 + if (!response.ok) { + // 如果响应状态码不是 200,抛出一个错误 + powerStar.innerHTML = ` +
+
+
+
还没有人赞助~
+
为爱发电,点击赞助
+
`; + } + return response.json(); // 只有在状态码为 200 时才解析 JSON + }) .then(data => { - console.log(data) if (200 === data["ec"]) { const values = data["data"]["list"]; saveToLocal.set('power-data', JSON.stringify(values), 10 / (60 * 24)) @@ -390,8 +404,6 @@ let halo = { } }) .catch(error => { - let powerStar = document.getElementById("power-star") - powerStar.href = GLOBAL_CONFIG.source.power.powerLink powerStar.innerHTML = `
diff --git a/templates/assets/js/heo.js b/templates/assets/js/heo.js index 2af937f..fa25384 100644 --- a/templates/assets/js/heo.js +++ b/templates/assets/js/heo.js @@ -115,7 +115,7 @@ var heo = { function getLinks() { 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) .then(res => res.json()) .then(json => { diff --git a/theme.yaml b/theme.yaml index 0fb942b..b34b1aa 100644 --- a/theme.yaml +++ b/theme.yaml @@ -51,5 +51,5 @@ spec: repo: https://gitea.uptoz.cn/UPToZ/halo-theme-hao settingName: "theme-hao-setting" configMapName: "theme-hao-configMap" - version: "1.0.1-ce" + version: "1.0.2-ce" require: ">=2.10.0"