hexo-theme-solitude 2.0.13 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/README_zh-Hans.md +2 -1
- package/README_zh-Hant.md +2 -1
- package/_config.yml +20 -5
- package/languages/default.yml +10 -0
- package/languages/en.yml +10 -0
- package/languages/zh-CN.yml +10 -0
- package/languages/zh-TW.yml +10 -0
- package/layout/includes/head/config.pug +3 -3
- package/layout/includes/inject/body.pug +1 -1
- package/layout/includes/layout.pug +4 -0
- package/layout/includes/rightmenu.pug +2 -2
- package/layout/includes/rightside.pug +3 -0
- package/layout/includes/widgets/aside/asideWebInfo.pug +4 -4
- package/layout/includes/widgets/post/postInfo.pug +10 -10
- package/layout/includes/widgets/rightside/hide.pug +6 -0
- package/layout/includes/widgets/rightside/show.pug +12 -0
- package/layout/includes/widgets/third-party/comments/comment.pug +3 -3
- package/layout/includes/widgets/third-party/pjax.pug +1 -1
- package/package.json +4 -4
- package/scripts/event/merge_config.js +14 -5
- package/source/css/_global/index.styl +2 -2
- package/source/css/_layout/aside.styl +20 -2
- package/source/css/_layout/capsule.styl +1 -1
- package/source/css/_layout/header.styl +1 -0
- package/source/css/_layout/rightside.styl +34 -0
- package/source/css/_page/_home/home-top.styl +5 -0
- package/source/js/main.js +36 -0
- package/source/js/tw_cn.js +18 -11
package/README.md
CHANGED
@@ -42,7 +42,8 @@ English丨[简体中文](README_zh-Hans.md)丨[繁体中文](README_zh-Hant.md)
|
|
42
42
|
|
43
43
|
## Todo
|
44
44
|
|
45
|
-
- [
|
45
|
+
- [X] Mobile directory support.
|
46
|
+
- [X] Add a bottom right sidebar.
|
46
47
|
|
47
48
|
> If you have any questions, please issue an [issue](https://github.com/everfu/hexo-theme-solitude/issues)
|
48
49
|
|
package/README_zh-Hans.md
CHANGED
package/README_zh-Hant.md
CHANGED
package/_config.yml
CHANGED
@@ -444,7 +444,7 @@ footer:
|
|
444
444
|
# 404 页面
|
445
445
|
errorpage:
|
446
446
|
img: /img/404.avif
|
447
|
-
text: =awa= Page
|
447
|
+
text: =awa= Page Not Found # Text
|
448
448
|
recommendList: true
|
449
449
|
# --------------------------- end ---------------------------
|
450
450
|
|
@@ -887,10 +887,7 @@ right_menu:
|
|
887
887
|
ctrlOriginalMenu: false
|
888
888
|
# Simplified and Traditional Chinese translation.
|
889
889
|
# 简繁体转换
|
890
|
-
translate:
|
891
|
-
enable: false
|
892
|
-
defaultEncoding: 2 # 1: 默认繁体 2: 默认简体
|
893
|
-
translateDelay: 0 # 首次加载翻译迟疑时间
|
890
|
+
translate: false
|
894
891
|
# Custom list
|
895
892
|
# 自定义列表
|
896
893
|
custom_list:
|
@@ -954,6 +951,24 @@ background:
|
|
954
951
|
light: https://i.pinimg.com/originals/93/57/38/935738ed9657b296c2ef0ebd2151eb66.jpg
|
955
952
|
# --------------------------- end ---------------------------
|
956
953
|
|
954
|
+
# --------------------------- start ---------------------------
|
955
|
+
translate:
|
956
|
+
enable: true
|
957
|
+
defaultEncoding: 2 # 1: 默认繁体 2: 默认简体
|
958
|
+
translateDelay: 0 # 首次加载翻译迟疑时间
|
959
|
+
# --------------------------- end ---------------------------
|
960
|
+
|
961
|
+
# --------------------------- start ---------------------------
|
962
|
+
# Right-Sidebar
|
963
|
+
# 右下角悬停导航栏
|
964
|
+
rightside:
|
965
|
+
enable: false
|
966
|
+
hide:
|
967
|
+
enable: false
|
968
|
+
translate: false
|
969
|
+
mode: false
|
970
|
+
# --------------------------- start ---------------------------
|
971
|
+
|
957
972
|
# --------------------------- start ---------------------------
|
958
973
|
# Do not modify unless necessary
|
959
974
|
# 非必要请勿修改
|
package/languages/default.yml
CHANGED
@@ -233,3 +233,13 @@ essay:
|
|
233
233
|
tip0: '- All expanded -'
|
234
234
|
tip1: '- Recent Exhibitions #{count} Short Articles -'
|
235
235
|
link: 'Link'
|
236
|
+
|
237
|
+
rightside:
|
238
|
+
show:
|
239
|
+
gear: Settings
|
240
|
+
toc: Toc
|
241
|
+
comment: Comment
|
242
|
+
top: Top
|
243
|
+
hide:
|
244
|
+
translate: 简繁转换
|
245
|
+
mode: Mode
|
package/languages/en.yml
CHANGED
@@ -234,3 +234,13 @@ essay:
|
|
234
234
|
tip0: '- All expanded -'
|
235
235
|
tip1: '- Recent Exhibitions #{count} Short Articles -'
|
236
236
|
link: 'Link'
|
237
|
+
|
238
|
+
rightside:
|
239
|
+
show:
|
240
|
+
gear: Settings
|
241
|
+
toc: Toc
|
242
|
+
comment: Comment
|
243
|
+
top: Top
|
244
|
+
hide:
|
245
|
+
translate: 简繁转换
|
246
|
+
mode: Mode
|
package/languages/zh-CN.yml
CHANGED
package/languages/zh-TW.yml
CHANGED
@@ -114,10 +114,10 @@
|
|
114
114
|
close: _p('right_menu.barrage.close')
|
115
115
|
}
|
116
116
|
}
|
117
|
-
if (theme.
|
117
|
+
if (theme.translate.enable) {
|
118
118
|
rightMenu.translate = {
|
119
|
-
translateDelay: theme.
|
120
|
-
defaultEncoding: theme.
|
119
|
+
translateDelay: theme.translate.translateDelay,
|
120
|
+
defaultEncoding: theme.translate.defaultEncoding
|
121
121
|
}
|
122
122
|
}
|
123
123
|
if (theme.right_menu.ctrlOriginalMenu)
|
@@ -26,6 +26,10 @@ html(lang=config.language, data-theme="light")
|
|
26
26
|
// keyboard
|
27
27
|
if theme.keyboard.enable
|
28
28
|
include ./keyboard.pug
|
29
|
+
|
30
|
+
// righhtside
|
31
|
+
if theme.rightside.enable
|
32
|
+
include rightside
|
29
33
|
|
30
34
|
#body-wrap(class = is_post() ? 'post' : 'page')
|
31
35
|
include ./header.pug
|
@@ -68,10 +68,10 @@ div#rightMenu
|
|
68
68
|
span.menu-darkmode-text= _p('right_menu.light')
|
69
69
|
when 'dark'
|
70
70
|
span.menu-darkmode-text= _p('right_menu.dark')
|
71
|
-
if theme.right_menu.translate
|
71
|
+
if theme.right_menu.translate
|
72
72
|
div.rightMenu-item#menu-translate
|
73
73
|
i.solitude.fa-solid.fa-language
|
74
|
-
case theme.
|
74
|
+
case theme.translate.defaultEncoding
|
75
75
|
when 2
|
76
76
|
span= _p('right_menu.chs_to_cht')
|
77
77
|
when 1
|
@@ -13,10 +13,10 @@
|
|
13
13
|
.item-name= __('aside.pv')
|
14
14
|
if theme.busuanzi_use === 0
|
15
15
|
span#busuanzi_value_site_pv
|
16
|
-
i.solitude.fa-solid.fa-spinner
|
16
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
17
17
|
else
|
18
18
|
span#busuanzi_site_pv
|
19
|
-
i.solitude.fa-solid.fa-spinner
|
19
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
20
20
|
if theme.aside.siteinfo.uv
|
21
21
|
.webinfo-item
|
22
22
|
.webinfo-item-title
|
@@ -24,10 +24,10 @@
|
|
24
24
|
.item-name= __('aside.uv')
|
25
25
|
if theme.busuanzi_use === 0
|
26
26
|
span#busuanzi_value_site_uv
|
27
|
-
i.solitude.fa-solid.fa-spinner
|
27
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
28
28
|
else
|
29
29
|
span#busuanzi_site_uv
|
30
|
-
i.solitude.fa-solid.fa-spinner
|
30
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
31
31
|
if theme.aside.siteinfo.runtimeenable
|
32
32
|
.webinfo-item
|
33
33
|
.webinfo-item-title
|
@@ -44,25 +44,25 @@
|
|
44
44
|
case theme.comment.use[0]
|
45
45
|
when "Twikoo"
|
46
46
|
span#twikoo_visitors
|
47
|
-
i.solitude.fa-solid.fa-spinner
|
47
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
48
48
|
when "Waline"
|
49
49
|
span.waline-pageview-count
|
50
|
-
i.solitude.fa-solid.fa-spinner
|
50
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
51
51
|
when "Valine"
|
52
52
|
span.leancloud_visitors(id=url_for(page.path))
|
53
53
|
span.leancloud-visitors-count
|
54
|
-
i.solitude.fa-solid.fa-spinner
|
54
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
55
55
|
when 'Artalk'
|
56
56
|
span#ArtalkPV
|
57
|
-
i.solitude.fa-solid.fa-spinner
|
57
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
58
58
|
else
|
59
59
|
if theme.busuanzi
|
60
60
|
if theme.busuanzi_use === 0
|
61
61
|
span#busuanzi_value_page_pv
|
62
|
-
i.solitude.fa-solid.fa-spinner
|
62
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
63
63
|
else
|
64
64
|
span#busuanzi_page_pv
|
65
|
-
i.solitude.fa-solid.fa-spinner
|
65
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
66
66
|
if theme.post.meta.comment && page.comment && theme.comment.count && theme.comment.use
|
67
67
|
span.post-meta-commentcount(title=_p('post.comment'), onclick="sco.scrollTo('post-comment')")
|
68
68
|
i.solitude.fa-solid.fa-comment
|
@@ -70,13 +70,13 @@
|
|
70
70
|
case theme.comment.use[0]
|
71
71
|
when "Twikoo"
|
72
72
|
span.twikoo-count
|
73
|
-
i.solitude.fa-solid.fa-spinner
|
73
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
74
74
|
when "Waline"
|
75
75
|
span.waline-comment-count
|
76
|
-
i.solitude.fa-solid.fa-spinner
|
76
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
77
77
|
when "Valine"
|
78
78
|
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
|
79
|
-
i.solitude.fa-solid.fa-spinner
|
79
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
80
80
|
when 'Artalk'
|
81
81
|
span.artalk-count
|
82
|
-
i.solitude.fa-solid.fa-spinner
|
82
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
@@ -0,0 +1,6 @@
|
|
1
|
+
.rs_hide
|
2
|
+
if theme.rightside.hide.translate
|
3
|
+
button.translate(type='button' title=_p('rightside.hide.translate'))= '简'
|
4
|
+
if theme.rightside.hide.mode
|
5
|
+
button.mode(type='button' title=_p('rightside.hide.mode') onclick='sco.switchDarkMode()')
|
6
|
+
i.fas.fa-circle-half-stroke
|
@@ -0,0 +1,12 @@
|
|
1
|
+
.rs_show
|
2
|
+
if theme.rightside.hide.enable
|
3
|
+
button.config(type='button' title=_p('rightside.show.gear') onclick='document.querySelector(".rs_hide").classList.toggle("show")')
|
4
|
+
i.fas.fa-gear.fa-spin
|
5
|
+
if page.toc
|
6
|
+
button.mobile.toc(type='button' title=_p('rightside.show.toc') onclick="document.querySelector('#card-toc').classList.toggle('open')")
|
7
|
+
i.fas.fa-list
|
8
|
+
if page.comment
|
9
|
+
button.comment(type='button' title=_p('rightside.show.comment') onclick="sco.scrollTo('post-comment')")
|
10
|
+
i.fas.fa-comment
|
11
|
+
button.top(type='button' title=_p('rightside.show.top') onclick='sco.toTop()')
|
12
|
+
i.fas.fa-arrow-up
|
@@ -12,13 +12,13 @@
|
|
12
12
|
case name
|
13
13
|
when "Twikoo"
|
14
14
|
span.twikoo-count
|
15
|
-
i.solitude.fa-solid.fa-spinner
|
15
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
16
16
|
when "Waline"
|
17
17
|
span.waline-comment-count
|
18
|
-
i.solitude.fa-solid.fa-spinner
|
18
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
19
19
|
when "Valine"
|
20
20
|
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
|
21
|
-
i.solitude.fa-solid.fa-spinner
|
21
|
+
i.solitude.fa-solid.fa-spinner.fa-spin
|
22
22
|
when "Artalk"
|
23
23
|
span.artalk-count
|
24
24
|
| )
|
@@ -3,7 +3,7 @@
|
|
3
3
|
script.
|
4
4
|
const pjax = new Pjax({
|
5
5
|
elements: 'a:not([target="_blank"])',
|
6
|
-
selectors: ['title','#body-wrap','#site-config','meta[name="description"]','.js-pjax','meta[property^="og:"]','#config-diff'],
|
6
|
+
selectors: ['title','#body-wrap','#site-config','meta[name="description"]','.js-pjax','meta[property^="og:"]','#config-diff', '.rs_show', '.rs_hide'],
|
7
7
|
cacheBust: false,
|
8
8
|
analytics: !{google_adsense},
|
9
9
|
scrollRestoration: false
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-solitude",
|
3
|
-
"version": "2.0
|
3
|
+
"version": "2.1.0",
|
4
4
|
"description": "A beautiful, powerful, and efficient Hexo theme developed by everfu.",
|
5
5
|
"main": "package.json",
|
6
6
|
"scripts": {
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"solitude",
|
13
13
|
"Card UI Design",
|
14
14
|
"everfu",
|
15
|
-
"
|
15
|
+
"伍十七",
|
16
16
|
"hexo-theme-solitude"
|
17
17
|
],
|
18
18
|
"repository": {
|
@@ -25,9 +25,9 @@
|
|
25
25
|
},
|
26
26
|
"bugs": {
|
27
27
|
"url": "https://github.com/everfu/hexo-theme-solitude/issues",
|
28
|
-
"email": "o@everfu.
|
28
|
+
"email": "o@everfu.cn"
|
29
29
|
},
|
30
30
|
"homepage": "https://solitude.js.org",
|
31
|
-
"author": "Hexo-Theme-Solitude<o@everfu.
|
31
|
+
"author": "Hexo-Theme-Solitude<o@everfu.cn>",
|
32
32
|
"license": "MIT"
|
33
33
|
}
|
@@ -384,11 +384,7 @@ hexo.extend.filter.register('before_generate', () => {
|
|
384
384
|
enable: false,
|
385
385
|
commentBarrage: false,
|
386
386
|
ctrlOriginalMenu: false,
|
387
|
-
translate:
|
388
|
-
enable: false,
|
389
|
-
defaultEncoding: 2,
|
390
|
-
translateDelay: 0,
|
391
|
-
},
|
387
|
+
translate: false,
|
392
388
|
custom_list: []
|
393
389
|
},
|
394
390
|
lure: {
|
@@ -409,6 +405,19 @@ hexo.extend.filter.register('before_generate', () => {
|
|
409
405
|
light: 'https://bu.dusays.com/2023/09/29/651685cc18d39.jpg',
|
410
406
|
opacity: .2,
|
411
407
|
},
|
408
|
+
translate: {
|
409
|
+
enable: false,
|
410
|
+
defaultEncoding: 2,
|
411
|
+
translateDelay: 0,
|
412
|
+
},
|
413
|
+
rightside: {
|
414
|
+
enable: false,
|
415
|
+
hide: {
|
416
|
+
enable: false,
|
417
|
+
translate: false,
|
418
|
+
mode: false
|
419
|
+
}
|
420
|
+
},
|
412
421
|
CDN: {
|
413
422
|
internal: 'local',
|
414
423
|
third_party: 'cdnjs',
|
@@ -43,8 +43,8 @@
|
|
43
43
|
--sidebar-bg #f6f8fa
|
44
44
|
--btn-hover-color #ff7242
|
45
45
|
--btn-color #fff
|
46
|
-
--btn-bg
|
47
|
-
--text-bg-hover #
|
46
|
+
--btn-bg var(--efu-main)
|
47
|
+
--text-bg-hover #f6f8fa
|
48
48
|
--light-grey #eee
|
49
49
|
--text-highlight-color #1f2d3d
|
50
50
|
--blockquote-color #6a737d
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#aside-content
|
2
|
-
|
2
|
+
+minWidth1200()
|
3
|
+
width 300px
|
3
4
|
if hexo-config('aside.position') == 0
|
4
5
|
order 1
|
5
6
|
else
|
@@ -12,7 +13,8 @@
|
|
12
13
|
padding-left 15px
|
13
14
|
|
14
15
|
+maxWidth1200()
|
15
|
-
|
16
|
+
.card-widget:not(#card-toc)
|
17
|
+
display: none
|
16
18
|
|
17
19
|
+minWidth1300()
|
18
20
|
animation slide-in .6s .3s backwards
|
@@ -62,6 +64,7 @@
|
|
62
64
|
.sticky_layout
|
63
65
|
top calc(60px + .5rem)
|
64
66
|
position sticky
|
67
|
+
z-index 10
|
65
68
|
transition: top .3s ease 0s
|
66
69
|
|
67
70
|
#author-info__sayhi
|
@@ -187,6 +190,21 @@
|
|
187
190
|
right 0
|
188
191
|
padding .5rem
|
189
192
|
|
193
|
+
+maxWidth1200()
|
194
|
+
position: fixed
|
195
|
+
right: 3rem
|
196
|
+
bottom: 2rem
|
197
|
+
z-index: 100
|
198
|
+
max-width: 380px
|
199
|
+
max-height: calc(100% - 60px)
|
200
|
+
width: calc(100% - 80px)
|
201
|
+
transition: transform .3s
|
202
|
+
transform: scale(0)
|
203
|
+
transform-origin: right bottom
|
204
|
+
|
205
|
+
&.open
|
206
|
+
transform: scale(1)
|
207
|
+
|
190
208
|
.toc-content
|
191
209
|
overflow-y: auto
|
192
210
|
max-height: calc(100vh - 300px)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
if hexo-config('rightside.enable')
|
2
|
+
#rightside
|
3
|
+
position: fixed
|
4
|
+
right: -2.5rem
|
5
|
+
bottom: 2.5rem
|
6
|
+
z-index: 1000
|
7
|
+
opacity: 0
|
8
|
+
transition: all .5s
|
9
|
+
|
10
|
+
button
|
11
|
+
display: block
|
12
|
+
margin-bottom: 5px
|
13
|
+
width: 1.8rem
|
14
|
+
height: 1.8rem
|
15
|
+
border-radius: 50%
|
16
|
+
background-color: var(--btn-bg)
|
17
|
+
color: var(--btn-color)
|
18
|
+
text-align: center
|
19
|
+
font-size: 16px
|
20
|
+
|
21
|
+
&.mobile
|
22
|
+
display: none
|
23
|
+
|
24
|
+
+maxWidth900()
|
25
|
+
display: block
|
26
|
+
|
27
|
+
.rs_hide
|
28
|
+
transform: translate(45px, 0)
|
29
|
+
transition: all .4s
|
30
|
+
opacity 0
|
31
|
+
|
32
|
+
&.show
|
33
|
+
opacity .8
|
34
|
+
transform: translate(0, 0)
|
package/source/js/main.js
CHANGED
@@ -26,9 +26,11 @@ const sidebarFn = () => {
|
|
26
26
|
sco.refreshWaterFall();
|
27
27
|
});
|
28
28
|
}
|
29
|
+
|
29
30
|
const scrollFn = () => {
|
30
31
|
let initTop = 0;
|
31
32
|
const $header = document.getElementById('page-header');
|
33
|
+
const $rightside = document.getElementById('rightside') || null;
|
32
34
|
const throttledScroll = utils.throttle(() => {
|
33
35
|
initThemeColor();
|
34
36
|
const currentTop = window.scrollY || document.documentElement.scrollTop;
|
@@ -40,14 +42,17 @@ const scrollFn = () => {
|
|
40
42
|
if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible');
|
41
43
|
}
|
42
44
|
$header.classList.add('nav-fixed');
|
45
|
+
$rightside && ($rightside.style.cssText = 'opacity: 0.8; transform: translateX(-58px);');
|
43
46
|
} else {
|
44
47
|
$header.classList.remove('nav-fixed', 'nav-visible');
|
48
|
+
$rightside && ($rightside.style.cssText = "opacity: ''; transform: ''");
|
45
49
|
}
|
46
50
|
}, 200);
|
47
51
|
window.addEventListener('scroll', (e) => {
|
48
52
|
throttledScroll(e);
|
49
53
|
if (window.scrollY === 0) {
|
50
54
|
$header.classList.remove('nav-fixed', 'nav-visible');
|
55
|
+
$rightside && ($rightside.style.cssText = "opacity: ''; transform: ''");
|
51
56
|
}
|
52
57
|
});
|
53
58
|
|
@@ -656,6 +661,35 @@ class tabs {
|
|
656
661
|
}
|
657
662
|
}
|
658
663
|
|
664
|
+
const scrollFnToDo = () => {
|
665
|
+
const { toc } = PAGE_CONFIG;
|
666
|
+
|
667
|
+
if (toc) {
|
668
|
+
const $cardTocLayout = document.getElementById('card-toc')
|
669
|
+
$cardToc = $cardTocLayout.querySelector('.toc-content')
|
670
|
+
$tocLink = $cardToc.querySelectorAll('.toc-link')
|
671
|
+
$tocPercentage = $cardTocLayout.querySelector('.toc-percentage')
|
672
|
+
isExpand = $cardToc.classList.contains('is-expand')
|
673
|
+
|
674
|
+
// toc percentage
|
675
|
+
const tocItemClickFn = e => {
|
676
|
+
const target = e.target.closest('.toc-link')
|
677
|
+
if (!target) return
|
678
|
+
|
679
|
+
e.preventDefault()
|
680
|
+
utils.scrollToDest(utils.getEleTop(document.getElementById(decodeURI(target.getAttribute('href')).replace('#', ''))), 300)
|
681
|
+
if (window.innerWidth < 900) {
|
682
|
+
$cardTocLayout.classList.remove('open')
|
683
|
+
}
|
684
|
+
}
|
685
|
+
utils.addEventListenerPjax($cardToc, 'click', tocItemClickFn)
|
686
|
+
}
|
687
|
+
}
|
688
|
+
|
689
|
+
const forPostFn = () => {
|
690
|
+
scrollFnToDo()
|
691
|
+
}
|
692
|
+
|
659
693
|
window.refreshFn = () => {
|
660
694
|
const {is_home, is_page, page, is_post} = PAGE_CONFIG;
|
661
695
|
const {runtime, lazyload, lightbox, randomlink, covercolor, post_ai, lure, expire} = GLOBAL_CONFIG;
|
@@ -684,6 +718,8 @@ window.refreshFn = () => {
|
|
684
718
|
if (covercolor.enable) coverColor();
|
685
719
|
if (PAGE_CONFIG.toc) toc.init();
|
686
720
|
if (lure) tabs.lureAddListener();
|
721
|
+
|
722
|
+
forPostFn();
|
687
723
|
}
|
688
724
|
document.addEventListener('DOMContentLoaded', () => {
|
689
725
|
[addCopyright, window.refreshFn, asideStatus, () => window.onscroll = percent, sco.initConsoleState].forEach(fn => fn());
|
package/source/js/tw_cn.js
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
document.addEventListener('DOMContentLoaded', function () {
|
2
2
|
const { defaultEncoding, translateDelay } = GLOBAL_CONFIG.right_menu.translate;
|
3
3
|
const targetEncodingCookie = 'translate-chn-cht';
|
4
|
-
const msgToTraditionalChinese = '轉為繁體';
|
5
|
-
const msgToSimplifiedChinese = '转为简体';
|
6
4
|
|
7
5
|
let currentEncoding = defaultEncoding;
|
8
6
|
let targetEncoding = Number(utils.saveToLocal.get(targetEncodingCookie)) || defaultEncoding;
|
9
|
-
let translateButtonObject;
|
10
7
|
|
11
8
|
function setLang() {
|
12
9
|
document.documentElement.lang = targetEncoding === 1 ? 'zh-TW' : 'zh-CN';
|
@@ -23,7 +20,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
23
20
|
const objs = fobj && typeof fobj === 'object' ? fobj.childNodes : document.body.childNodes;
|
24
21
|
|
25
22
|
objs.forEach(obj => {
|
26
|
-
if (['BR', 'HR'].includes(obj.tagName)
|
23
|
+
if (['BR', 'HR'].includes(obj.tagName)) return;
|
27
24
|
|
28
25
|
if (obj.title) obj.title = translateText(obj.title);
|
29
26
|
if (obj.alt) obj.alt = translateText(obj.alt);
|
@@ -36,12 +33,12 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
36
33
|
});
|
37
34
|
}
|
38
35
|
|
39
|
-
function translatePage() {
|
36
|
+
function translatePage(simeple, traditional ,button) {
|
40
37
|
currentEncoding = targetEncoding;
|
41
38
|
targetEncoding = targetEncoding === 1 ? 2 : 1;
|
42
|
-
|
39
|
+
button.lastChild.textContent = targetEncoding === 1 ? simeple : traditional;
|
43
40
|
|
44
|
-
utils.snackbarShow(targetEncoding === 1 ? '
|
41
|
+
utils.snackbarShow(targetEncoding === 1 ? '你已切換為繁體' : '你已切换为简体');
|
45
42
|
utils.saveToLocal.set(targetEncodingCookie, targetEncoding, 2);
|
46
43
|
setLang();
|
47
44
|
translateBody();
|
@@ -75,14 +72,24 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
75
72
|
}
|
76
73
|
|
77
74
|
function translateInitialization() {
|
78
|
-
|
79
|
-
if (
|
75
|
+
let btn_1 = document.getElementById('menu-translate');
|
76
|
+
if (btn_1) {
|
77
|
+
btn_1.lastChild.textContent = targetEncoding === 1 ? '转为简体' : '转为繁体';
|
80
78
|
if (currentEncoding !== targetEncoding) {
|
81
|
-
translateButtonObject.lastChild.textContent = targetEncoding === 1 ? msgToSimplifiedChinese : msgToTraditionalChinese;
|
82
79
|
setLang();
|
83
80
|
setTimeout(translateBody, translateDelay);
|
84
81
|
}
|
85
|
-
|
82
|
+
btn_1.addEventListener('click', () => {translatePage( '转为简体','转为繁体',btn_1)}, false);
|
83
|
+
}
|
84
|
+
|
85
|
+
let btn_2 = document.querySelector('.rs_hide .translate');
|
86
|
+
if (btn_2) {
|
87
|
+
btn_2.lastChild.textContent = targetEncoding === 1 ? '简' : '繁';
|
88
|
+
if (currentEncoding !== targetEncoding) {
|
89
|
+
setLang();
|
90
|
+
setTimeout(translateBody, translateDelay);
|
91
|
+
}
|
92
|
+
btn_2.addEventListener('click', () => {translatePage('简','繁',btn_2)}, false);
|
86
93
|
}
|
87
94
|
}
|
88
95
|
|