hexo-theme-solitude 1.8.0 → 1.8.2

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.
Files changed (30) hide show
  1. package/README.md +12 -9
  2. package/README_en.md +9 -6
  3. package/README_zh-tw.md +8 -7
  4. package/layout/includes/console.pug +1 -1
  5. package/layout/includes/footer.pug +2 -2
  6. package/layout/includes/head/config.pug +3 -3
  7. package/layout/includes/inject/body.pug +15 -13
  8. package/layout/includes/inject/head.pug +2 -5
  9. package/layout/includes/rightmenu.pug +2 -2
  10. package/layout/includes/widgets/page/links/banner.pug +1 -1
  11. package/layout/includes/widgets/post/postMeta.pug +18 -17
  12. package/layout/includes/widgets/third-party/comments/artalk.pug +2 -2
  13. package/layout/includes/widgets/third-party/comments/comment.pug +1 -12
  14. package/layout/includes/widgets/third-party/comments/js.pug +12 -0
  15. package/layout/includes/widgets/third-party/comments/twikoo.pug +17 -22
  16. package/layout/includes/widgets/third-party/comments/valine.pug +23 -27
  17. package/layout/includes/widgets/third-party/comments/waline.pug +22 -24
  18. package/layout/includes/widgets/third-party/news-comment/artalk.pug +6 -7
  19. package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +5 -5
  20. package/layout/includes/widgets/third-party/news-comment/valine.pug +20 -18
  21. package/layout/includes/widgets/third-party/news-comment/waline.pug +11 -9
  22. package/layout/includes/widgets/third-party/pjax.pug +1 -11
  23. package/layout/page.pug +1 -0
  24. package/layout/post.pug +1 -0
  25. package/package.json +1 -1
  26. package/plugins.yml +5 -4
  27. package/scripts/filter/default.js +1 -1
  28. package/source/css/index.styl +1 -1
  29. package/source/js/barrage_comment.js +19 -13
  30. package/source/js/right_menu.js +3 -3
package/README.md CHANGED
@@ -10,11 +10,11 @@
10
10
 
