From 7df176b4c5117257f93a7e5a8a0b0871b6bdd132 Mon Sep 17 00:00:00 2001 From: "1152958806@qq.com" <1152958806@qq.com> Date: Sun, 8 Oct 2023 23:53:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=88=B1=E5=8F=91=E7=94=B5?= =?UTF-8?q?=E8=B5=9E=E5=8A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.yaml | 29 ++++- templates/assets/js/heo.js | 21 ++++ templates/assets/zhheo/blogex.js | 1 + templates/assets/zhheo/zhheoblog.css | 115 ++++++++++++++++-- templates/modules/variables/site-config.html | 3 + .../widgets/aside/contain/stat-contain.html | 2 +- templates/modules/widgets/aside/power.html | 37 ++++++ 7 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 templates/modules/widgets/aside/power.html diff --git a/settings.yaml b/settings.yaml index bee75320..1a83de6f 100644 --- a/settings.yaml +++ b/settings.yaml @@ -556,7 +556,7 @@ spec: - $formkit: group name: widgetss label: 侧边栏内容 - help: 目前提供的小部件有:profile(站点资料), wechat(微信), welcome(小板报), steam(Steam卡片), music(音乐卡片), friend-link(通讯录), recent-posts(近期文章), comments(最新评论), categories(文章分类), tags(文章标签), stat(统计), tags-stat(标签&归档&统计), adbox(广告区域)。你可以随意组合或排序,以逗号隔开。 + help: 目前提供的小部件有:profile(站点资料), wechat(微信), power(爱发电赞助), welcome(小板报), steam(Steam卡片), music(音乐卡片), friend-link(通讯录), recent-posts(近期文章), comments(最新评论), categories(文章分类), tags(文章标签), stat(统计), tags-stat(标签&归档&统计), adbox(广告区域)。你可以随意组合或排序,以逗号隔开。 value: indexWidgets: profile,wechat,comments,recent-posts,categories,tags-stat postWidgets: profile,wechat,toc,comments,recent-posts,categories,tags-stat @@ -654,6 +654,33 @@ spec: name: wechatImgBack placeholder: 公众号背面图 help: 图片可以从公众号后台下载物料或者自制 + - $formkit: group + name: power + label: 爱发电赞助 + value: + powerLink: / + list: + children: + - $formkit: url + name: powerLink + label: 赞助地址 + - $formkit: repeater + name: list + label: 爱发电赞助列表 + value: [ ] + children: + - $formkit: attachment + name: avatar + label: 头像 + - $formkit: text + name: name + label: 名称 + - $formkit: url + name: link + label: 链接 + - $formkit: text + name: descr + label: 描述 - $formkit: group name: welcome label: 小板报 diff --git a/templates/assets/js/heo.js b/templates/assets/js/heo.js index 7652e94c..887b8fdd 100644 --- a/templates/assets/js/heo.js +++ b/templates/assets/js/heo.js @@ -531,6 +531,27 @@ var heo = { input.setSelectionRange(-1, -1); }, + //爱发电赞助 + addPowerLinksInPostRightSide: async function() { + const image = document.getElementById("power-star-image") + , star = document.getElementById("power-star") + , title = document.getElementById("power-star-title") + , desc = document.getElementById("power-star-desc"); + if (image && star && title && desc) + try { + const list = GLOBAL_CONFIG.source.power.list + , i = heo.getRandomInt(0, list.length) + , power = list[i].realNode; + image.style.backgroundImage = `url(${power.avatar})`, + star.href = power.link, + title.innerText = power.name, + desc.innerText = power.descr + } catch (e) {} + }, + getRandomInt: function(e, t) { + return Math.floor(Math.random() * (t - e)) + e + }, + //初始化console图标 initConsoleState: function() { document.documentElement.classList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on") diff --git a/templates/assets/zhheo/blogex.js b/templates/assets/zhheo/blogex.js index 7ca7790d..19feb860 100644 --- a/templates/assets/zhheo/blogex.js +++ b/templates/assets/zhheo/blogex.js @@ -645,6 +645,7 @@ function initBlog() { //右下角 snackbar 弹窗 GLOBAL_CONFIG.source.tool.switch && heo.hidecookie(), heo.stopImgRightDrag(), + heo.addPowerLinksInPostRightSide(), heo.onlyHome(), heo.addNavBackgroundInit(), heo.darkModeStatus(), diff --git a/templates/assets/zhheo/zhheoblog.css b/templates/assets/zhheo/zhheoblog.css index 7727020b..7a6c0472 100644 --- a/templates/assets/zhheo/zhheoblog.css +++ b/templates/assets/zhheo/zhheoblog.css @@ -2021,15 +2021,6 @@ blockquote footer cite::before { padding-left: 0.5rem; } -#aside-content .item-headline { - padding-bottom: 0.3rem; - font-size: 1.2em; -} - -#aside-content .item-headline span { - margin-left: 0.5rem; -} - @media screen and (min-width: 900px) { #aside-content .sticky_layout { position: sticky; @@ -7388,7 +7379,6 @@ span.fund_name { } /* 微信公众号翻转 */ - #flip-wrapper { position: relative; width: 235px; @@ -7436,6 +7426,103 @@ span.fund_name { background-size: 100%; } +/* 爱发电赞助 */ +#aside-content .card-widget.card-power { + padding: .4rem .6rem!important +} + +#aside-content .card-widget.card-power .power-charge { + margin-left: auto; + color: var(--heo-secondtext); + font-size: 14px; + line-height: 1 +} + +#aside-content .card-widget.card-power .power-charge:hover { + color: var(--heo-lighttext) +} + +.power-list { + display: flex; + flex-direction: row; + flex-wrap: wrap; + margin: 0 -4px +} + +.power-list .power-item .power-item-link a { + padding: 2px 4px; + border-radius: 4px; + margin-left: 8px +} + +.power-list .power-item .power-item-link a:hover { + background: var(--heo-lighttext); + color: var(--heo-card-bg) +} + +#aside-content .power-item-body { + display: flex; + flex-direction: row; + flex-wrap: wrap +} + +#power-star-image { + width: 60px; + height: 60px; + border-radius: 8px; + background-size: cover; + margin-right: 12px; + border: var(--style-border-always) +} + +a#power-star { + display: flex; + padding: 8px; + border: var(--style-border-always); + border-radius: 8px; + flex-direction: row; + flex-wrap: nowrap; + justify-content: flex-start; + position: relative; + margin: 12px 0; + background: var(--heo-secondbg) +} + +a#power-star:hover { + background: var(--heo-lighttext); + color: var(--heo-card-bg) +} + +div#power-star-title { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-size: 16px; + font-weight: 700; + line-height: 1; + margin-bottom: 8px +} + +#power-star-desc { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; + font-size: 12px; + max-width: 100%; + line-height: 1.2 +} + +.power-star-body { + display: flex; + flex-direction: column; + align-items: flex-start; + flex-wrap: wrap; + position: relative; + width: calc(100% - 68px); + justify-content: center +} + /* 商务广告-设计周刊 */ #card-vip-designweekly.card-widget { display: flex !important; @@ -10023,7 +10110,13 @@ div#author-info__sayhi:hover { padding-bottom: 0; margin-left: 8px; font-size: 1em; - font-weight: bold; + font-weight: 700; + display: flex; + align-items: center +} + +#aside-content .item-headline span { + margin-left: 4px; } #aside-content .item-headline i { diff --git a/templates/modules/variables/site-config.html b/templates/modules/variables/site-config.html index 2a6d3955..fc55a220 100644 --- a/templates/modules/variables/site-config.html +++ b/templates/modules/variables/site-config.html @@ -55,6 +55,9 @@ enable_height_limit: [[${theme.config.code.enable_height_limit}]] }, source: { + power:{ + list:[[${theme.config.sidebar.power.list}]] + }, links: { linksUrl: [[${ theme.config.link.linksUrl }]], linksNum: [[${theme.config.footer.footer_group.num}]], diff --git a/templates/modules/widgets/aside/contain/stat-contain.html b/templates/modules/widgets/aside/contain/stat-contain.html index f10e3149..6c6e532c 100644 --- a/templates/modules/widgets/aside/contain/stat-contain.html +++ b/templates/modules/widgets/aside/contain/stat-contain.html @@ -4,7 +4,7 @@ -
统计
+
diff --git a/templates/modules/widgets/aside/power.html b/templates/modules/widgets/aside/power.html new file mode 100644 index 00000000..c4554e87 --- /dev/null +++ b/templates/modules/widgets/aside/power.html @@ -0,0 +1,37 @@ + + + +
+ + +
+ + + \ No newline at end of file