From 15f3614aacabd1f8c38486362d7d9f02383b8ed7 Mon Sep 17 00:00:00 2001 From: UPToZ Date: Tue, 21 May 2024 11:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E7=88=B1=E5=8F=91?= =?UTF-8?q?=E7=94=B5=E6=8F=92=E4=BB=B6=E7=9A=84=E6=94=AF=E6=8C=81=20detail?= =?UTF-8?q?ed=EF=BC=9A=201.=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=AF=B9=E7=88=B1?= =?UTF-8?q?=E5=8F=91=E7=94=B5=E6=8F=92=E4=BB=B6=E7=9A=84=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E3=80=82=202.=E7=A7=BB=E9=99=A4=E4=BA=86=E7=88=B1=E5=8F=91?= =?UTF-8?q?=E7=94=B5apiToekn=E5=92=8CuserID=E7=9A=84=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9=E3=80=82=203.=E4=BF=AE=E6=94=B9=E4=BA=86=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E9=A1=B5=E9=9D=A2=E4=B8=AD=E8=AE=BF=E9=97=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=86=85=E7=9A=84=E2=80=9C=E6=96=87=E7=AB=A0=E9=9A=A7?= =?UTF-8?q?=E9=81=93=E2=80=9D=E6=8C=89=E9=92=AE=E5=9C=A8=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E4=B8=8B=E7=9A=84=E6=A0=B7=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.yaml | 11 +- templates/assets/js/halo.js | 110 +++++-------------- templates/assets/zhheo/zhheoblog.css | 11 +- templates/modules/variables/site-config.html | 4 +- templates/modules/widgets/aside/power.html | 2 +- 5 files changed, 37 insertions(+), 101 deletions(-) diff --git a/settings.yaml b/settings.yaml index 73c8652..5b951ad 100644 --- a/settings.yaml +++ b/settings.yaml @@ -750,9 +750,7 @@ spec: label: 爱发电赞助 value: powerLink: / - url: https://afdian.net/api/open/query-sponsor - userId: - apiToken: + url: /apis/api.plugin.halo.run/v1alpha1/plugins/plugin-afdian/afdian/getSponsorList showNum: 3 children: - $formkit: url @@ -761,12 +759,7 @@ spec: - $formkit: text name: url label: 接口地址 - - $formkit: text - name: userId - label: 用户ID - - $formkit: text - name: apiToken - label: API-Token + help: 需要安装爱发电插件 - $formkit: number name: showNum label: 最大展示条数 diff --git a/templates/assets/js/halo.js b/templates/assets/js/halo.js index 71ad2ed..3fcb56f 100644 --- a/templates/assets/js/halo.js +++ b/templates/assets/js/halo.js @@ -374,81 +374,32 @@ let halo = { }, getTopSponsors() { - var user_id = GLOBAL_CONFIG.source.power.userId; var show_num = GLOBAL_CONFIG.source.power.showNum; - var api_token = GLOBAL_CONFIG.source.power.apiToken; var url = GLOBAL_CONFIG.source.power.url; - //计算sign - function calculateSign(token, params, ts, userId) { - // 按照签名规则拼接字符串 - const signString = `${token}params${params}ts${ts}user_id${userId}`; - // 使用MD5库计算签名 - const sign = CryptoJS.MD5(signString).toString(); - return sign; - } - - //查询赞助者 - async function callQuerySponsorApi() { - //查询参数 - const params = { - page: 1, - per_page: 10 - } - // 获取秒级时间戳 - const ts = Math.floor(Date.now() / 1000); - // 计算签名 - const sign = calculateSign(api_token, JSON.stringify(params), ts, user_id); - // 构建请求体 - const request = { - user_id: user_id, - params: JSON.stringify(params), - ts: ts, - sign: sign - }; - - // 发送请求 - const response = await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(request) - }); - - // 处理响应 - if (response.ok) { - const data = await response.json(); - console.log('API Response:', data); - } else { - let powerStar = document.getElementById("power-star"); - powerStar.href = GLOBAL_CONFIG.source.power.powerLink - powerStar.innerHTML = ` -
-
-
-
还没有人赞助~
-
为爱发电,点击赞助
-
`; - console.error('API Error:', response.status, response.statusText); - } - } - - function getPower() { const url = GLOBAL_CONFIG.source.power.url; - const ts = Math.floor(Date.now() / 1000); - const sign = - // + user_id - fetch(url) + fetch(url) .then(res => res.json()) .then(data => { + console.log(data) if (200 === data["ec"]) { - var values = data["data"]["list"] + const values = data["data"]["list"]; saveToLocal.set('power-data', JSON.stringify(values), 10 / (60 * 24)) renderer(values); } - + }) + .catch(error => { + let powerStar = document.getElementById("power-star") + powerStar.href = GLOBAL_CONFIG.source.power.powerLink + powerStar.innerHTML = ` +
+
+
+
还没有人赞助~
+
为爱发电,点击赞助
+
`; + console.error(error); }) } @@ -458,22 +409,22 @@ let halo = { if (values.length === 0) { powerStar.href = GLOBAL_CONFIG.source.power.powerLink powerStar.innerHTML = ` -
-
-
-
还没有人赞助~
-
为爱发电,点击赞助
-
`; +
+
+
+
还没有人赞助~
+
为爱发电,点击赞助
+
`; } else { if (powerStar) { - powerStar.href = "https://afdian.net/u/" + data[0].user_id + powerStar.href = "https://afdian.net/u/" + data[0]["user"].user_id powerStar.innerHTML = ` -
-
-
-
${data[0].name}
-
更多支持,为爱发电
-
`; +
+
+
+
${data[0]["user"].name}
+
更多支持,为爱发电
+
`; } if (values.length > 1) { @@ -484,7 +435,7 @@ let halo = { break; } htmlText += - ` ${value["name"]}`; + ` ${value["user"]["name"]}`; i = i + 1; } if (document.getElementById("power-item-link")) { @@ -499,8 +450,7 @@ let halo = { if (data) { renderer(JSON.parse(data)) } else { - callQuerySponsorApi(); - // getPower(); + getPower(); } } diff --git a/templates/assets/zhheo/zhheoblog.css b/templates/assets/zhheo/zhheoblog.css index 6151cbf..d3778ee 100644 --- a/templates/assets/zhheo/zhheoblog.css +++ b/templates/assets/zhheo/zhheoblog.css @@ -2860,11 +2860,11 @@ blockquote footer cite::before { display: inline; } -#nav .menus_items .menus_item { +/* #nav .menus_items .menus_item { position: relative; display: inline-block; padding: 0px 0.4rem 0px 0px; -} +} */ #nav .menus_items .recursion_menus_item:hover>.menus_item_child, #nav .menus_items .menus_item:hover>.menus_item_child { @@ -12432,11 +12432,6 @@ a.reward-main-btn:hover { } /* 评论 */ -/* ---------------------------------------------------------------- */ -/* ---------------------------------------------------------------- */ -/* ---------------------------------------------------------------- */ -/* ---------------------------------------------------------------- */ -/* ---------------------------------------------------------------- */ div#post-comment { margin-top: 2rem; } @@ -16867,7 +16862,7 @@ span.hexo-douban-pagenum { } .author-content-item .card-content .banner-button-group .banner-button { - background: none; + background: none !important; color: var(--heo-white); padding: 0; width: fit-content; diff --git a/templates/modules/variables/site-config.html b/templates/modules/variables/site-config.html index b571911..b61ca98 100644 --- a/templates/modules/variables/site-config.html +++ b/templates/modules/variables/site-config.html @@ -58,9 +58,7 @@ power: { powerLink: [[${theme.config.sidebar.power.powerLink}]], url: [[${theme.config.sidebar.power.url}]], - userId: [[${theme.config.sidebar.power.userId}]], - showNum: [[${theme.config.sidebar.power.showNum}]], - apiToken:[[${theme.config.sidebar.power.apiToken}]] + showNum: [[${theme.config.sidebar.power.showNum}]] }, links: { linksUrl: [[${ theme.config.link.linksUrl }]], diff --git a/templates/modules/widgets/aside/power.html b/templates/modules/widgets/aside/power.html index 71bec58..e84758a 100644 --- a/templates/modules/widgets/aside/power.html +++ b/templates/modules/widgets/aside/power.html @@ -5,7 +5,7 @@ 赞助 - +