11
11
  主题由 [@张洪Heo](https://github.com/zhheo) 作者全权授权、设计!
12
12
 
13
- ![npm package](https://img.shields.io/npm/v/hexo-theme-solitude?color=blue&logo=npm)
13
+ ![npm package](https://img.shields.io/npm/v/hexo-theme-solitude?logo=npm)
14
14
  ![release](https://img.shields.io/github/package-json/v/valor-x/hexo-theme-solitude/master?color=%231ab1ad&label=release)
15
15
  ![license](https://img.shields.io/github/license/valor-x/hexo-theme-solitude?color=FF5531)
16
16
  [![Stars](https://img.shields.io/github/stars/valor-x/hexo-theme-solitude)](https://github.com/valor-x/hexo-theme-solitude/stargazers)
17
- [![GitHub all releases](https://img.shields.io/github/downloads/valor-x/hexo-theme-solitude/total)](https://github.com/valor-x/hexo-theme-solitude/releases/latest)
17
+ [![NPM all downloads](https://img.shields.io/npm/dy/hexo-theme-solitude?color=white)](https://www.npmjs.com/package/hexo-theme-solitude)
18
18
 
19
19
  ![hexo version](https://img.shields.io/badge/hexo-7.0.0+-blue?logo=hexo&logoColor=white)
20
20
  ![node version](https://img.shields.io/badge/node-14.0.0-white?logo=node.js&logoColor=white)
@@ -28,8 +28,9 @@
28
28
  ![mermaid](https://img.shields.io/badge/mermaid-ff3670?logo=mermaid&logoColor=white)
29
29
  [![pwa](https://img.shields.io/badge/pwa-red?logo=pwa)](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
30
30
 
31
- [![twiter](https://img.shields.io/badge/@efu__oo-gray?logo=x)](https://twitter.com/efu_oo)
32
- [![TG](https://img.shields.io/badge/efuome-gray?logo=Telegram&logoColor=white)](https://t.me/solitudePro)
31
+ [![twiter](https://img.shields.io/badge/Twitter-gray?logo=x)](https://twitter.com/efu_oo)
32
+ [![TG](https://img.shields.io/badge/Telegram-gray?logo=Telegram&logoColor=white)](https://t.me/solitudePro)
33
+ [![Discord](https://img.shields.io/discord/1218118131428495430?label=Discord&logo=Discord&labelColor=white&color=black)](https://discord.gg/Y8VEvVgW)
33
34
 
34
35
  ![JetBrains](https://img.shields.io/badge/jetbrains-support-black?logo=jetbrains)
35
36
  ![DuoLingo](https://img.shields.io/badge/duolingo-support-black?logo=duolingo&logoColor=white)
@@ -37,7 +38,7 @@
37
38
  [![gitee](https://img.shields.io/badge/Gitee-red?logo=gitee)](https://gitee.com/nsjjd_w/hexo-theme-solitude)
38
39
  [![gitlab](https://img.shields.io/badge/GitLab-blue?logo=gitlab)](https://gitlab.com/efu/hexo-theme-solitude)
39
40
 
40
- [预览](https://efu.me/) 丨 [文档](https://solitude-docs.efu.me/)
41
+ [预览](https://www.efu.me/) 丨 [文档](https://solitude-docs.efu.me/)
41
42
 
42
43
  </div>
43
44
 
@@ -47,7 +48,7 @@
47
48
 
48
49
  - 页面懒加载(Pjax)、图片懒加载(LazyLoad)、离线应用(PWA)
49
50
  - 评论(Twikoo、Waline、Valine、Artalk),支持双评论
50
- - 显示切换(ColorMode)
51
+ - 昼夜切换(ColorMode)
51
52
  - 灯箱(medium-zoom、fancybox)
52
53
  - 数学公式(Latex)
53
54
  - 特色页面:即刻短文、我的装备、在线工具、音乐馆、友链鱼塘、相册页、豆瓣页
@@ -55,9 +56,11 @@
55
56
 
56
57
  ## Todo
57
58
 
58
- - [x] Waline 评论支持
59
- - [ ] Tags plugin 插件化
60
- - [ ] 相册页重构(已移除,待重构)
59
+ - [x] Artalk 评论
60
+ - [x] 双评论
61
+ - [x] 相册
62
+
63
+ > 如有問題請提 [issue](https://github.com/valor-x/hexo-theme-solitude/issues)
61
64
 
62
65
  ## 应用
63
66
 
package/README_en.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ![release](https://img.shields.io/github/package-json/v/valor-x/hexo-theme-solitude/master?color=%231ab1ad&label=release)
15
15
  ![license](https://img.shields.io/github/license/valor-x/hexo-theme-solitude?color=FF5531)
16
16
  [![Stars](https://img.shields.io/github/stars/valor-x/hexo-theme-solitude)](https://github.com/valor-x/hexo-theme-solitude/stargazers)
17
- [![GitHub all releases](https://img.shields.io/github/downloads/valor-x/hexo-theme-solitude/total)](https://github.com/valor-x/hexo-theme-solitude/releases/latest)
17
+ [![NPM all downloads](https://img.shields.io/npm/dy/hexo-theme-solitude?color=white)](https://www.npmjs.com/package/hexo-theme-solitude)
18
18
 
19
19
  ![hexo version](https://img.shields.io/badge/hexo-7.0.0+-blue?logo=hexo&logoColor=white)
20
20
  ![node version](https://img.shields.io/badge/node-14.0.0-white?logo=node.js&logoColor=white)
@@ -28,8 +28,9 @@
28
28
  ![mermaid](https://img.shields.io/badge/mermaid-ff3670?logo=mermaid&logoColor=white)
29
29
  [![pwa](https://img.shields.io/badge/pwa-red?logo=pwa)](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
30
30
 
31
- [![twiter](https://img.shields.io/badge/@efu__oo-gray?logo=x)](https://twitter.com/efu_oo)
32
- [![TG](https://img.shields.io/badge/efuome-gray?logo=Telegram&logoColor=white)](https://t.me/solitudePro)
31
+ [![twiter](https://img.shields.io/badge/Twitter-gray?logo=x)](https://twitter.com/efu_oo)
32
+ [![TG](https://img.shields.io/badge/Telegram-gray?logo=Telegram&logoColor=white)](https://t.me/solitudePro)
33
+ [![Discord](https://img.shields.io/discord/1218118131428495430?label=Discord&logo=Discord&labelColor=white&color=black)](https://discord.gg/Y8VEvVgW)
33
34
 
34
35
  ![JetBrains](https://img.shields.io/badge/jetbrains-support-black?logo=jetbrains)
35
36
  ![DuoLingo](https://img.shields.io/badge/duolingo-support-black?logo=duolingo&logoColor=white)
@@ -55,9 +56,11 @@
55
56
 
56
57
  ## Todo
57
58
 
58
- - [x] Support Waline
59
- - [ ] Tags plugin
60
- - [ ] Album reconstruction(Removed, to be refactored)
59
+ - [x] Artalk
60
+ - [x] Use double comment
61
+ - [x] Album
62
+
63
+ > If you have any questions, please issue an [issue](https://github.com/valor-x/hexo-theme-solitude/issues)
61
64
 
62
65
  ## Setup
63
66
 
package/README_zh-tw.md CHANGED
@@ -14,7 +14,7 @@
14
14
  ![release](https://img.shields.io/github/package-json/v/valor-x/hexo-theme-solitude/master?color=%231ab1ad&label=release)
15
15
  ![license](https://img.shields.io/github/license/valor-x/hexo-theme-solitude?color=FF5531)
16
16
  [![Stars](https://img.shields.io/github/stars/valor-x/hexo-theme-solitude)](https://github.com/valor-x/hexo-theme-solitude/stargazers)
17
- [![GitHub all releases](https://img.shields.io/github/downloads/valor-x/hexo-theme-solitude/total)](https://github.com/valor-x/hexo-theme-solitude/releases/latest)
17
+ [![NPM all downloads](https://img.shields.io/npm/dy/hexo-theme-solitude?color=white)](https://www.npmjs.com/package/hexo-theme-solitude)
18
18
 
19
19
  ![hexo version](https://img.shields.io/badge/hexo-7.0.0+-blue?logo=hexo&logoColor=white)
20
20
  ![node version](https://img.shields.io/badge/node-14.0.0-white?logo=node.js&logoColor=white)
@@ -28,8 +28,9 @@
28
28
  ![mermaid](https://img.shields.io/badge/mermaid-ff3670?logo=mermaid&logoColor=white)
29
29
  [![pwa](https://img.shields.io/badge/pwa-red?logo=pwa)](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
30
30
 
31
- [![twiter](https://img.shields.io/badge/@efu__oo-gray?logo=x)](https://twitter.com/efu_oo)
32
- [![TG](https://img.shields.io/badge/efuome-gray?logo=Telegram&logoColor=white)](https://t.me/solitudePro)
31
+ [![twiter](https://img.shields.io/badge/Twitter-gray?logo=x)](https://twitter.com/efu_oo)
32
+ [![TG](https://img.shields.io/badge/Telegram-gray?logo=Telegram&logoColor=white)](https://t.me/solitudePro)
33
+ [![Discord](https://img.shields.io/discord/1218118131428495430?label=Discord&logo=Discord&labelColor=white&color=black)](https://discord.gg/Y8VEvVgW)
33
34
 
34
35
  ![JetBrains](https://img.shields.io/badge/jetbrains-support-black?logo=jetbrains)
35
36
  ![DuoLingo](https://img.shields.io/badge/duolingo-support-black?logo=duolingo&logoColor=white)
@@ -47,7 +48,7 @@
47
48
 
48
49
  - 頁面懶載入(Pjax)、圖片懶載入(LazyLoad)、離線應用(PWA)
49
50
  - 評論(Twikoo、Waline、Valine、Artalk),支援雙評論
50
- - 顯示切換(ColorMode)
51
+ - 晝夜切換(ColorMode)
51
52
  - 燈箱(medium-zoom、fancybox)
52
53
  - 數學公式(Latex)
53
54
  - 特色頁面:即刻短文、我的裝備、在線工具、音樂館、友鏈魚塘、相冊頁、豆瓣頁
@@ -55,9 +56,9 @@
55
56
 
56
57
  ## Todo
57
58
 
58
- - [x] Waline 評論支援
59
- - [ ] Tags plugin 外掛程式化
60
- - [ ] 相冊頁重構(已移除,待重構)
59
+ - [x] Artalk 評論
60
+ - [x] 雙評論
61
+ - [x] 相冊
61
62
 
62
63
  ## 應用
63
64
 
@@ -39,7 +39,7 @@ div#console
39
39
  div.console-btn-item#consoleMusic(onclick="sco.musicToggle()")
40
40
  span.music-switch(title=_p('console.switch_music'))
41
41
  i.solitude.st-disc-fill
42
- if theme.comment.enable && theme.comment.commentBarrage
42
+ if theme.comment.use && theme.comment.commentBarrage
43
43
  div.console-btn-item.on#consoleCommentBarrage(onclick="sco.switchCommentBarrage()")
44
44
  span.commentBarrage
45
45
  i.solitude.st-chat-fill
@@ -52,7 +52,7 @@ div#footer-bar
52
52
  a.footer-bar-link(href=url_for("/"))= config.author
53
53
  div.footer-bar-right
54
54
  each item in theme.footer.links
55
- a.footer-bar-link(href=url_for(item.url), title=item.name)= item.name
55
+ a.footer-bar-link(href=url_for(item.url), alt=item.name)!= item.name
56
56
  a.footer-bar-link.cc(href=url_for(theme.footer.license), aria-label = 'copyright')
57
57
  i.solitude.st-copyright-line
58
58
  i.solitude.st-creative-commons-by-line
@@ -65,5 +65,5 @@ if theme.footer.privacy
65
65
  span.cookies-tip= __('cookies.tip')
66
66
  a.cookies-link(href=url_for(theme.footer.privacy), title=_p('cookies.privacy'))
67
67
  i.solitude.st-right-btn-fill
68
- if theme.comment.enable && theme.comment.commentBarrage
68
+ if theme.comment.use && theme.comment.commentBarrage
69
69
  div.comment-barrage.needEndHide
@@ -26,7 +26,7 @@
26
26
 
27
27
  let comment = false
28
28
 
29
- if (theme.comment.enable) {
29
+ if (theme.comment.use) {
30
30
  comment = {
31
31
  avatar: theme.comment.avatar,
32
32
  commentBarrage: theme.comment.commentBarrage,
@@ -85,7 +85,7 @@
85
85
  }
86
86
  }
87
87
 
88
- if (theme.comment.enable && theme.comment.commentBarrage) {
88
+ if (theme.comment.use && theme.comment.commentBarrage) {
89
89
  lang.barrage = {
90
90
  title: _p('commentBarrage.title'),
91
91
  }
@@ -106,7 +106,7 @@
106
106
  stop: _p('right_menu.music.stop'),
107
107
  }
108
108
  }
109
- if (theme.comment.enable && theme.comment.commentBarrage) {
109
+ if (theme.comment.use && theme.comment.commentBarrage) {
110
110
  rightMenu.barrage = {
111
111
  open: _p('right_menu.barrage.open'),
112
112
  close: _p('right_menu.barrage.close')
@@ -80,19 +80,21 @@ div
80
80
  each item in theme.extends.body
81
81
  != item
82
82
 
83
- div#js-pjax
84
- if theme.mermaid
85
- script.
86
- mermaid.run();
87
- if is_home() && theme.carousel && site.posts.data.filter(item => item.recommend === true).slice(0, 6) || false
88
- script.
89
- carousel_swiper()
90
- if page.type === 'says' && theme.says.enable
91
- script.
92
- GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img"));
93
- sco.changeTimeFormat(document.querySelectorAll('.bber-info-time time'))
94
- if theme.busuanzi && (theme.aside.siteinfo.uv || theme.aside.siteinfo.pv)
95
- script(async src=url_for(theme.cdn.busuanzi_js))
83
+ .js-pjax
84
+ if comment_js
85
+ include ../widgets/third-party/comments/js
86
+ if theme.mermaid
87
+ script.
88
+ mermaid.run();
89
+ if is_home() && theme.carousel && site.posts.data.filter(item => item.recommend === true).slice(0, 6) || false
90
+ script.
91
+ carousel_swiper()
92
+ if page.type === 'says' && theme.says.enable
93
+ script.
94
+ GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img"));
95
+ sco.changeTimeFormat(document.querySelectorAll('.bber-info-time time'))
96
+ if theme.busuanzi && (theme.aside.siteinfo.uv || theme.aside.siteinfo.pv)
97
+ script(async src=url_for(theme.cdn.busuanzi_js))
96
98
 
97
99
 
98
100
  if theme.footer.randomlink
@@ -28,7 +28,7 @@ if theme.pwa.enable
28
28
 
29
29
  script.
30
30
  console.log(
31
- "%c Program: Hexo %c Theme: Solitude %c Version: v1.8.0",
31
+ "%c Program: Hexo %c Theme: Solitude %c Version: v1.8.2",
32
32
  "border-radius:5px 0 0 5px;padding: 5px 10px;color:white;background:#ff3842;",
33
33
  "padding: 5px 10px;color:white;background:#3e9f50;",
34
34
  "border-radius:0 5px 5px 0;padding: 5px 10px;background:#0084ff;color:white;"
@@ -39,7 +39,4 @@ if theme.extends.head
39
39
  != item
40
40
 
41
41
  script(src=url_for(theme.cdn.utils))
42
- script(src=url_for(theme.cdn.main))
43
-
44
- if theme.comment.use.includes('Valine')
45
- script(src=url_for(theme.cdn.blueimp_md5))
42
+ script(src=url_for(theme.cdn.main))
@@ -17,7 +17,7 @@ div#rightMenu
17
17
  div.rightMenu-item#menu-pastetext
18
18
  i.solitude.st-clipboard-fill
19
19
  span= _p('right_menu.paste')
20
- if theme.comment.enable
20
+ if theme.comment.use
21
21
  div.rightMenu-item#menu-commenttext
22
22
  i.solitude.st-chat-new-fill
23
23
  span= _p('right_menu.comment')
@@ -56,7 +56,7 @@ div#rightMenu
56
56
  i.solitude(class=item.icon)
57
57
  span= item.name
58
58
  div.rightMenu-group.rightMenu-line.rightMenuOther
59
- if theme.right_menu.commentBarrage && theme.comment.enable && theme.comment.commentBarrage
59
+ if theme.right_menu.commentBarrage && theme.comment.use && theme.comment.commentBarrage
60
60
  div.rightMenu-item#menu-commentBarrage(onclick="sco.switchCommentBarrage()")
61
61
  i.solitude.st-chat-fill
62
62
  span.menu-commentBarrage-text= _p('right_menu.barrage.open')
@@ -7,7 +7,7 @@
7
7
  a.banner-button.secondary(onclick="travelling()")
8
8
  i.solitude.st-signal-tower-fill
9
9
  span.banner-button-text=_p('link.banner.random')
10
- if theme.comment.enable
10
+ if theme.comment.use
11
11
  a.banner-button(onclick="sco.scrollToComment()")
12
12
  i.solitude.st-right-btn-fill
13
13
  span.solitude.banner-button-text=_p('link.banner.toComment')
@@ -40,25 +40,26 @@
40
40
  if theme.post.meta.pv
41
41
  a.post-meta-pv(href=url_for(page.path), title=_p('post.pv'))
42
42
  i.post-meta-icon.solitude.st-fire-fill
43
- case theme.comment.use[0]
44
- when "Twikoo"
45
- span#twikoo_visitors
46
- i.solitude.st-loading-line
47
- when "Waline"
48
- span.waline-pageview-count
49
- i.solitude.st-loading-line
50
- when "Valine"
51
- span.leancloud_visitors(id=url_for(page.path))
52
- span.leancloud-visitors-count
43
+ if theme.comment.use
44
+ case theme.comment.use[0]
45
+ when "Twikoo"
46
+ span#twikoo_visitors
47
+ i.solitude.st-loading-line
48
+ when "Waline"
49
+ span.waline-pageview-count
50
+ i.solitude.st-loading-line
51
+ when "Valine"
52
+ span.leancloud_visitors(id=url_for(page.path))
53
+ span.leancloud-visitors-count
54
+ i.solitude.st-loading-line
55
+ when 'Artalk'
56
+ span#ArtalkPV
53
57
  i.solitude.st-loading-line
54
- when 'Artalk'
55
- span#ArtalkPV
58
+ else
59
+ if theme.busuanzi
60
+ span#busuanzi_value_page_pv
56
61
  i.solitude.st-loading-line
57
- default
58
- if theme.busuanzi
59
- span#busuanzi_value_page_pv
60
- i.solitude.st-loading-line
61
- if theme.post.meta.comment && page.comment && theme.comment.count
62
+ if theme.post.meta.comment && page.comment && theme.comment.count && theme.comment.use
62
63
  span.post-meta-commentcount(title=_p('post.comment'), onclick="sco.scrollTo('post-comment')")
63
64
  i.solitude.st-chat-fill
64
65
  a(href=url_for(page.path) + "#post-comment")
@@ -25,7 +25,7 @@ script.
25
25
  utils.lightbox($content.querySelectorAll('img:not([atk-emoticon])'))
26
26
  sco.owoBig({body: '.atk-grp', item: '.atk-item'})
27
27
  })
28
- !{commentBarrage} && getBarrage(array)
28
+ !{commentBarrage} && barrageArtalk(array)
29
29
  })
30
30
  const destroyArtalk = () => artalkItem.destroy()
31
31
  utils.addGlobalFn('pjax', destroyArtalk, 'destroyArtalk')
@@ -54,7 +54,7 @@ script.
54
54
 
55
55
  if commentBarrage
56
56
  script.
57
- async function getBarrage(array) {
57
+ async function barrageArtalk(array) {
58
58
  await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() => {
59
59
  initializeCommentBarrage(array)
60
60
  })
@@ -39,15 +39,4 @@
39
39
  when 'Waline'
40
40
  #waline-wrap
41
41
  when 'Artalk'
42
- #artalk-wrap
43
-
44
- each name in use
45
- case name
46
- when 'Twikoo'
47
- !=partial('includes/widgets/third-party/comments/twikoo', {}, {cache: true})
48
- when 'Waline'
49
- !=partial('includes/widgets/third-party/comments/waline', {}, {cache: true})
50
- when 'Valine'
51
- !=partial('includes/widgets/third-party/comments/valine', {}, {cache: true})
52
- when 'Artalk'
53
- !=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
42
+ #artalk-wrap
@@ -0,0 +1,12 @@
1
+ - const {use} = theme.comment
2
+
3
+ each name in use
4
+ case name
5
+ when 'Twikoo'
6
+ !=partial('includes/widgets/third-party/comments/twikoo', {}, {cache: true})
7
+ when 'Waline'
8
+ !=partial('includes/widgets/third-party/comments/waline', {}, {cache: true})
9
+ when 'Valine'
10
+ !=partial('includes/widgets/third-party/comments/valine', {}, {cache: true})
11
+ when 'Artalk'
12
+ !=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
@@ -12,7 +12,7 @@ script.
12
12
  urls: [window.location.pathname],
13
13
  includeReply: false
14
14
  }).then(res => {
15
- ele.forEach(item => item.textContent=res[0].count)
15
+ ele.forEach(item => item.textContent = res[0].count)
16
16
  }).catch(err => {
17
17
  console.error(err)
18
18
  })
@@ -33,7 +33,7 @@ script.
33
33
  item: '.OwO-items li'
34
34
  })
35
35
 
36
- !{commentBarrage} && getBarrage()
36
+ if (!{commentBarrage}) await barrageTwikoo()
37
37
  }
38
38
 
39
39
  const loadTwikoo = () => {
@@ -51,23 +51,20 @@ script.
51
51
 
52
52
  if commentBarrage
53
53
  script.
54
- async function getBarrage() {
55
- try {
56
- const response = await fetch("!{envId}", {
57
- method: "POST",
58
- headers: {
59
- "Content-Type": "application/json"
60
- },
61
- body: JSON.stringify({
62
- event: "COMMENT_GET",
63
- accessToken: "!{accessToken}",
64
- url: window.location.pathname
65
- })
66
- });
67
- if (!response.ok) {
68
- throw new Error("HTTP error! status: " + response.status);
69
- }
70
- const data = await response.json();
54
+ async function barrageTwikoo() {
55
+ await fetch("!{envId}", {
56
+ method: "POST",
57
+ headers: {
58
+ "Content-Type": "application/json"
59
+ },
60
+ body: JSON.stringify({
61
+ event: "COMMENT_GET",
62
+ accessToken: "!{accessToken}",
63
+ url: window.location.pathname
64
+ })
65
+ }).then(async res => {
66
+ if (!res.ok) throw new Error("HTTP error! status: " + res.status)
67
+ const data = await res.json();
71
68
  await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() => {
72
69
  initializeCommentBarrage((data.data).map(item => Object.assign({
73
70
  content: item.comment,
@@ -76,7 +73,5 @@ if commentBarrage
76
73
  id: item.id
77
74
  })))
78
75
  })
79
- } catch (error) {
80
- console.error("An error occurred while fetching comments: ", error);
81
- }
76
+ }).catch(error => console.error("An error occurred while fetching comments: ", error))
82
77
  }
@@ -27,7 +27,7 @@ script.
27
27
  else {
28
28
  await utils.getScript('!{url_for(theme.cdn.valine)}').then(initValine)
29
29
  }
30
- !{commentBarrage} && getBarrage()
30
+ !{commentBarrage} && barrageValine()
31
31
  }
32
32
  if ('!{use[0]}' === 'Valine' || !{lazyload}) {
33
33
  if (!{lazyload}) utils.loadComment(document.getElementById('vcomment'), loadValine)
@@ -39,36 +39,32 @@ script.
39
39
 
40
40
  if commentBarrage
41
41
  script.
42
- async function getBarrage() {
42
+ async function barrageValine() {
43
43
  const url = new URL('!{serverURLs}/1.1/classes/Comment')
44
44
  const params = {
45
45
  url: window.location.pathname,
46
46
  order: '-createdAt'
47
47
  }
48
48
  Object.entries(params).forEach(([key, value]) => url.searchParams.append(key, value))
49
- try {
50
- const response = await fetch(url, {
51
- method: "GET",
52
- headers: {
53
- "X-LC-Id": "#{appId}",
54
- "X-LC-Key": "#{appKey}",
55
- "Content-Type": "application/json"
56
- },
57
- })
58
- if (!response.ok) {
59
- throw new Error(`HTTP error! status: ${response.status}`)
60
- }
61
- const data = await response.json()
62
- await utils.getScript('!{url_for(theme.cdn.commentBarrage)}')
63
- initializeCommentBarrage(data.results
64
- .filter(item => item.url === window.location.pathname)
65
- .map(item => ({
66
- content: item.comment,
67
- nick: item.nick,
68
- mailMd5: md5(item.mail),
69
- id: item.objectId
70
- })))
71
- } catch (error) {
72
- console.error("An error occurred while fetching comments: ", error)
73
- }
49
+ await fetch(url, {
50
+ method: "GET",
51
+ headers: {
52
+ "X-LC-Id": "#{appId}",
53
+ "X-LC-Key": "#{appKey}",
54
+ "Content-Type": "application/json"
55
+ },
56
+ }).then(async res => {
57
+ if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
58
+ const data = await res.json()
59
+ if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
60
+ await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() =>
61
+ initializeCommentBarrage(data.results
62
+ .filter(item => item.url === window.location.pathname)
63
+ .map(item => ({
64
+ content: item.comment,
65
+ nick: item.nick,
66
+ mailMd5: md5(item.mail),
67
+ id: item.objectId
68
+ }))))
69
+ }).catch(error => console.error("An error occurred while fetching comments: ", error))
74
70
  }
@@ -1,5 +1,5 @@
1
- - const { envId, option ,pageview } = theme.comment.waline
2
- - const { lazyload, count, commentBarrage } = theme.comment
1
+ - const { envId, option ,pageview } = theme.waline
2
+ - const { lazyload, count, commentBarrage,use } = theme.comment
3
3
 
4
4
  script.
5
5
  !function () {
@@ -18,7 +18,10 @@ script.
18
18
  const walineInstance = initFn(walineOptions)
19
19
  utils.addGlobalFn('pjax', () => walineInstance.destroy(), 'destroyWaline')
20
20
  GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll('#comment .wl-content img:not(.wl-emoji)'))
21
- sco.owoBig()
21
+ sco.owoBig({
22
+ body: '.wl-emoji-popup',
23
+ item: '.wl-tab-wrapper button'
24
+ })
22
25
  }
23
26
 
24
27
  async function loadWaline() {
@@ -30,10 +33,10 @@ script.
30
33
  initWaline(walineInitFunction)
31
34
  window.walineFn = walineInitFunction
32
35
  }
33
- if (!{commentBarrage}) getBarrage()
36
+ !{commentBarrage} && barrageWaline()
34
37
  }
35
38
 
36
- if ('!{use[0]}' === 'Valine' || !{lazyload}) {
39
+ if (!{use[0] === 'Waline'} || !{lazyload}) {
37
40
  if (!{lazyload}) utils.loadComment(document.getElementById('waline-wrap'), loadWaline)
38
41
  else loadWaline()
39
42
  } else window.loadTwoComment = loadWaline
@@ -41,27 +44,22 @@ script.
41
44
 
42
45
  if commentBarrage
43
46
  script.
44
- async function getBarrage() {
47
+ async function barrageWaline() {
45
48
  const url = new URL('!{envId}/api/comment')
46
49
  const params = {path: window.location.pathname, sortBy: 'insertedAt_asc'}
47
50
  Object.entries(params).forEach(([key, value]) => url.searchParams.append(key, value))
48
- try {
49
- const response = await fetch(url, {
50
- method: "GET",
51
- headers: {
52
- "Content-Type": "application/json"
53
- },
51
+ await fetch(url).then(async res => {
52
+ if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
53
+ const data = await res.json();
54
+ const regex = /<img [^>]*class="wl-emoji"[^>]*>/;
55
+ await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(() => {
56
+ initializeCommentBarrage(data.data.data
57
+ .map(item => ({
58
+ nick: item.nick,
59
+ mailId: item.avatar,
60
+ content: item.comment.replace(regex, ''),
61
+ id: item.objectId
62
+ })))
54
63
  })
55
- if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`)
56
- const data = await response.json();
57
- await utils.getScript('!{url_for(theme.cdn.commentBarrage)}')
58
- initializeCommentBarrage(data.data.map(item => ({
59
- nick: item.nick,
60
- mailId: item.avatar,
61
- content: item.comment,
62
- id: item.objectId
63
- })))
64
- } catch (error) {
65
- console.error("An error occurred while fetching comments: ", error)
66
- }
64
+ }).catch(error => console.error("An error occurred while fetching comments: ", error))
67
65
  }
@@ -47,9 +47,8 @@ script.
47
47
  }
48
48
 
49
49
  const getComment = async (asideList) => {
50
- try {
51
- const searchParams = new URLSearchParams({'site_name': "!{site}", 'limit': '6'})
52
- const res = await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'})
50
+ const searchParams = new URLSearchParams({'site_name': "!{site}", 'limit': '6'})
51
+ await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'}).then(async res => {
53
52
  const result = await res.json()
54
53
  const avatarConfig = await getSetting()
55
54
  const {mirror, params, default: defaults} = avatarConfig.frontend_conf.gravatar
@@ -65,11 +64,11 @@ script.
65
64
  }))
66
65
  utils.saveToLocal.set('artalk-newest-comments', artalk, !{theme.comment.newest_comment.storage})
67
66
  generateHtml(artalk, asideList)
68
- } catch (e) {
69
- console.error(e);
67
+ }).catch(error => {
68
+ console.error(error);
70
69
  asideList.textContent = "!{_p('newest_comment.error')}"
71
- }
72
- };
70
+ })
71
+ }
73
72
 
74
73
  const newestCommentInit = (asideList) => {
75
74
  const data = utils.saveToLocal.get('artalk-newest-comments')
@@ -1,10 +1,10 @@
1
- if theme.console_plus && theme.comment.newest_comment.enable
1
+ if theme.comment.use && theme.console_plus && theme.comment.newest_comment.enable
2
2
  case theme.comment.use[0]
3
3
  when 'Twikoo'
4
- !=partial('includes/widgets/third-party/news-comment/twikoo',{}, {cache: true})
4
+ !=partial('includes/widgets/third-party/news-comment/twikoo', {}, {cache: true})
5
5
  when 'Waline'
6
- !=partial('includes/widgets/third-party/news-comment/waline',{}, {cache: true})
6
+ !=partial('includes/widgets/third-party/news-comment/waline', {}, {cache: true})
7
7
  when 'Valine'
8
- !=partial('includes/widgets/third-party/news-comment/valine',{}, {cache: true})
8
+ !=partial('includes/widgets/third-party/news-comment/valine', {}, {cache: true})
9
9
  when 'Artalk'
10
- !=partial('includes/widgets/third-party/news-comment/artalk',{}, {cache: true})
10
+ !=partial('includes/widgets/third-party/news-comment/artalk', {}, {cache: true})
@@ -5,7 +5,10 @@ script.
5
5
 
6
6
  const replacements = [
7
7
  {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
8
- {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '[!{_p("console.newest_comment.link")}]'},
8
+ {
9
+ regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
10
+ replacement: '[!{_p("console.newest_comment.link")}]'
11
+ },
9
12
  {regex: /```[\s\S]*?```/g, replacement: '[!{_p("console.newest_comment.code")}]'},
10
13
  {regex: /<[^>]+>/g, replacement: ""}
11
14
  ];
@@ -26,17 +29,16 @@ script.
26
29
  }
27
30
 
28
31
  const getComment = async () => {
29
- try {
30
- const settings = {
31
- "method": "GET",
32
- "headers": {
33
- "X-LC-Id": '!{theme.valine.appId}',
34
- "X-LC-Key": '!{theme.valine.appKey}',
35
- "Content-Type": "application/json"
36
- },
37
- }
38
-
39
- const res = await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings)
32
+ const settings = {
33
+ "method": "GET",
34
+ "headers": {
35
+ "X-LC-Id": '!{theme.valine.appId}',
36
+ "X-LC-Key": '!{theme.valine.appKey}',
37
+ "Content-Type": "application/json"
38
+ },
39
+ }
40
+ if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
41
+ await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings).then(async res => {
40
42
  const result = await res.json()
41
43
  window.res = result
42
44
  const valineArray = result.results.map(e => {
@@ -50,10 +52,10 @@ script.
50
52
  })
51
53
  utils.saveToLocal.set('valine-newest-comment', valineArray, !{theme.comment.newest_comment.storage})
52
54
  generateHtml(valineArray)
53
- } catch (err) {
54
- console.error(err)
55
+ }).catch(error => {
56
+ console.error(error);
55
57
  $asideList.textContent = "!{_p('newest_comment.error')}"
56
- }
58
+ })
57
59
  }
58
60
 
59
61
  const generateHtml = array => {
@@ -70,9 +72,9 @@ script.
70
72
  </div>
71
73
  </div>
72
74
  `).join('') : "!{_p('newest_comment.zero')}"
73
- window.lazyLoadInstance && window.lazyLoadInstance.update()
74
- window.pjax && window.pjax.refresh()
75
- sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
75
+ window.lazyLoadInstance?.update()
76
+ window.pjax?.refresh()
77
+ sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
76
78
  }
77
79
 
78
80
  newestCommentInit()
@@ -5,7 +5,10 @@ script.
5
5
 
6
6
  const replacements = [
7
7
  {regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
8
- {regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, replacement: '[!{_p("console.newest_comment.link")}]'},
8
+ {
9
+ regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
10
+ replacement: '[!{_p("console.newest_comment.link")}]'
11
+ },
9
12
  {regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
10
13
  {regex: /<[^>]+>/g, replacement: ""}
11
14
  ];
@@ -26,8 +29,7 @@ script.
26
29
  }
27
30
 
28
31
  const getComment = async () => {
29
- try {
30
- const res = await fetch('!{theme.waline.envId}/api/comment?type=recent&count=8', {method: 'GET'})
32
+ await fetch('!{theme.waline.envId}/api/comment?type=recent&count=8', {method: 'GET'}).then(async res => {
31
33
  const result = await res.json()
32
34
  const walineArray = result.data.map(e => {
33
35
  return {
@@ -40,10 +42,10 @@ script.
40
42
  })
41
43
  utils.saveToLocal.set('waline-newest-comment', walineArray, !{theme.comment.newest_comment.storage})
42
44
  generateHtml(walineArray)
43
- } catch (err) {
44
- console.error(err)
45
+ }).catch(error => {
46
+ console.error(error)
45
47
  $asideList.textContent = "!{_p('newest_comment.error')}"
46
- }
48
+ })
47
49
  }
48
50
 
49
51
  const generateHtml = array => {
@@ -60,9 +62,9 @@ script.
60
62
  </div>
61
63
  </div>
62
64
  `).join('') : "!{_p('newest_comment.zero')}"
63
- window.lazyLoadInstance && window.lazyLoadInstance.update()
64
- window.pjax && window.pjax.refresh()
65
- sco && sco.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
65
+ window.lazyLoadInstance?.update()
66
+ window.pjax?.refresh()
67
+ sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
66
68
  }
67
69
 
68
70
  newestCommentInit()
@@ -1,17 +1,7 @@
1
1
  script.
2
- let pjaxSelectors = [
3
- 'title',
4
- '#body-wrap',
5
- '#site-config',
6
- 'meta[name="description"]',
7
- '#js-pjax',
8
- 'meta[property^="og:"]',
9
- '#config-diff'
10
- ]
11
-
12
2
  const pjax = new Pjax({
13
3
  elements: 'a:not([target="_blank"])',
14
- selectors: pjaxSelectors,
4
+ selectors: ['title','#body-wrap','#site-config','meta[name="description"]','.js-pjax','meta[property^="og:"]','#config-diff'],
15
5
  cacheBust: false,
16
6
  analytics: false,
17
7
  scrollRestoration: false
package/layout/page.pug CHANGED
@@ -31,6 +31,7 @@ block content
31
31
  default
32
32
  include includes/page/default
33
33
  if page.comment
34
+ - var comment_js = true
34
35
  include includes/widgets/third-party/comments/comment
35
36
  if page.aside
36
37
  include includes/widgets/aside/aside
package/layout/post.pug CHANGED
@@ -20,5 +20,6 @@ block content
20
20
  if theme.related_post.enable
21
21
  != related_posts(page, site.posts)
22
22
  if page.comment
23
+ - var comment_js = true
23
24
  include includes/widgets/third-party/comments/comment
24
25
  include includes/widgets/aside/aside
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-solitude",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "A beautiful, powerful, and efficient Hexo theme developed by the efu.",
5
5
  "main": "package.json",
6
6
  "scripts": {
package/plugins.yml CHANGED
@@ -15,14 +15,15 @@ twikoo:
15
15
  file: dist/twikoo.all.min.js
16
16
  version: 1.6.32
17
17
  waline_js:
18
- name: 'waline'
18
+ name: '@waline/client'
19
19
  file: dist/waline.js
20
20
  other_name: waline
21
21
  version: 3.1.3
22
22
  waline_css:
23
- name: 'waline'
23
+ name: '@waline/client'
24
24
  file: dist/waline.css
25
25
  version: 3.1.3
26
+ other_name: waline
26
27
  valine:
27
28
  name: valine
28
29
  file: dist/Valine.min.js
@@ -95,12 +96,12 @@ medium_zoom:
95
96
  fancyapps_ui:
96
97
  name: '@fancyapps/ui'
97
98
  file: dist/fancybox/fancybox.umd.js
98
- version: 5.0.35
99
+ version: 5.0.36
99
100
  other_name: fancyapps-ui
100
101
  fancyapps_css:
101
102
  name: '@fancyapps/ui'
102
103
  file: dist/fancybox/fancybox.css
103
- version: 5.0.35
104
+ version: 5.0.36
104
105
  other_name: fancyapps-ui
105
106
  mermaid_js:
106
107
  name: mermaid
@@ -19,7 +19,7 @@ hexo.extend.filter.register('after_post_render', function (data) {
19
19
  data.excerpt = data.title
20
20
  data.toc = !!(config.aside.toc.page && data.toc !== false && data.aside);
21
21
  }
22
- data.comment = !!(config.comment.enable && data.comment !== false);
22
+ data.comment = !!(config.comment.use && data.comment !== false);
23
23
  return data;
24
24
  });
25
25
 
@@ -26,5 +26,5 @@ if hexo-config('search.enable')
26
26
  @import "_tags/*"
27
27
 
28
28
  // comment
29
- if hexo-config('comment.enable')
29
+ if hexo-config('comment.use')
30
30
  @import '_comments/comment.styl'
@@ -1,15 +1,12 @@
1
- /**
2
- * Comment Barrage
3
- * author: @efu
4
- * website: efu.me
5
- * copyright: MIT
6
- * date: 2024-04-12
7
- * update: 2024-04-12
8
- * @param array
9
- */
10
1
  function initializeCommentBarrage(array) {
11
- if (array === undefined) return;
12
- new class {
2
+ if (array === []) return;
3
+ let existingBarrage = window.currentBarrage;
4
+
5
+ if (existingBarrage) {
6
+ existingBarrage.destroy();
7
+ }
8
+
9
+ let barrage = class {
13
10
  constructor() {
14
11
  this.config = {
15
12
  barrageTimer: [],
@@ -36,7 +33,7 @@ function initializeCommentBarrage(array) {
36
33
  if (!content) return false;
37
34
  const element = document.createElement("div");
38
35
  element.className = "comment-barrage-item";
39
- element.innerHTML = `<div class="barrageHead"><a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a><div class="barrageNick">${comment.nick}</div><img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.mailMd5}"/><a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="solitude st-close-fill"></i></a></div><a class="barrageContent" href="${comment.id ? `javascript:sco.scrollTo(\'${comment.id}\')` : 'javascript:sco.scrollTo(\'post-comment\')' }">${content}</a>`;
36
+ element.innerHTML = `<div class="barrageHead"><a class="barrageTitle" href="javascript:sco.scrollTo('post-comment')">${GLOBAL_CONFIG.lang.barrage.title}</a><div class="barrageNick">${comment.nick}</div><img class="barrageAvatar" src="${GLOBAL_CONFIG.comment.avatar}/avatar/${comment.mailMd5}"/><a class="comment-barrage-close" href="javascript:sco.switchCommentBarrage();"><i class="solitude st-close-fill"></i></a></div><a class="barrageContent" href="${comment.id ? `javascript:sco.scrollTo(\'${comment.id}\')` : 'javascript:sco.scrollTo(\'post-comment\')'}">${content}</a>`;
40
37
  this.config.dom.appendChild(element);
41
38
  this.config.barrageTimer.push(element);
42
39
  return true;
@@ -74,5 +71,14 @@ function initializeCommentBarrage(array) {
74
71
  this.config.dom.addEventListener('mouseover', () => this.hoverOnCommentBarrage = true);
75
72
  this.config.dom.addEventListener('mouseout', () => this.hoverOnCommentBarrage = false);
76
73
  }
77
- }();
74
+
75
+ destroy() {
76
+ clearInterval(this.commentInterval);
77
+ this.config.dom.removeEventListener('mouseover', () => this.hoverOnCommentBarrage = true)
78
+ this.config.dom.removeEventListener('mouseout', () => this.hoverOnCommentBarrage = false)
79
+ this.config.dom.innerHTML = ""
80
+ }
81
+ }
82
+
83
+ window.currentBarrage = new barrage();
78
84
  }
@@ -130,11 +130,11 @@ window.oncontextmenu = (ele) => {
130
130
  if (selectTextNow && window.getSelection()) {
131
131
  display = true;
132
132
  rm.menuItems.copy.style.display = 'block';
133
- rm.menuItems.comment.style.display = 'block';
133
+ GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = 'block');
134
134
  rm.menuItems.search.style.display = 'block';
135
135
  } else {
136
136
  rm.menuItems.copy.style.display = 'none';
137
- rm.menuItems.comment.style.display = 'none';
137
+ GLOBAL_CONFIG.comment && (rm.menuItems.comment.style.display = 'none');
138
138
  rm.menuItems.search.style.display = 'none';
139
139
  }
140
140
 
@@ -220,7 +220,7 @@ window.oncontextmenu = (ele) => {
220
220
  })
221
221
 
222
222
  rm.menuItems.paste.addEventListener('click', () => rm.pasteText() && rm.hideRightMenu())
223
- rm.menuItems.comment.addEventListener('click', () => rm.hideRightMenu() || sco.toTalk(selectTextNow))
223
+ GLOBAL_CONFIG.comment && rm.menuItems.comment.addEventListener('click', () => rm.hideRightMenu() || sco.toTalk(selectTextNow))
224
224
  rm.menuItems.new.addEventListener('click', () => window.open(rm.domhref) && rm.hideRightMenu())
225
225
  rm.menuItems.downloadImg.addEventListener('click', () => rm.downloadImage() && rm.hideRightMenu())
226
226
  rm.menuItems.copyImg.addEventListener('click', () => rm.copyImage() && rm.hideRightMenu())