Skip to content

Commit 7daa68d

Browse files
committed
feat: 添加主题切换功能
- 在设置中添加主题切换按钮的显示控制 - 在页脚添加主题切换按钮和图标 - 优化主题切换消息的显示格式 close chengzhongxue#9
1 parent b166dce commit 7daa68d

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,10 @@ spec:
15721572
- group: footer
15731573
label: 页脚
15741574
formSchema:
1575+
- $formkit: checkbox
1576+
name: allow_switch_theme
1577+
label: 是否显示切换主题的按钮
1578+
value: false
15751579
- $formkit: repeater
15761580
name: social
15771581
label: 社交媒体

templates/modules/partial/scripts/theme.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
window.localStorage.setItem('Stellar.theme', newTheme)
4646

4747
const messages = {
48-
light: [[#{message.theme_switched.light}]],
49-
dark: [[#{message.theme_switched.dark}]],
50-
auto: [[#{message.theme_switched.auto}]],
48+
light: "#{message.theme_switched.light}",
49+
dark: "#{message.theme_switched.dark}",
50+
auto: "#{message.theme_switched.auto}",
5151
}
5252
hud?.toast?.(messages[newTheme])
5353
}
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<footer class="footer dis-select">
22
<div class="social-wrap">
3-
<a th:each="social : ${theme.config.footer.social}"
4-
th:with="is_contain = ${#strings.contains(social.url,'://')}"
5-
class="social"
6-
th:title="${social.title}"
7-
th:href="${social.url}"
8-
th:target="${is_contain ? '_blank' : '_self'}"
9-
th::rel="${ is_contain ? 'external nofollow noopener noreferrer' : 'noopener noreferrer'}">
10-
<th:block th:if="${not #strings.isEmpty(social.icon)}" th:utext="${social.icon}"></th:block>
3+
<a th:each="social : ${theme.config.footer.social}"
4+
th:with="is_contain = ${#strings.contains(social.url,'://')}" class="social" th:title="${social.title}"
5+
th:href="${social.url}" th:target="${is_contain ? '_blank' : '_self'}"
6+
th::rel="${ is_contain ? 'external nofollow noopener noreferrer' : 'noopener noreferrer'}">
7+
<th:block th:if="${not #strings.isEmpty(social.icon)}" th:utext="${social.icon}"></th:block>
8+
</a>
9+
<a class="social" onclick="switchTheme()" th:if="${theme.config.footer.allow_switch_theme}">
10+
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
11+
<path
12+
d="M582.4 326.4c-140.8 0-256 115.2-256 256s115.2 256 256 256 256-115.2 256-256-115.2-256-256-256z m0 448c-70.4 0-131.2-36.8-164.8-92.8 12.8 3.2 27.2 4.8 40 4.8 121.6 0 219.2-99.2 219.2-219.2 0-17.6-1.6-35.2-6.4-52.8 60.8 32 102.4 96 102.4 169.6 1.6 104-84.8 190.4-190.4 190.4zM582.4 262.4c17.6 0 32-14.4 32-32v-128c0-17.6-14.4-32-32-32s-32 14.4-32 32v128c0 17.6 14.4 32 32 32zM262.4 582.4c0-17.6-14.4-32-32-32h-128c-17.6 0-32 14.4-32 32s14.4 32 32 32h128c17.6 0 32-14.4 32-32zM310.4 356.8c6.4 6.4 14.4 9.6 22.4 9.6 8 0 16-3.2 22.4-9.6 12.8-12.8 12.8-32 0-44.8l-91.2-91.2c-12.8-12.8-32-12.8-44.8 0-12.8 12.8-12.8 32 0 44.8l91.2 91.2zM944 220.8c-12.8-12.8-32-12.8-44.8 0l-91.2 91.2c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 14.4 9.6 22.4 9.6 8 0 16-3.2 22.4-9.6l91.2-91.2c12.8-12.8 12.8-33.6 0-44.8zM310.4 808l-91.2 91.2c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 14.4 9.6 22.4 9.6 8 0 16-3.2 22.4-9.6l91.2-91.2c12.8-12.8 12.8-32 0-44.8-11.2-11.2-32-11.2-44.8 0z"
13+
fill="currentColor" fill-rule="evenodd">
14+
</path>
15+
</svg>
1116
</a>
1217
</div>
1318
</footer>

theme.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ apiVersion: theme.halo.run/v1alpha1
22
kind: Theme
33
metadata:
44
name: theme-stellar
5-
annotations:
6-
# Add supports for Halo App Store
7-
# https://www.halo.run/store/apps/app-KxJeQ
8-
"store.halo.run/app-id": "app-KxJeQ"
95
spec:
106
customTemplates:
117
page:
@@ -34,4 +30,3 @@ spec:
3430
license:
3531
- name: "MIT license"
3632
url: "https://github.com/chengzhongxue/halo-theme-stellar/blob/main/LICENSE"
37-

0 commit comments

Comments
 (0)