hexo-theme-solitude 1.1.0 → 1.2.1

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 (304) hide show
  1. package/LICENSE +674 -19
  2. package/README.md +56 -19
  3. package/README_EN.md +98 -0
  4. package/_config.yml +274 -224
  5. package/languages/en-US.yml +1 -0
  6. package/languages/zh-CN.yml +8 -8
  7. package/layout/404.pug +24 -0
  8. package/layout/archive.pug +11 -0
  9. package/layout/category.pug +16 -0
  10. package/layout/includes/console.pug +42 -0
  11. package/layout/includes/footer.pug +71 -0
  12. package/layout/includes/head/config.pug +79 -0
  13. package/layout/includes/head/pwa.pug +59 -0
  14. package/layout/includes/head.pug +29 -0
  15. package/layout/includes/header.pug +4 -0
  16. package/layout/includes/inject/body.pug +68 -0
  17. package/layout/{partial/compoment/inject/head.ejs → includes/inject/head.pug} +60 -37
  18. package/layout/includes/layout.pug +35 -0
  19. package/layout/{partial/loading.ejs → includes/loading.pug} +19 -17
  20. package/layout/includes/mixins/articleSort.pug +14 -0
  21. package/layout/includes/mixins/pagination.pug +8 -0
  22. package/layout/includes/nav.pug +22 -0
  23. package/layout/includes/page/about.pug +10 -0
  24. package/layout/includes/page/categories.pug +8 -0
  25. package/layout/includes/page/default.pug +2 -0
  26. package/layout/includes/page/echarts.pug +7 -0
  27. package/layout/includes/page/equipment.pug +3 -0
  28. package/layout/includes/page/links.pug +35 -0
  29. package/layout/includes/page/moments.pug +5 -0
  30. package/layout/includes/page/rss.pug +22 -0
  31. package/layout/includes/page/says.pug +20 -0
  32. package/layout/includes/page/tags.pug +8 -0
  33. package/layout/includes/page/tlink.pug +9 -0
  34. package/layout/includes/recent-posts.pug +9 -0
  35. package/layout/includes/sidebar.pug +17 -0
  36. package/layout/includes/widgets/aside/aside.pug +18 -0
  37. package/layout/includes/widgets/aside/asideAllInfo.pug +8 -0
  38. package/layout/includes/widgets/aside/asideArchive.pug +9 -0
  39. package/layout/includes/widgets/aside/asideFlipCard.pug +5 -0
  40. package/layout/includes/widgets/aside/asideHistory.pug +8 -0
  41. package/layout/includes/widgets/aside/asideInfoCard.pug +22 -0
  42. package/layout/includes/widgets/aside/asideNewestPost.pug +16 -0
  43. package/layout/includes/widgets/aside/asidePower.pug +19 -0
  44. package/layout/includes/widgets/aside/asideSwitch.pug +26 -0
  45. package/layout/includes/widgets/aside/asideTag.pug +11 -0
  46. package/layout/includes/widgets/aside/asideToc.pug +5 -0
  47. package/layout/includes/widgets/aside/asideWebInfo.pug +40 -0
  48. package/layout/includes/widgets/aside/asideWelcome.pug +12 -0
  49. package/layout/includes/widgets/home/banner.pug +16 -0
  50. package/layout/includes/widgets/home/bbTimeList.pug +8 -0
  51. package/layout/includes/widgets/home/categoryBar.pug +10 -0
  52. package/layout/includes/widgets/home/categoryGroup.pug +9 -0
  53. package/layout/includes/widgets/home/hometop.pug +9 -0
  54. package/layout/includes/widgets/home/postList.pug +26 -0
  55. package/layout/includes/widgets/home/rencentPost.pug +26 -0
  56. package/layout/includes/widgets/home/topGroup.pug +27 -0
  57. package/layout/includes/widgets/nav/left.pug +10 -0
  58. package/layout/includes/widgets/nav/menu.pug +16 -0
  59. package/layout/includes/widgets/nav/right.pug +23 -0
  60. package/layout/includes/widgets/page/about/authorinfo.pug +12 -0
  61. package/layout/includes/widgets/page/about/award.pug +34 -0
  62. package/layout/includes/widgets/page/about/contentinfo.pug +38 -0
  63. package/layout/includes/widgets/page/about/hobbies.pug +33 -0
  64. package/layout/includes/widgets/page/about/motto.pug +19 -0
  65. package/layout/includes/widgets/page/about/other.pug +61 -0
  66. package/layout/includes/widgets/page/about/personalities.pug +16 -0
  67. package/layout/includes/widgets/page/about/skillsinfo.pug +41 -0
  68. package/layout/includes/widgets/page/banner.pug +14 -0
  69. package/layout/includes/widgets/page/equipment/content.pug +23 -0
  70. package/layout/includes/widgets/page/links/banner.pug +30 -0
  71. package/layout/includes/widgets/page/links/linksCard.pug +18 -0
  72. package/layout/includes/widgets/page/links/linksItem.pug +14 -0
  73. package/layout/includes/widgets/page/moments/angle.pug +24 -0
  74. package/layout/includes/widgets/page/moments/index.pug +18 -0
  75. package/layout/includes/widgets/page/says/saysBottom.pug +11 -0
  76. package/layout/includes/widgets/page/says/saysContent.pug +6 -0
  77. package/layout/includes/widgets/page/says/saysFunction.pug +10 -0
  78. package/layout/includes/widgets/page/says/saysMeta.pug +7 -0
  79. package/layout/includes/widgets/post/award.pug +48 -0
  80. package/layout/includes/widgets/post/copyright.pug +27 -0
  81. package/layout/includes/widgets/post/postMeta.pug +55 -0
  82. package/layout/includes/widgets/post/postNav.pug +25 -0
  83. package/layout/includes/widgets/post/wave.pug +9 -0
  84. package/layout/includes/widgets/randomlink.pug +32 -0
  85. package/layout/includes/widgets/rightside/index.pug +74 -0
  86. package/layout/includes/widgets/third-party/comments/comment.pug +14 -0
  87. package/layout/includes/widgets/third-party/comments/gitalk.pug +0 -0
  88. package/layout/{partial/compoment/third-party/comments/twikoo.ejs → includes/widgets/third-party/comments/twikoo.pug} +8 -9
  89. package/layout/includes/widgets/third-party/comments/valine.pug +0 -0
  90. package/layout/includes/widgets/third-party/music.pug +3 -0
  91. package/layout/includes/widgets/third-party/pjax.pug +30 -0
  92. package/layout/includes/widgets/third-party/search/algolia-search.pug +16 -0
  93. package/layout/includes/widgets/third-party/search/index.pug +7 -0
  94. package/layout/includes/widgets/third-party/search/local-search.pug +15 -0
  95. package/layout/index.pug +20 -0
  96. package/layout/page.pug +32 -0
  97. package/layout/post.pug +43 -0
  98. package/layout/tag.pug +19 -0
  99. package/package.json +3 -3
  100. package/scripts/event/page.js +20 -2
  101. package/scripts/filter/checkThemeConfig.js +0 -1
  102. package/scripts/filter/randomPosts.js +0 -1
  103. package/scripts/helper/{charts.js → echarts.js} +21 -11
  104. package/scripts/helper/related_post.js +10 -3
  105. package/scripts/helper/stylus.js +23 -0
  106. package/scripts/tags/bvideo.js +1 -36
  107. package/scripts/tags/fold.js +2 -3
  108. package/scripts/tags/note.js +6 -2
  109. package/scripts/tags/tabs.js +1 -1
  110. package/source/css/_comment/index.styl +121 -0
  111. package/source/css/_comment/twikoo.styl +515 -0
  112. package/source/css/_extra/console.styl +354 -0
  113. package/source/css/_extra/rightmenu.styl +83 -0
  114. package/source/css/_global/animation.css +756 -0
  115. package/source/css/_global/function.styl +83 -0
  116. package/source/css/_global/index.styl +120 -0
  117. package/source/css/_global/var.styl +1 -0
  118. package/source/css/_layout/articleSort.styl +199 -0
  119. package/source/css/_layout/base.styl +392 -0
  120. package/source/css/_layout/footer.styl +359 -0
  121. package/source/css/_layout/header.styl +1331 -0
  122. package/source/css/_layout/index.styl +293 -0
  123. package/source/css/_layout/sidebar.styl +226 -0
  124. package/source/css/_mode/index.styl +52 -0
  125. package/source/css/_page/about.styl +944 -0
  126. package/source/css/_page/category.styl +141 -0
  127. package/source/css/_page/equipment.styl +108 -0
  128. package/source/css/_page/error.styl +161 -0
  129. package/source/css/_page/home.styl +58 -0
  130. package/source/css/_page/homeTop.styl +1035 -0
  131. package/source/css/_page/index.styl +22 -0
  132. package/source/css/_page/link.styl +433 -0
  133. package/source/css/_page/moment.styl +186 -0
  134. package/source/css/_page/rss.styl +87 -0
  135. package/source/css/_page/says.styl +353 -0
  136. package/source/css/_page/tag.styl +56 -0
  137. package/source/css/_post/commentBarrage.styl +149 -0
  138. package/source/css/_post/externalTags.styl +694 -0
  139. package/source/css/_post/highlight.styl +96 -0
  140. package/source/css/_post/index.styl +935 -0
  141. package/source/css/_post/pagination.styl +467 -0
  142. package/source/css/_post/postContent.styl +957 -0
  143. package/source/css/_post/relatedPost.styl +160 -0
  144. package/source/css/_post/reward.styl +217 -0
  145. package/source/css/_search/algolia-search.styl +206 -0
  146. package/source/css/_search/local-search.styl +112 -0
  147. package/source/css/_widgets/aside/allinfo.styl +134 -0
  148. package/source/css/_widgets/aside/flip.styl +68 -0
  149. package/source/css/_widgets/aside/history.styl +35 -0
  150. package/source/css/_widgets/aside/index.styl +156 -0
  151. package/source/css/_widgets/aside/info.styl +263 -0
  152. package/source/css/_widgets/aside/newPost.styl +55 -0
  153. package/source/css/_widgets/aside/power.styl +90 -0
  154. package/source/css/_widgets/aside/toc.styl +85 -0
  155. package/source/css/_widgets/aside/welcome.styl +14 -0
  156. package/source/css/_widgets/index.styl +3 -0
  157. package/source/css/index.styl +40 -0
  158. package/source/img/default.png +0 -0
  159. package/source/img/logo-horizontal_version.png +0 -0
  160. package/source/img/pwa/16.png +0 -0
  161. package/source/img/pwa/180.png +0 -0
  162. package/source/img/pwa/192.png +0 -0
  163. package/source/img/pwa/32.png +0 -0
  164. package/source/img/pwa/512.png +0 -0
  165. package/source/img/pwa/logo.png +0 -0
  166. package/source/img/pwa/siteicon/splash-1125x2436.png +0 -0
  167. package/source/img/pwa/siteicon/splash-1136x640.png +0 -0
  168. package/source/img/pwa/siteicon/splash-1170x2532.png +0 -0
  169. package/source/img/pwa/siteicon/splash-1179x2556.png +0 -0
  170. package/source/img/pwa/siteicon/splash-1242x2208.png +0 -0
  171. package/source/img/pwa/siteicon/splash-1242x2688.png +0 -0
  172. package/source/img/pwa/siteicon/splash-1248x2778.png +0 -0
  173. package/source/img/pwa/siteicon/splash-1290x2796.png +0 -0
  174. package/source/img/pwa/siteicon/splash-1334x750.png +0 -0
  175. package/source/img/pwa/siteicon/splash-1536x2048.png +0 -0
  176. package/source/img/pwa/siteicon/splash-1620x2160.png +0 -0
  177. package/source/img/pwa/siteicon/splash-1668x2224.png +0 -0
  178. package/source/img/pwa/siteicon/splash-1668x2388.png +0 -0
  179. package/source/img/pwa/siteicon/splash-1792x828.png +0 -0
  180. package/source/img/pwa/siteicon/splash-2048x1536.png +0 -0
  181. package/source/img/pwa/siteicon/splash-2048x2732.png +0 -0
  182. package/source/img/pwa/siteicon/splash-2160x1620.png +0 -0
  183. package/source/img/pwa/siteicon/splash-2208x1242.png +0 -0
  184. package/source/img/pwa/siteicon/splash-2224x1668.png +0 -0
  185. package/source/img/pwa/siteicon/splash-2388x1668.png +0 -0
  186. package/source/img/pwa/siteicon/splash-2436x1125.png +0 -0
  187. package/source/img/pwa/siteicon/splash-2532x1170.png +0 -0
  188. package/source/img/pwa/siteicon/splash-2556x1179.png +0 -0
  189. package/source/img/pwa/siteicon/splash-2688x1242.png +0 -0
  190. package/source/img/pwa/siteicon/splash-2732x2048.png +0 -0
  191. package/source/img/pwa/siteicon/splash-2778x1248.png +0 -0
  192. package/source/img/pwa/siteicon/splash-2796x1290.png +0 -0
  193. package/source/img/pwa/siteicon/splash-640x1136.png +0 -0
  194. package/source/img/pwa/siteicon/splash-750x1334.png +0 -0
  195. package/source/img/pwa/siteicon/splash-828x1792.png +0 -0
  196. package/source/img/solitude-show.jpg +0 -0
  197. package/source/js/commentBarrage.js +8 -5
  198. package/source/js/extend/console/comment.js +60 -63
  199. package/source/js/extend/covercolor/local.js +105 -95
  200. package/source/js/extend/search/algolia-search.js +104 -111
  201. package/source/js/extend/search/local-search.js +7 -7
  202. package/source/js/main.js +673 -520
  203. package/source/js/utils.js +131 -137
  204. package/source/lib/chuckle-post-ai.js +1 -1
  205. package/layout/404.ejs +0 -34
  206. package/layout/archive.ejs +0 -10
  207. package/layout/category.ejs +0 -18
  208. package/layout/index.ejs +0 -20
  209. package/layout/layout.ejs +0 -30
  210. package/layout/page/about.ejs +0 -13
  211. package/layout/page/categories.ejs +0 -12
  212. package/layout/page/circle.ejs +0 -5
  213. package/layout/page/echarts.ejs +0 -14
  214. package/layout/page/equipment.ejs +0 -2
  215. package/layout/page/links.ejs +0 -46
  216. package/layout/page/page.ejs +0 -3
  217. package/layout/page/rss.ejs +0 -37
  218. package/layout/page/says.ejs +0 -17
  219. package/layout/page/tags.ejs +0 -12
  220. package/layout/page/tlink.ejs +0 -11
  221. package/layout/page.ejs +0 -45
  222. package/layout/partial/body.ejs +0 -7
  223. package/layout/partial/compoment/about/authorinfo.ejs +0 -18
  224. package/layout/partial/compoment/about/award.ejs +0 -59
  225. package/layout/partial/compoment/about/contentinfo.ejs +0 -33
  226. package/layout/partial/compoment/about/hobbies.ejs +0 -53
  227. package/layout/partial/compoment/about/motto.ejs +0 -17
  228. package/layout/partial/compoment/about/other.ejs +0 -76
  229. package/layout/partial/compoment/about/personalities.ejs +0 -11
  230. package/layout/partial/compoment/about/skillsinfo.ejs +0 -62
  231. package/layout/partial/compoment/aside/aside.ejs +0 -28
  232. package/layout/partial/compoment/aside/asideAllInfo.ejs +0 -6
  233. package/layout/partial/compoment/aside/asideArchive.ejs +0 -11
  234. package/layout/partial/compoment/aside/asideFlipCard.ejs +0 -72
  235. package/layout/partial/compoment/aside/asideHistory.ejs +0 -49
  236. package/layout/partial/compoment/aside/asideInfoCard.ejs +0 -39
  237. package/layout/partial/compoment/aside/asideNewestPost.ejs +0 -31
  238. package/layout/partial/compoment/aside/asidePower.ejs +0 -31
  239. package/layout/partial/compoment/aside/asideSwitch.ejs +0 -41
  240. package/layout/partial/compoment/aside/asideTag.ejs +0 -5
  241. package/layout/partial/compoment/aside/asideToc.ejs +0 -11
  242. package/layout/partial/compoment/aside/asideWebInfo.ejs +0 -60
  243. package/layout/partial/compoment/aside/asideWelcome.ejs +0 -33
  244. package/layout/partial/compoment/circle/angle.ejs +0 -26
  245. package/layout/partial/compoment/circle/banner.ejs +0 -11
  246. package/layout/partial/compoment/circle/content.ejs +0 -19
  247. package/layout/partial/compoment/dorakika/rightmenu.ejs +0 -100
  248. package/layout/partial/compoment/equipment/list.ejs +0 -37
  249. package/layout/partial/compoment/home/homeCategoryBar.ejs +0 -11
  250. package/layout/partial/compoment/home/postList.ejs +0 -37
  251. package/layout/partial/compoment/hometop/bbTimeList.ejs +0 -15
  252. package/layout/partial/compoment/hometop/categoryGroup.ejs +0 -19
  253. package/layout/partial/compoment/hometop/groupTag.ejs +0 -30
  254. package/layout/partial/compoment/hometop/topGroup.ejs +0 -41
  255. package/layout/partial/compoment/inject/body.ejs +0 -72
  256. package/layout/partial/compoment/links/angle.ejs +0 -26
  257. package/layout/partial/compoment/links/banner.ejs +0 -42
  258. package/layout/partial/compoment/links/linksCard.ejs +0 -27
  259. package/layout/partial/compoment/links/linksItem.ejs +0 -21
  260. package/layout/partial/compoment/mixins/articleSort.ejs +0 -26
  261. package/layout/partial/compoment/mixins/pagination.ejs +0 -11
  262. package/layout/partial/compoment/nav/left.ejs +0 -22
  263. package/layout/partial/compoment/nav/menu.ejs +0 -25
  264. package/layout/partial/compoment/nav/right.ejs +0 -42
  265. package/layout/partial/compoment/post/award.ejs +0 -52
  266. package/layout/partial/compoment/post/copyright.ejs +0 -37
  267. package/layout/partial/compoment/post/postMeta.ejs +0 -83
  268. package/layout/partial/compoment/post/postNav.ejs +0 -41
  269. package/layout/partial/compoment/post/wave.ejs +0 -14
  270. package/layout/partial/compoment/says/banner.ejs +0 -10
  271. package/layout/partial/compoment/says/saysBottom.ejs +0 -18
  272. package/layout/partial/compoment/says/saysContent.ejs +0 -10
  273. package/layout/partial/compoment/says/saysFunction.ejs +0 -15
  274. package/layout/partial/compoment/third-party/comments/comment.ejs +0 -12
  275. package/layout/partial/compoment/third-party/comments/twikoo_k.ejs +0 -29
  276. package/layout/partial/compoment/third-party/music.ejs +0 -5
  277. package/layout/partial/compoment/third-party/pjax.ejs +0 -31
  278. package/layout/partial/compoment/third-party/search/algolia-search.ejs +0 -20
  279. package/layout/partial/compoment/third-party/search/index.ejs +0 -10
  280. package/layout/partial/compoment/third-party/search/local-search.ejs +0 -22
  281. package/layout/partial/compoment/tlink/banner.ejs +0 -10
  282. package/layout/partial/console.ejs +0 -68
  283. package/layout/partial/footer.ejs +0 -104
  284. package/layout/partial/head.ejs +0 -37
  285. package/layout/partial/header.ejs +0 -6
  286. package/layout/partial/hometop.ejs +0 -15
  287. package/layout/partial/nav.ejs +0 -34
  288. package/layout/partial/pwa.ejs +0 -40
  289. package/layout/partial/sidebar.ejs +0 -31
  290. package/layout/post.ejs +0 -52
  291. package/layout/tag.ejs +0 -19
  292. package/scripts/filter/katex.js +0 -25
  293. package/scripts/helper/randomLinks.js +0 -16
  294. package/scripts/helper/themeJsExport.js +0 -79
  295. package/scripts/tags/expand.js +0 -4
  296. package/scripts/tags/hide.js +0 -70
  297. package/source/css/commentBarrage.css +0 -174
  298. package/source/css/custom.css +0 -901
  299. package/source/css/main.css +0 -16420
  300. package/source/css/search/algolia-search.css +0 -141
  301. package/source/css/search/local-search.css +0 -138
  302. package/source/css/var.css +0 -189
  303. package/source/js/extend/covercolor/web.js +0 -137
  304. /package/source/js/{rightmenu.js → rightside.js} +0 -0
package/source/js/main.js CHANGED
@@ -1,103 +1,43 @@
1
- function set_fest() {
2
- let date = new Date();
3
- switch ((date.getMonth() + 1).toString() + '.' + date.getDate()) {
4
- case '1.8': // 周总理逝世
5
- case '9.9': // 毛主席逝世
6
- case '7.7': // 七七事变
7
- case '9.18': // 九一八事变
8
- case '12.13': // 南京大屠杀国家公祭日
9
- {
10
- // 创建一个<style>元素
11
- const styleElement = document.createElement('style');
12
- // 定义要添加的CSS样式
13
- const css = `
14
- html {
15
- -webkit-filter: grayscale(100%);
16
- -moz-filter: grayscale(100%);
17
- -ms-filter: grayscale(100%);
18
- -o-filter: grayscale(100%);
19
- filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
20
- _filter: none;
21
- }
22
- `;
23
- // 将CSS样式添加到<style>元素中
24
- styleElement.appendChild(document.createTextNode(css));
25
- // 将<style>元素添加到<head>标签中
26
- document.head.appendChild(styleElement);
27
- }
28
- break;
1
+ const adjustMenu = (change = false) => {
2
+ const $blogName = document.getElementById('site-name')
3
+ let blogNameWidth = $blogName && $blogName.offsetWidth
4
+ const $menusEle = document.querySelector('#menus .menus_items')
5
+ let menusWidth = $menusEle && $menusEle.offsetWidth
6
+ const $searchEle = document.querySelector('#search-button')
7
+ let searchWidth = $searchEle && $searchEle.offsetWidth
8
+ if (change) {
9
+ blogNameWidth = $blogName && $blogName.offsetWidth
10
+ menusWidth = $menusEle && $menusEle.offsetWidth
11
+ searchWidth = $searchEle && $searchEle.offsetWidth
29
12
  }
30
- }
13
+ const $nav = document.getElementById('nav')
14
+ let t
15
+ if (window.innerWidth < 768) t = true
16
+ else t = blogNameWidth + menusWidth + searchWidth > $nav.offsetWidth - 120
31
17
 
32
- function setFixed(el) {
33
- if (!el) return
34
- const currentTop = window.scrollY || document.documentElement.scrollTop
35
- if (currentTop > 0) {
36
- el.classList.add('nav-fixed')
18
+ if (t) {
19
+ $nav.classList.add('hide-menu')
37
20
  } else {
38
- el.classList.remove('nav-fixed')
21
+ $nav.classList.remove('hide-menu')
39
22
  }
40
23
  }
41
24
 
42
- function getTimeState() {
43
- var e = (new Date).getHours()
44
- , t = "";
45
- e >= 0 && e <= 5 ? t = "睡个好觉,保证精力充沛" : e > 5 && e <= 10 ? t = "一日之计在于晨" : e > 10 && e <= 14 ? t = "吃饱了才有力气干活" : e > 14 && e <= 18 ? t = "集中精力,攻克难关" : e > 18 && e <= 24 && (t = "不要太劳累了,早睡更健康")
46
- return t;
47
- }
48
-
49
- const scrollFn = function () {
50
- const innerHeight = window.innerHeight + 0
51
- const $header = document.getElementById('page-header')
52
- setFixed($header)
53
- if (document.body.scrollHeight <= innerHeight) {
54
- return
55
- }
56
- let initTop = 0
57
- window.addEventListener('scroll', utils.throttle(function (e) {
58
- const currentTop = window.scrollY || document.documentElement.scrollTop
59
- const isDown = scrollDirection(currentTop)
60
- if (currentTop > 0) {
61
- if (isDown) {
62
- if ($header.classList.contains('nav-visible')) $header.classList.remove(
63
- 'nav-visible')
64
- } else {
65
- if (!$header.classList.contains('nav-visible')) $header.classList.add(
66
- 'nav-visible')
67
- }
68
- $header.classList.add('nav-fixed')
69
- } else {
70
- if (currentTop === 0) {
71
- $header.classList.remove('nav-fixed', 'nav-visible')
72
- }
73
- }
74
- percent()
75
- }, 200))
76
-
77
- function scrollDirection(currentTop) {
78
- const result = currentTop > initTop
79
- initTop = currentTop
80
- return result
81
- }
25
+ // 初始化header
26
+ const initAdjust = () => {
27
+ adjustMenu()
28
+ document.getElementById('nav').classList.add('show')
82
29
  }
83
30
 
84
31
  /**
85
- * 滾動處理
32
+ * side menu
86
33
  */
87
-
88
34
  const sidebarFn = () => {
89
35
  const $toggleMenu = document.getElementById('toggle-menu')
90
36
  const $mobileSidebarMenus = document.getElementById('sidebar-menus')
91
37
  const $menuMask = document.getElementById('menu-mask')
92
- const $cookies_window = document.getElementById('cookies-window')
93
- const $header = document.getElementById('page-header')
94
38
  const $body = document.body
95
39
 
96
- if (!$toggleMenu) return
97
-
98
- let initTop = 0
99
- const isChatBtnHide = typeof chatBtnHide === 'function'
100
- const isChatBtnShow = typeof chatBtnShow === 'function'
40
+ const isOpen = () => $mobileSidebarMenus.classList.contains('open')
101
41
 
102
42
  function openMobileSidebar() {
103
43
  utils.sidebarPaddingR()
@@ -115,86 +55,108 @@ const sidebarFn = () => {
115
55
 
116
56
  $toggleMenu.addEventListener('click', openMobileSidebar)
117
57
 
118
- $menuMask.addEventListener('click', e => {
119
- if ($mobileSidebarMenus.classList.contains('open')) {
58
+ $menuMask.addEventListener('click', () => {
59
+ if (isOpen()) {
120
60
  closeMobileSidebar()
121
61
  }
122
62
  })
123
63
 
124
- window.addEventListener('resize', e => {
125
- if ($mobileSidebarMenus.classList.contains('open')) closeMobileSidebar()
64
+ window.addEventListener('resize', () => {
65
+ if (utils.isHidden($toggleMenu) && isOpen()) {
66
+ closeMobileSidebar()
67
+ }
126
68
  })
127
- window.addEventListener('scroll', e => {
128
- const currentTop = window.scrollY || document.documentElement.scrollTop
129
- const isDown = scrollDirection(currentTop)
69
+ }
70
+
71
+ /**
72
+ * 滚动处理
73
+ */
74
+ const scrollFn = function () {
75
+ const innerHeight = window.innerHeight;
76
+ const $header = document.getElementById('page-header');
77
+ if (!$header || document.body.scrollHeight <= innerHeight) return;
78
+
79
+ let initTop = 0;
80
+ window.addEventListener('scroll', utils.throttle(function (e) {
81
+ const currentTop = window.scrollY || document.documentElement.scrollTop;
82
+ const isDown = scrollDirection(currentTop);
83
+
130
84
  if (currentTop > 0) {
85
+ $header.classList.add('nav-fixed');
131
86
  if (isDown) {
132
- if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible')
133
- if (isChatBtnShow && isChatShow === true) {
134
- chatBtnHide()
135
- isChatShow = false
136
- }
87
+ if ($header.classList.contains('nav-visible')) $header.classList.remove('nav-visible');
137
88
  } else {
138
- if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible')
139
- if (isChatBtnHide && isChatShow === false) {
140
- chatBtnShow()
141
- isChatShow = true
142
- }
89
+ if (!$header.classList.contains('nav-visible')) $header.classList.add('nav-visible');
143
90
  }
144
- $header.classList.add('nav-fixed')
145
- $cookies_window.classList.add('cw-hide')
146
91
  } else {
147
- if (currentTop === 0) {
148
- $header.classList.remove('nav-fixed', 'nav-visible')
149
- }
92
+ $header.classList.remove('nav-fixed', 'nav-visible');
150
93
  }
151
- }, 200)
94
+ percent();
95
+ }, 200));
152
96
 
153
- // find the scroll direction
154
97
  function scrollDirection(currentTop) {
155
- const result = currentTop > initTop // true is down & false is up
156
- initTop = currentTop
157
- return result
98
+ const result = currentTop > initTop;
99
+ initTop = currentTop;
100
+ return result;
158
101
  }
159
102
  }
160
103
 
161
- const showTodayCard = () => {
162
- const el = document.getElementById('todayCard')
163
- if (el) {
164
- document.getElementsByClassName('topGroup')[0].addEventListener('mouseleave', () => {
165
- if (el.classList.contains('hide')) {
166
- el.classList.remove('hide')
167
- }
104
+ /**
105
+ * 滑动导航栏数字变化
106
+ */
107
+ const percent = () => {
108
+ let scrollTop = document.documentElement.scrollTop || window.pageYOffset
109
+ let totalHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight
110
+ let scrollPercent = Math.round(scrollTop / totalHeight * 100)
111
+ let percentElement = document.querySelector("#percent")
112
+ let viewportBottom = window.scrollY + document.documentElement.clientHeight
113
+ let remainingScroll = totalHeight - scrollTop
114
+
115
+ if ((document.getElementById("post-comment") || document.getElementById("footer")).offsetTop < viewportBottom || scrollPercent > 90) {
116
+ document.querySelector("#nav-totop").classList.add("long")
117
+ percentElement.innerHTML = "返回顶部"
118
+ } else {
119
+ document.querySelector("#nav-totop").classList.remove("long")
120
+ if (scrollPercent >= 0) {
121
+ percentElement.innerHTML = scrollPercent
122
+ }
123
+ }
124
+
125
+ let elementsToHide = document.querySelectorAll(".needEndHide")
126
+ if (remainingScroll < 100) {
127
+ elementsToHide.forEach(function (element) {
128
+ element.classList.add("hide")
129
+ })
130
+ } else {
131
+ elementsToHide.forEach(function (element) {
132
+ element.classList.remove("hide")
168
133
  })
169
134
  }
135
+
136
+ window.onscroll = percent
170
137
  }
171
138
 
172
- const setTimeState = () => {
173
- const el = document.getElementById('author-info__sayhi')
174
- if (el) {
175
- const timeNow = new Date(), hours = timeNow.getHours(), lang = GLOBALCONFIG.lang.sayhello;
176
- let text = '';
177
- if (hours >= 0 && hours <= 5) {
178
- text = lang.goodnight;
179
- } else if (hours > 5 && hours <= 10) {
180
- text = lang.morning;
181
- } else if (hours > 10 && hours <= 14) {
182
- text = lang.noon;
183
- } else if (hours > 14 && hours <= 18) {
184
- text = lang.afternoon;
185
- } else if (hours > 18 && hours <= 24) {
186
- text = lang.night;
187
- }
188
- el.innerText = text + lang.iam;
139
+
140
+ const showTodayCard = () => {
141
+ const el = document.getElementById('todayCard')
142
+ const topGroup = document.getElementsByClassName('topGroup')[0]
143
+
144
+ if (el && topGroup) {
145
+ topGroup.addEventListener('mouseleave', () => {
146
+ el.classList.remove('hide')
147
+ })
189
148
  }
190
- };
149
+ }
191
150
 
192
- const chageTimeFormate = () => {
193
- const timeElements = document.getElementsByTagName("time"), lang = GLOBALCONFIG.lang.time
194
- for (var i = 0; i < timeElements.length; i++) {
151
+ /**
152
+ * 修改时间格式
153
+ */
154
+ const changeTimeFormat = () => {
155
+ const timeElements = document.getElementsByTagName("time"), lang = GLOBAL_CONFIG.lang.time
156
+ for (let i = 0; i < timeElements.length; i++) {
195
157
  const datetime = timeElements[i].getAttribute("datetime"), timeObj = new Date(datetime),
196
158
  daysDiff = utils.timeDiff(timeObj, new Date())
197
- var timeString;
159
+ let timeString;
198
160
  if (daysDiff === 0) {
199
161
  timeString = lang.recent;
200
162
  } else if (daysDiff === 1) {
@@ -218,49 +180,24 @@ const chageTimeFormate = () => {
218
180
  * 文章页右下角下一篇
219
181
  */
220
182
  const initObserver = () => {
221
- let e = document.getElementById("post-comment");
222
- let t = document.getElementById("pagination");
183
+ let commentElement = document.getElementById("post-comment");
184
+ let paginationElement = document.getElementById("pagination");
223
185
 
224
186
  function handleIntersection(entries) {
225
187
  entries.forEach(function (entry) {
226
188
  if (entry.isIntersecting) {
227
- t.classList.add("show-window");
189
+ paginationElement.classList.add("show-window");
228
190
  document.querySelector(".comment-barrage").style.bottom = "-200px";
229
191
  } else {
230
- t.classList.remove("show-window");
192
+ paginationElement.classList.remove("show-window");
231
193
  document.querySelector(".comment-barrage").style.bottom = "0px";
232
194
  }
233
195
  });
234
196
  }
235
197
 
236
- if (e && t) {
198
+ if (commentElement && paginationElement) {
237
199
  let observer = new IntersectionObserver(handleIntersection);
238
- observer.observe(e);
239
- }
240
- }
241
-
242
- const percent = () => {
243
- let a = document.documentElement.scrollTop || window.pageYOffset,
244
- b = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight, // 整个网页高度
245
- result = Math.round(a / b * 100),
246
- btn = document.querySelector("#percent");
247
- const visibleBottom = window.scrollY + document.documentElement.clientHeight;
248
- const eventlistner = document.getElementById('post-tools') || document.getElementById('footer');
249
- const centerY = eventlistner.offsetTop + (eventlistner.offsetHeight / 2);
250
- if ((centerY > visibleBottom) || (result > 90)) {
251
- document.querySelector("#nav-totop").classList.add("long");
252
- btn.innerHTML = GLOBALCONFIG.lang.backtop;
253
- document.querySelectorAll(".needEndHide").forEach(item => {
254
- item.classList.add("hide")
255
- })
256
- } else {
257
- document.querySelector("#nav-totop").classList.remove("long");
258
- if (result >= 0) {
259
- btn.innerHTML = result;
260
- document.querySelectorAll(".needEndHide").forEach(item => {
261
- item.classList.remove("hide")
262
- })
263
- }
200
+ observer.observe(commentElement);
264
201
  }
265
202
  }
266
203
 
@@ -286,8 +223,7 @@ class toc {
286
223
  const $tocContent = document.getElementById('toc-content')
287
224
  const list = $article.querySelectorAll('h1,h2,h3,h4,h5,h6')
288
225
  let detectItem = ''
289
-
290
- function autoScroll(el) {
226
+ const autoScroll = (el) => {
291
227
  const activePosition = el.getBoundingClientRect().top
292
228
  const sidebarScrollTop = $tocContent.scrollTop
293
229
  if (activePosition > (document.documentElement.clientHeight - 100)) {
@@ -297,20 +233,16 @@ class toc {
297
233
  $tocContent.scrollTop = sidebarScrollTop - 150
298
234
  }
299
235
  }
300
-
301
- function findHeadPosition(top) {
236
+ const findHeadPosition = (top) => {
302
237
  if (top === 0) {
303
238
  return false
304
239
  }
305
-
306
240
  let currentIndex = ''
307
-
308
- list.forEach(function (ele, index) {
241
+ list.forEach((ele, index) => {
309
242
  if (top > utils.getEleTop(ele) - 80) {
310
243
  currentIndex = index
311
244
  }
312
245
  })
313
-
314
246
  if (detectItem === currentIndex) return
315
247
  detectItem = currentIndex
316
248
  document.querySelectorAll('.toc .active').forEach((i) => {
@@ -318,42 +250,36 @@ class toc {
318
250
  })
319
251
  const activeitem = toc[detectItem]
320
252
  if (activeitem) {
321
- let parent = toc[detectItem].parentNode
322
253
  activeitem.classList.add('active')
323
254
  autoScroll(activeitem)
324
- for (; !parent.matches('.toc'); parent = parent.parentNode) {
255
+ let parent = activeitem.parentNode
256
+ while (!parent.matches('.toc')) {
325
257
  if (parent.matches('li')) parent.classList.add('active')
258
+ parent = parent.parentNode
326
259
  }
327
260
  }
328
261
  }
329
-
330
- window.tocScrollFn = utils.throttle(function () {
262
+ window.tocScrollFn = utils.throttle(() => {
331
263
  const currentTop = window.scrollY || document.documentElement.scrollTop
332
264
  findHeadPosition(currentTop)
333
265
  }, 100)
334
-
335
266
  window.addEventListener('scroll', tocScrollFn)
336
267
  }
337
268
  }
338
269
 
339
270
  let lastSayHello = "";
271
+ let wleelw_musicPlaying = false
340
272
 
341
- class sco {
273
+ let sco = {
342
274
  /**
343
275
  * 个性定位
344
276
  */
345
- static card_welcome() {
346
- /**
347
- * 请求数据
348
- */
277
+ card_welcome: function () {
349
278
  ipLoacation = window.saveToLocal.get('ipLocation');
350
- if (ipLoacation) {
351
- // 使用 ipLocation
352
-
353
- } else {
279
+ if (!ipLoacation) {
354
280
  // 数据已过期或不存在
355
- var script = document.createElement('script');
356
- var url = `https://apis.map.qq.com/ws/location/v1/ip?key=${txkey}&output=jsonp`;
281
+ let script = document.createElement('script');
282
+ let url = `https://apis.map.qq.com/ws/location/v1/ip?key=${txkey}&output=jsonp`;
357
283
  script.src = url;
358
284
  window.QQmap = function (data) {
359
285
  ipLoacation = data;
@@ -365,95 +291,75 @@ class sco {
365
291
  document.body.appendChild(script);
366
292
  }
367
293
  showWelcome();
368
- }
369
-
294
+ },
370
295
  /**
371
296
  * 那年今日
372
- * @type {*}
373
297
  */
374
- static card_history() {
298
+ card_history: function () {
375
299
  if (document.getElementById('history-container')) {
300
+ async function fetchHistoryData() {
301
+ let myDate = new Date();
302
+ let myMonth = myDate.getMonth() + 1;
303
+ let getDate = myDate.getDate();
304
+ let getMonth = myMonth < 10 ? "0" + myMonth : "" + myMonth;
305
+ let getDay = getDate < 10 ? "0" + getDate : "" + getDate;
306
+ let getMonthDate = "S" + getMonth + getDay;
307
+ let history_data_url = `https://cdn.meuicat.com/gh/Zfour/Butterfly-card-history@2.08/${getMonth}.json`;
308
+
309
+ let response = await fetch(history_data_url);
310
+ let data = await response.json();
311
+ return data[getMonthDate];
312
+ }
313
+
376
314
  function append(parent, text) {
377
- if (typeof text === 'string') {
378
- let temp = document.createElement('div');
379
- temp.innerHTML = text;
380
- // 防止元素太多 进行提速
381
- let frag = document.createDocumentFragment();
382
- while (temp.firstChild) {
383
- frag.appendChild(temp.firstChild);
384
- }
385
- parent.appendChild(frag);
386
- } else {
387
- parent.appendChild(text);
315
+ let temp = document.createElement('div');
316
+ temp.innerHTML = text;
317
+ let frag = document.createDocumentFragment();
318
+ while (temp.firstChild) {
319
+ frag.appendChild(temp.firstChild);
388
320
  }
321
+ parent.appendChild(frag);
389
322
  }
390
323
 
391
- let history_data = sco.history_get_data()
392
- fetch(history_data[0])
393
- .then(data => data.json())
394
- .then(data => {
395
- let html_item = ''
396
- for (let item of data[history_data[1]]) {
397
- html_item += '<div class="swiper-slide history_slide"><span class="history_slide_time">A.D.' +
398
- item.year + '</span>' + '<span class="history_slide_link">' + item.title + '</span></div>'
399
-
400
- }
401
- var history_container_wrapper = document.getElementById('history_container_wrapper')
402
- append(history_container_wrapper, html_item);
403
- var swiper_history = new Swiper('.history_swiper-container', {
404
- passiveListeners: true,
405
- spaceBetween: 30,
406
- effect: 'coverflow',
407
- coverflowEffect: {
408
- rotate: 30,
409
- slideShadows: false,
410
- },
411
- loop: true,
412
- direction: 'vertical',
413
- autoplay: {
414
- disableOnInteraction: true,
415
- delay: 5000
416
- },
417
-
418
- mousewheel: false,
419
- // autoHeight: true,
420
-
421
- });
422
-
423
- let history_comtainer = document.getElementById('history-container');
424
- history_comtainer.onmouseenter = function () {
425
- swiper_history.autoplay.stop();
426
- };
427
- history_comtainer.onmouseleave = function () {
428
- swiper_history.autoplay.start();
429
- }
430
- })
431
- }
432
- }
433
-
434
- static history_get_data() {
435
- let myDate = new Date();
436
- let myMonth = myDate.getMonth() + 1;
437
- let getMonth;
438
- if (myMonth < 10) {
439
- getMonth = "0" + String(myMonth);
440
- } else {
441
- getMonth = String(myMonth);
442
- }
443
- let getDate = String(myDate.getDate());
444
- if (getDate < 10) {
445
- getDate = "0" + String(getDate);
446
- } else {
447
- getDate = String(getDate);
324
+ fetchHistoryData().then(data => {
325
+ let html_item = data.map(item => `
326
+ <div class="swiper-slide history_slide">
327
+ <span class="history_slide_time">A.D.${item.year}</span>
328
+ <span class="history_slide_link">${item.title}</span>
329
+ </div>
330
+ `).join('');
331
+ let history_container_wrapper = document.getElementById('history_container_wrapper');
332
+ append(history_container_wrapper, html_item);
333
+ let swiper_history = new Swiper('.history_swiper-container', {
334
+ passiveListeners: true,
335
+ spaceBetween: 30,
336
+ effect: 'coverflow',
337
+ coverflowEffect: {
338
+ rotate: 30,
339
+ slideShadows: false,
340
+ },
341
+ loop: true,
342
+ direction: 'vertical',
343
+ autoplay: {
344
+ disableOnInteraction: true,
345
+ delay: 5000
346
+ },
347
+ mousewheel: false,
348
+ });
349
+ let history_container = document.getElementById('history-container');
350
+ history_container.onmouseenter = function () {
351
+ swiper_history.autoplay.stop();
352
+ };
353
+ history_container.onmouseleave = function () {
354
+ swiper_history.autoplay.start();
355
+ }
356
+ });
448
357
  }
449
- let getMonthDate = "S" + getMonth + getDate;
450
- return ["https://cdn.meuicat.com/gh/Zfour/Butterfly-card-history@2.08/" + getMonth + ".json", getMonthDate]
451
- }
452
-
453
- /*
454
- * 隐藏协议提醒助手
358
+ },
359
+ /**
360
+ * 隐藏协议小助手
455
361
  */
456
- static hideCookie() {
362
+ hideCookie: function () {
457
363
  setTimeout(() => {
458
364
  const cookiesWindow = document.getElementById("cookies-window");
459
365
  if (cookiesWindow) {
@@ -463,29 +369,33 @@ class sco {
463
369
  }, 1000);
464
370
  }
465
371
  }, 3000);
466
- }
467
-
468
- static scrollTo(e) {
469
- const t = document.getElementById(e);
470
- if (t) {
471
- const e = t.getBoundingClientRect().top + window.pageYOffset - 80
472
- , o = window.pageYOffset
473
- , n = e - o;
474
- let a = null;
475
- window.requestAnimationFrame((function e(t) {
476
- a || (a = t);
477
- const l = t - a
478
- , i = (c = Math.min(l / 0, 1)) < .5 ? 2 * c * c : (4 - 2 * c) * c - 1;
479
- var c;
480
- window.scrollTo(0, o + n * i),
481
- l < 600 && window.requestAnimationFrame(e)
482
- }
483
- ))
372
+ },
373
+ /**
374
+ * 平滑滚动处理
375
+ * @param elementId
376
+ */
377
+ scrollTo: function (elementId) {
378
+ const targetElement = document.getElementById(elementId);
379
+ if (targetElement) {
380
+ const targetPosition = targetElement.getBoundingClientRect().top + window.pageYOffset - 80;
381
+ const startPosition = window.pageYOffset;
382
+ const distanceToScroll = targetPosition - startPosition;
383
+ let animationStartTime = null;
384
+ window.requestAnimationFrame((function smoothScroll(currentTime) {
385
+ animationStartTime = animationStartTime || currentTime;
386
+ const elapsedTime = currentTime - animationStartTime;
387
+ const progressRatio = Math.min(elapsedTime / 0, 1);
388
+ const easing = progressRatio < .5 ? 2 * progressRatio * progressRatio : (4 - 2 * progressRatio) * progressRatio - 1;
389
+ window.scrollTo(0, startPosition + distanceToScroll * easing);
390
+ elapsedTime < 600 && window.requestAnimationFrame(smoothScroll);
391
+ }));
484
392
  }
485
- }
486
-
487
- static switchCommentBarrage() {
488
- var commentBarrageElement = document.querySelector(".comment-barrage");
393
+ },
394
+ /**
395
+ * 控制台热评隐藏显示切换
396
+ */
397
+ switchCommentBarrage: function () {
398
+ let commentBarrageElement = document.querySelector(".comment-barrage");
489
399
  if (commentBarrageElement) {
490
400
  if (window.getComputedStyle(commentBarrageElement).display === "flex") {
491
401
  commentBarrageElement.style.display = "none";
@@ -499,121 +409,144 @@ class sco {
499
409
  localStorage.setItem("commentBarrageSwitch", "false");
500
410
  }
501
411
  }
502
- }
503
-
504
- static switchHideAside() {
505
- const e = document.documentElement.classList;
506
- e.contains("hide-aside") ? saveToLocal.set("aside-status", "show", 2) : saveToLocal.set("aside-status", "hide", 2),
507
- e.toggle("hide-aside"),
508
- e.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on")
509
- }
510
-
511
- static initConsoleState() {
412
+ },
413
+ /**
414
+ * 控制台侧边栏隐藏显示切换
415
+ */
416
+ switchHideAside: function () {
417
+ const htmlClassList = document.documentElement.classList;
418
+ htmlClassList.contains("hide-aside") ? saveToLocal.set("aside-status", "show", 1) : saveToLocal.set("aside-status", "hide", 1)
419
+ htmlClassList.toggle("hide-aside");
420
+ htmlClassList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on");
421
+ },
422
+ initConsoleState: function () {
512
423
  document.documentElement.classList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on")
513
- }
514
-
515
- static sayhi() {
516
- document.querySelector("#author-info__sayhi") && (document.getElementById("author-info__sayhi").innerHTML = getTimeState())
517
- }
518
-
519
- static changeSayHelloText() {
520
- const e = ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"]
521
- , t = document.getElementById("author-info__sayhi");
522
- let o = e[Math.floor(Math.random() * e.length)];
523
- for (; o === lastSayHello;)
524
- o = e[Math.floor(Math.random() * e.length)];
525
- t.textContent = o,
526
- lastSayHello = o
527
- }
528
-
529
- static switchDarkMode() {
530
- const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' :
424
+ },
425
+ /**
426
+ * 个人信息顶部
427
+ */
428
+ changeSayHelloText: function () {
429
+ const greetings = ["🤖️ 数码科技爱好者", "🔍 分享与热心帮助", "🏠 智能家居小能手", "🔨 设计开发一条龙", "🤝 专修交互与设计", "🏃 脚踏实地行动派", "🧱 团队小组发动机", "💢 壮汉人狠话不多"];
430
+ const greetingElement = document.getElementById("author-info__sayhi");
431
+ let randomGreeting = greetings[Math.floor(Math.random() * greetings.length)];
432
+ while (randomGreeting === lastSayHello) {
433
+ randomGreeting = greetings[Math.floor(Math.random() * greetings.length)];
434
+ }
435
+ greetingElement.textContent = randomGreeting;
436
+ lastSayHello = randomGreeting;
437
+ },
438
+ /**
439
+ * 昼夜切换
440
+ */
441
+ switchDarkMode: function () {
442
+ let nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' :
531
443
  'light'
532
444
  if (nowMode === 'light') {
533
445
  document.documentElement.setAttribute('data-theme', 'dark')
534
- saveToLocal.set('theme', 'dark', 0.5);
535
- utils.snackbarShow(GLOBALCONFIG.lang.theme.dark, false, 2000)
446
+ saveToLocal.set('theme', 'dark', 0.04);
447
+ utils.snackbarShow(GLOBAL_CONFIG.lang.theme.dark, false, 2000)
536
448
  document.querySelector(".menu-darkmode-text").textContent = "深色模式";
537
449
  } else {
538
450
  document.documentElement.setAttribute('data-theme', 'light')
539
- saveToLocal.set('theme', 'light', 0.5);
540
- utils.snackbarShow(GLOBALCONFIG.lang.theme.light, false, 2000)
451
+ saveToLocal.set('theme', 'light', 0.04);
452
+ utils.snackbarShow(GLOBAL_CONFIG.lang.theme.light, false, 2000)
541
453
  document.querySelector(".menu-darkmode-text").textContent = "浅色模式";
542
454
  }
543
- }
544
-
545
- static hideTodayCard() {
455
+ },
456
+ hideTodayCard: function () {
546
457
  document.getElementById('todayCard').classList.add('hide')
547
- }
548
-
549
- static toTop() {
458
+ },
459
+ /**
460
+ * 返回顶部
461
+ */
462
+ toTop: function () {
550
463
  utils.scrollToDest(0)
551
- }
552
-
553
- static showConsole() {
554
- const el = document.getElementById('console')
464
+ },
465
+ /**
466
+ * 显示控制台
467
+ */
468
+ showConsole: function () {
469
+ let el = document.getElementById('console')
555
470
  if (!el.classList.contains('show')) {
556
471
  el.classList.add('show')
557
472
  }
558
- }
559
-
560
- static hideConsole() {
473
+ },
474
+ /**
475
+ * 隐藏控制台
476
+ */
477
+ hideConsole: function () {
561
478
  const el = document.getElementById('console')
562
479
  if (el.classList.contains('show')) {
563
480
  el.classList.remove('show')
564
481
  }
565
- }
566
-
567
- static copyPageUrl() {
568
- utils.copy(window.location.href)
569
- }
570
-
571
- static lightbox(el) {
482
+ },
483
+ /**
484
+ * 灯箱使用
485
+ */
486
+ lightbox: function () {
572
487
  window.ViewImage && window.ViewImage.init("#article-container img:not(.flink-avatar), .bber-content-img img, #album_detail img, #equipment img, #twikoo .tk-content img:not(.tk-owo-emotion)");
573
- }
574
-
575
- static initTheme() {
576
- const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
577
- const cachedMode = saveToLocal.get('theme');
578
-
579
- if (cachedMode === undefined) {
580
- const nowMode =
581
- isDarkMode ? 'dark' : 'light'
582
- document.documentElement.setAttribute('data-theme', nowMode);
583
- saveToLocal.set('theme', nowMode, 2);
584
- } else {
585
- document.documentElement.setAttribute('data-theme', cachedMode);
488
+ },
489
+ /**
490
+ * 初始化
491
+ */
492
+ initTheme: function () {
493
+ let isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
494
+ try {
495
+ const cachedMode = saveToLocal.get('theme');
496
+ if (cachedMode === undefined) {
497
+ const nowMode =
498
+ isDarkMode ? 'dark' : 'light'
499
+ document.documentElement.setAttribute('data-theme', nowMode);
500
+ saveToLocal.set('theme', nowMode, 0.5);
501
+ } else {
502
+ document.documentElement.setAttribute('data-theme', cachedMode);
503
+ }
504
+ } catch (e) {
505
+ if (isDarkMode) {
506
+ saveToLocal.set('theme', 'dark', 0.5)
507
+ } else {
508
+ saveToLocal.set('theme', 'light', 0.5)
509
+ }
586
510
  }
587
- }
588
-
589
- static reflashEssayWaterFall() {
511
+ },
512
+ /**
513
+ *
514
+ */
515
+ reflashEssayWaterFall: function () {
590
516
  if (document.getElementById('waterfall')) {
591
517
  setTimeout(function () {
592
518
  waterfall('#waterfall');
593
519
  document.getElementById("waterfall").classList.add('show');
594
520
  }, 500);
595
521
  }
596
- }
597
-
598
- static addRuntime() {
599
- const el = document.getElementById('runtimeshow')
600
- if (el && GLOBALCONFIG.runtime) {
601
- el.innerText = utils.timeDiff(new Date(GLOBALCONFIG.runtime), new Date()) + GLOBALCONFIG.lang.time.runtime
522
+ },
523
+ /**
524
+ * 更新站点运行时间
525
+ */
526
+ addRuntime: function () {
527
+ let el = document.getElementById('runtimeshow')
528
+ if (el && GLOBAL_CONFIG.runtime) {
529
+ el.innerText = utils.timeDiff(new Date(GLOBAL_CONFIG.runtime), new Date()) + GLOBAL_CONFIG.lang.time.runtime
602
530
  }
603
- }
604
-
605
- static lazyloadImg() {
531
+ },
532
+ /**
533
+ * 懒加载图片
534
+ */
535
+ lazyloadImg: function () {
606
536
  window.lazyLoadInstance = new LazyLoad({
607
537
  elements_selector: 'img',
608
538
  threshold: 0,
609
539
  data_src: 'lazy-src',
610
540
  callback_error: (img) => {
611
- img.setAttribute("src", GLOBALCONFIG.lazyload.error);
541
+ img.setAttribute("src", GLOBAL_CONFIG.lazyload.error);
612
542
  }
613
543
  })
614
- }
615
-
616
- static toTalk(txt) {
544
+ },
545
+ /**
546
+ * 跳转到输评论
547
+ * @param txt
548
+ */
549
+ toTalk: function (txt) {
617
550
  const input = document.querySelector('.el-textarea__inner');
618
551
  const evt = new Event('input', {bubbles: true, cancelable: true});
619
552
  const inputValue = txt.replace(/\n/g, '\n> ');
@@ -626,11 +559,13 @@ class sco {
626
559
  if (commentTips) {
627
560
  commentTips.classList.add("show");
628
561
  }
629
- }
630
-
631
- static initbbtalk() {
562
+ },
563
+ /**
564
+ * 初始化即刻mini
565
+ */
566
+ initbbtalk: function () {
632
567
  if (document.querySelector('#bber-talk')) {
633
- var swiper = new Swiper('.swiper-container', {
568
+ let swiper = new Swiper('.swiper-container', {
634
569
  direction: 'vertical',
635
570
  loop: true,
636
571
  autoplay: {
@@ -639,10 +574,12 @@ class sco {
639
574
  },
640
575
  });
641
576
  }
642
- }
643
-
644
- static addPhotoFigcaption() {
645
- const images = document.querySelectorAll('#article-container img');
577
+ },
578
+ /**
579
+ * 图片添加水印
580
+ */
581
+ addPhotoFigcaption: function () {
582
+ let images = document.querySelectorAll('#article-container img');
646
583
  images.forEach((image) => {
647
584
  const imageParent = image.parentNode;
648
585
  const captionText = image.getAttribute('alt');
@@ -655,145 +592,360 @@ class sco {
655
592
  imageParent.insertBefore(captionElement, image.nextSibling);
656
593
  }
657
594
  });
658
- }
659
-
660
- /*
661
- * 图片加水印
595
+ },
596
+ /**
597
+ * 下载图片并添加水印
662
598
  */
663
- static downloadImage(e, t) {
599
+ downloadImage: async function (url, filename) {
664
600
  rm.hideRightMenu();
665
- if (0 == rm.downloadimging) {
666
- rm.downloadimging = !0;
667
- utils.snackbarShow("正在下载中,请稍后", !1, 1e4);
668
- setTimeout((function () {
669
- let o = new Image;
670
- o.setAttribute("crossOrigin", "anonymous");
671
- o.onload = function () {
672
- let e = document.createElement("canvas");
673
- e.width = o.width;
674
- e.height = o.height;
675
- e.getContext("2d").drawImage(o, 0, 0, o.width, o.height);
676
- let n = e.toDataURL("image/png");
677
- let a = document.createElement("a");
678
- let l = new MouseEvent("click");
679
- a.download = t || "photo";
680
- a.href = n;
681
- a.dispatchEvent(l);
682
- };
683
- o.src = e;
684
- utils.snackbarShow("图片已添加盲水印,请遵守版权协议");
685
- rm.downloadimging = !1;
686
- }), "10000");
687
- } else {
601
+ if (rm.downloadimging) {
688
602
  utils.snackbarShow("有正在进行中的下载,请稍后再试");
603
+ return;
689
604
  }
690
- }
691
-
692
-
693
- static musicToggle() {
694
- const $music = document.querySelector('#nav-music'),
695
- $meting = document.querySelector('meting-js'),
696
- $console = document.getElementById('consoleMusic')
605
+ try {
606
+ rm.downloadimging = true;
607
+ utils.snackbarShow("正在下载中,请稍后", false, 10000);
608
+ await new Promise(resolve => setTimeout(resolve, 10000));
609
+ const img = new Image();
610
+ img.setAttribute("crossOrigin", "anonymous");
611
+ img.onload = function () {
612
+ const canvas = document.createElement("canvas");
613
+ const ctx = canvas.getContext("2d");
614
+ canvas.width = img.width;
615
+ canvas.height = img.height;
616
+ ctx.drawImage(img, 0, 0, img.width, img.height);
617
+ ctx.font = "30px Arial";
618
+ ctx.fillText(window.location.href, 10, img.height - 10);
619
+ const dataUrl = canvas.toDataURL("image/png");
620
+ const link = document.createElement("a");
621
+ const event = new MouseEvent("click");
622
+ link.download = filename || "photo";
623
+ link.href = dataUrl;
624
+ link.dispatchEvent(event);
625
+ utils.snackbarShow("图片已添加盲水印,请遵守版权协议");
626
+ rm.downloadimging = false;
627
+ };
628
+ img.src = url;
629
+ } catch (error) {
630
+ console.error(error);
631
+ utils.snackbarShow("下载图片时出错");
632
+ rm.downloadimging = false;
633
+ }
634
+ },
635
+ /**
636
+ * 音乐播放暂停
637
+ */
638
+ musicToggle: function () {
639
+ const $music = document.querySelector('#nav-music');
640
+ const $meting = document.querySelector('meting-js');
641
+ const $console = document.getElementById('consoleMusic');
642
+ const $toggleButton = document.getElementById('menu-music-toggle');
643
+ wleelw_musicPlaying = !wleelw_musicPlaying;
644
+ $music.classList.toggle("playing", wleelw_musicPlaying);
645
+ $console.classList.toggle("on", wleelw_musicPlaying);
697
646
  if (wleelw_musicPlaying) {
698
- $music.classList.remove("playing")
699
- $console.classList.remove("on")
700
- wleelw_musicPlaying = false;
701
- $meting.aplayer.pause();
702
- document.getElementById('menu-music-toggle').innerHTML = `<i class="scoicon sco-play-fill"></i><span>播放音乐</span>`
703
- } else {
704
- $music.classList.add("playing")
705
- $console.classList.add("on")
706
- wleelw_musicPlaying = true;
707
647
  $meting.aplayer.play();
708
- document.getElementById('menu-music-toggle').innerHTML = `<i class="scoicon sco-pause-fill"></i><span>暂停音乐</span>`
648
+ $toggleButton.innerHTML = `<i class="scoicon sco-pause-fill"></i><span>暂停音乐</span>`;
649
+ } else {
650
+ $meting.aplayer.pause();
651
+ $toggleButton.innerHTML = `<i class="scoicon sco-play-fill"></i><span>播放音乐</span>`;
709
652
  }
710
- rm.hideRightMenu()
711
- }
712
-
713
- static musicSkipBack() {
653
+ rm.hideRightMenu();
654
+ },
655
+ /**
656
+ * 音乐上一首
657
+ */
658
+ musicSkipBack: function () {
714
659
  document.querySelector('meting-js').aplayer.skipBack()
715
660
  rm.hideRightMenu()
716
- }
717
-
718
- static musicSkipForward() {
661
+ },
662
+ /**
663
+ * 音乐下一首
664
+ */
665
+ musicSkipForward: function () {
719
666
  document.querySelector('meting-js').aplayer.skipForward()
720
667
  rm.hideRightMenu()
721
- }
668
+ },
669
+ /**
670
+ * 获取歌曲名称
671
+ */
672
+ musicGetName: function () {
673
+ const titles = Array.from(document.querySelectorAll('.aplayer-title')).map(e => e.innerText);
674
+ return titles[0];
675
+ },
676
+ /**
677
+ * 跳转到评论
678
+ */
679
+ scrollToComment: function () {
680
+ utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300)
681
+ },
682
+ /**
683
+ * 一些日子灰色页面
684
+ */
685
+ setFest: function () {
686
+ const date = new Date();
687
+ const currentDate = `${date.getMonth() + 1}.${date.getDate()}`;
688
+
689
+ const specialDates = ['1.8', '9.9', '7.7', '9.18', '12.13'];
722
690
 
723
- static musicGetName() {
724
- var e = document.querySelectorAll('.aplayer-title');
725
- var t = [];
726
- for (var o = e.length - 1; o >= 0; o--) {
727
- t[o] = e[o].innerText;
691
+ if (specialDates.includes(currentDate)) {
692
+ const css = `
693
+ html {
694
+ filter: grayscale(100%);
728
695
  }
729
- return t[0];
730
- }
696
+ `;
731
697
 
732
- static scrollToComment() {
733
- utils.scrollToDest(utils.getEleTop(document.getElementById('post-comment')), 300)
698
+ const styleElement = document.createElement('style');
699
+ styleElement.textContent = css;
700
+ document.head.appendChild(styleElement);
701
+ }
702
+ },
703
+ /**
704
+ * 个人信息顶部文字更新
705
+ */
706
+ setTimeState: function () {
707
+ const el = document.getElementById('author-info__sayhi');
708
+ if (el) {
709
+ const timeNow = new Date();
710
+ const hours = timeNow.getHours();
711
+ const lang = GLOBAL_CONFIG.lang.sayhello;
712
+ const greetings = [
713
+ {start: 0, end: 5, text: lang.goodnight},
714
+ {start: 6, end: 10, text: lang.morning},
715
+ {start: 11, end: 14, text: lang.noon},
716
+ {start: 15, end: 18, text: lang.afternoon},
717
+ {start: 19, end: 24, text: lang.night},
718
+ ];
719
+ for (let greeting of greetings) {
720
+ if (hours >= greeting.start && hours <= greeting.end) {
721
+ el.innerText = greeting.text;
722
+ break;
723
+ }
724
+ }
725
+ }
726
+ },
727
+ /**
728
+ * tagPageActive
729
+ */
730
+ tagPageActive: function () {
731
+ const currentPath = window.location.pathname;
732
+ const decodedPath = decodeURIComponent(currentPath);
733
+
734
+ const isTagPage = /\/tags\/.*?\//.test(decodedPath);
735
+ if (isTagPage) {
736
+ const tag = decodedPath.split("/").slice(-2, -1)[0];
737
+
738
+ const tagPageTagsElement = document.getElementById("#tag-page-tags");
739
+ if (tagPageTagsElement) {
740
+ const allLinks = document.querySelectorAll("a");
741
+ allLinks.forEach(link => {
742
+ link.classList.remove("select");
743
+ });
744
+
745
+ const tagElement = document.getElementById(tag);
746
+ if (tagElement) {
747
+ tagElement.classList.add("select");
748
+ }
749
+ }
750
+ }
751
+ },
752
+ /**
753
+ * categoryBarActive
754
+ */
755
+ categoriesBarActive: function () {
756
+ const categoryBar = document.querySelector("#category-bar");
757
+ const currentPath = window.location.pathname;
758
+ const decodedPath = decodeURIComponent(currentPath);
759
+
760
+ if (categoryBar) {
761
+ const categoryBarItems = document.querySelectorAll(".category-bar-item");
762
+ categoryBarItems.forEach(item => {
763
+ item.classList.remove("select");
764
+ });
765
+ }
766
+ if (decodedPath === "/") {
767
+ if (categoryBar) {
768
+ const homeItem = document.getElementById("category-bar-home");
769
+ homeItem.classList.add("select");
770
+ }
771
+ } else {
772
+ if (/\/categories\/.*?\//.test(decodedPath)) {
773
+ let category = decodedPath.split("/").slice(-2, -1)[0];
774
+ category = category.charAt(0).toUpperCase() + category.slice(1);
775
+ if (categoryBar) {
776
+ const categoryItem = document.getElementById(category);
777
+ if (categoryItem) {
778
+ categoryItem.classList.add("select");
779
+ }
780
+ }
781
+ }
782
+ }
783
+ },
784
+ /**
785
+ * categoryBarRightButton
786
+ */
787
+ scrollCategoryBarToRight: function () {
788
+ let timeoutId;
789
+ let scrollBar = document.getElementById("category-bar-items");
790
+ let nextElement = document.getElementById("category-bar-next");
791
+ let scrollBarWidth = scrollBar.clientWidth;
792
+ if (scrollBar) {
793
+ if (scrollBar.scrollLeft + scrollBar.clientWidth >= scrollBar.scrollWidth - 8) {
794
+ scrollBar.scroll({
795
+ left: 0,
796
+ behavior: "smooth"
797
+ });
798
+ } else {
799
+ scrollBar.scrollBy({
800
+ left: scrollBarWidth,
801
+ behavior: "smooth"
802
+ });
803
+ }
804
+ scrollBar.addEventListener("scroll", function onScroll() {
805
+ clearTimeout(timeoutId);
806
+ timeoutId = setTimeout(function () {
807
+ if (scrollBar.scrollLeft + scrollBar.clientWidth >= scrollBar.scrollWidth - 8) {
808
+ nextElement.style.transform = "rotate(180deg)";
809
+ } else {
810
+ nextElement.style.transform = "";
811
+ }
812
+ scrollBar.removeEventListener("scroll", onScroll);
813
+ }, 150);
814
+ });
815
+ }
816
+ },
817
+ /**
818
+ * 打开侧边栏标签隐藏
819
+ */
820
+ openAllTags: function () {
821
+ let tagCloudElements = document.querySelectorAll(".card-allinfo .card-tag-cloud");
822
+ tagCloudElements.forEach(function (tagCloudElement) {
823
+ tagCloudElement.classList.add("all-tags");
824
+ });
825
+ let moreTagsButton = document.getElementById("more-tags-btn");
826
+ if (moreTagsButton) {
827
+ moreTagsButton.parentNode.removeChild(moreTagsButton);
828
+ }
829
+ },
830
+ /**
831
+ * 监听底部分页输入框
832
+ */
833
+ listenToPageInputPress: function () {
834
+ const pageText = document.getElementById("toPageText");
835
+ const pageButton = document.getElementById("toPageButton");
836
+
837
+ if (!pageText) return;
838
+
839
+ const pageNumbers = document.querySelectorAll(".page-number");
840
+ const lastPageNumber = +pageNumbers[pageNumbers.length - 1].textContent;
841
+
842
+ if (lastPageNumber === 1) {
843
+ const toPageGroup = document.querySelector(".toPageGroup");
844
+ if (toPageGroup) toPageGroup.remove();
845
+ }
846
+
847
+ pageText.addEventListener("keydown", (event) => {
848
+ if (event.keyCode === 13) {
849
+ heo.toPage();
850
+ pjax.loadUrl(pageButton.href);
851
+ }
852
+ });
853
+
854
+ pageText.addEventListener("input", () => {
855
+ if (pageText.value === "" || pageText.value === "0") {
856
+ pageButton.classList.remove("haveValue");
857
+ } else {
858
+ pageButton.classList.add("haveValue");
859
+ }
860
+
861
+ const pageNumbers = document.querySelectorAll(".page-number");
862
+ const lastPageNumber = +pageNumbers[pageNumbers.length - 1].textContent;
863
+
864
+ if (+pageText.value > lastPageNumber) {
865
+ pageText.value = lastPageNumber;
866
+ }
867
+ });
868
+ },
869
+ /**
870
+ * 初始化Nav背景
871
+ */
872
+ addNavBackgroundInit: function () {
873
+ var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
874
+ if (scrollTop !== 0) {
875
+ var pageHeader = document.getElementById("page-header");
876
+ if (pageHeader) {
877
+ pageHeader.classList.add("nav-fixed", "nav-visible");
878
+ }
879
+ var cookiesWindow = document.getElementById("cookies-window");
880
+ if (cookiesWindow) {
881
+ cookiesWindow.style.display = 'none';
882
+ }
883
+ }
734
884
  }
735
885
  }
736
886
 
887
+ /*
888
+ * 代码高亮显示
889
+ */
737
890
  class hightlight {
738
891
  static createEle(langEl, item) {
739
- const fragment = document.createDocumentFragment()
740
- const highlightCopyEle = '<i class="scoicon sco-copy-fill"></i>'
741
- const highlightExpandEle = '<i class="scoicon sco-arrow-down expand" style="font-size: 16px"></i>'
742
-
743
- const hlTools = document.createElement('div')
744
- hlTools.className = `highlight-tools`
745
- hlTools.innerHTML = highlightExpandEle + langEl + highlightCopyEle
746
- let expand = true
747
- hlTools.children[0].addEventListener('click', (e) => {
748
- if (expand) {
749
- hlTools.children[0].classList.add('closed')
750
- $table.setAttribute('style', 'display:none')
751
- if ($expand.length !== 0) {
752
- $expand[0].setAttribute('style', 'display:none')
753
- }
754
- } else {
755
- hlTools.children[0].classList.remove('closed')
756
- $table.setAttribute('style', 'display:block')
757
- if ($expand.length !== 0) {
758
- $expand[0].setAttribute('style', 'display:block')
759
- }
760
- if (itemHeight < 200) {
761
- $table.setAttribute('style', 'height:' + itemHeight + "px")
762
- } else {
763
- $table.setAttribute('style', 'height:200px')
764
- ele.classList.remove("expand-done")
892
+ const fragment = document.createDocumentFragment();
893
+ const highlightCopyEle = '<i class="scoicon sco-copy-fill"></i>';
894
+ const highlightExpandEle = '<i class="scoicon sco-arrow-down expand" style="font-size: 16px"></i>';
895
+
896
+ const hlTools = document.createElement('div');
897
+ hlTools.className = 'highlight-tools';
898
+ hlTools.innerHTML = `${highlightExpandEle}${langEl}${highlightCopyEle}`;
899
+
900
+ const itemHeight = item.clientHeight;
901
+ const $table = item.querySelector('table');
902
+ const $expand = item.getElementsByClassName('code-expand-btn');
903
+
904
+ let expand = true;
905
+ hlTools.children[0].addEventListener('click', () => {
906
+ expand = !expand;
907
+ hlTools.children[0].classList.toggle('closed');
908
+ $table.style.display = expand ? 'none' : 'block';
909
+ if ($expand.length !== 0) {
910
+ $expand[0].style.display = expand ? 'none' : 'block';
911
+ }
912
+ if (!expand) {
913
+ $table.style.height = itemHeight < 200 ? 'auto' : '200px';
914
+ if (itemHeight >= 200) {
915
+ item.classList.remove("expand-done");
765
916
  }
766
917
  }
767
- expand = !expand
768
- })
769
- hlTools.children[2].addEventListener('click', (e) => {
770
- utils.copy($table.querySelector('.code').innerText)
771
- })
772
- const ele = document.createElement('div')
773
- fragment.appendChild(hlTools)
774
- const itemHeight = item.clientHeight, $table = item.querySelector('table'),
775
- $expand = item.getElementsByClassName('code-expand-btn')
776
- if (GLOBALCONFIG.hightlight.limit && itemHeight > GLOBALCONFIG.hightlight.limit + 30) {
777
- $table.setAttribute('style', `height: ${GLOBALCONFIG.hightlight.limit}px`)
778
- ele.className = 'code-expand-btn'
779
- ele.innerHTML = '<i class="scoicon sco-show-line" style="font-size: 1.2rem"></i>'
918
+ });
919
+
920
+ hlTools.children[2].addEventListener('click', () => {
921
+ utils.copy($table.querySelector('.code').innerText);
922
+ });
923
+
924
+ fragment.appendChild(hlTools);
925
+
926
+ if (GLOBAL_CONFIG.hightlight.limit && itemHeight > GLOBAL_CONFIG.hightlight.limit + 30) {
927
+ $table.style.height = `${GLOBAL_CONFIG.hightlight.limit}px`;
928
+ const ele = document.createElement('div');
929
+ ele.className = 'code-expand-btn';
930
+ ele.innerHTML = '<i class="scoicon sco-show-line" style="font-size: 1.2rem"></i>';
780
931
  ele.addEventListener('click', (e) => {
781
- $table.setAttribute('style', `height: ${itemHeight}px`)
782
- e.target.className !== 'code-expand-btn' ? e.target.parentNode.classList.add('expand-done') : e.target.classList.add('expand-done')
783
- })
784
- fragment.appendChild(ele)
932
+ $table.style.height = `${itemHeight}px`;
933
+ const target = e.target.className !== 'code-expand-btn' ? e.target.parentNode : e.target;
934
+ target.classList.add('expand-done');
935
+ });
936
+ fragment.appendChild(ele);
785
937
  }
786
- item.insertBefore(fragment, item.firstChild)
938
+ item.insertBefore(fragment, item.firstChild);
787
939
  }
788
940
 
789
941
  static init() {
790
- const $figureHighlight = document.querySelectorAll('figure.highlight'), that = this
791
- $figureHighlight.forEach(function (item) {
792
- let langName = item.getAttribute('class').split(' ')[1]
793
- if (langName === 'plaintext' || langName === undefined) langName = 'Code'
794
- const highlightLangEle = `<div class="code-lang">${langName.toUpperCase()}</div>`
795
- that.createEle(highlightLangEle, item)
796
- })
942
+ const $figureHighlight = document.querySelectorAll('figure.highlight');
943
+ $figureHighlight.forEach(item => {
944
+ let langName = item.classList[1] || 'Code';
945
+ if (langName === 'plaintext') langName = 'Code';
946
+ const highlightLangEle = `<div class="code-lang">${langName.toUpperCase()}</div>`;
947
+ this.createEle(highlightLangEle, item);
948
+ });
797
949
  }
798
950
  }
799
951
 
@@ -833,47 +985,48 @@ class tabs {
833
985
  }
834
986
  }
835
987
 
836
-
837
988
  window.refreshFn = () => {
989
+ if (PAGE_CONFIG.page === "404") return;
990
+ initAdjust()
838
991
  scrollFn()
839
992
  sidebarFn()
840
- setTimeState()
841
- GLOBALCONFIG.comment.enable && newestCommentInit()
842
- chageTimeFormate()
993
+ changeTimeFormat()
843
994
  initObserver()
844
995
  sco.addRuntime()
845
996
  sco.hideCookie()
846
997
  sco.addPhotoFigcaption()
847
- sco.sayhi()
848
- addRightMenuClickEvent()
849
- GLOBALCONFIG.lazyload.enable && sco.lazyloadImg()
850
- GLOBALCONFIG.lightbox && sco.lightbox('')
851
- GLOBALCONFIG.randomlinks && randomLinksList()
852
- PAGECONFIG.toc && toc.init()
853
- if (PAGECONFIG.is_post || PAGECONFIG.is_page) {
854
- GLOBALCONFIG.hightlight.enable && hightlight.init()
998
+ sco.setFest()
999
+ sco.setTimeState()
1000
+ sco.tagPageActive()
1001
+ sco.categoriesBarActive()
1002
+ sco.listenToPageInputPress()
1003
+ sco.addNavBackgroundInit()
1004
+ GLOBAL_CONFIG.rightside.enable && addRightMenuClickEvent()
1005
+ GLOBAL_CONFIG.lazyload.enable && sco.lazyloadImg()
1006
+ GLOBAL_CONFIG.lightbox && sco.lightbox('')
1007
+ GLOBAL_CONFIG.randomlinks && randomLinksList()
1008
+ GLOBAL_CONFIG.comment.enable && newestCommentInit()
1009
+ if (PAGE_CONFIG.comment) {
1010
+ initComment()
1011
+ }
1012
+ PAGE_CONFIG.toc && toc.init()
1013
+ if (PAGE_CONFIG.is_post || PAGE_CONFIG.is_page) {
1014
+ GLOBAL_CONFIG.hightlight.enable && hightlight.init()
855
1015
  tabs.init()
856
1016
  }
857
- PAGECONFIG.comment && initComment()
858
- if (PAGECONFIG.is_home) {
1017
+ if (PAGE_CONFIG.is_home) {
859
1018
  showTodayCard()
860
1019
  sco.initbbtalk()
861
1020
  }
862
- if (PAGECONFIG.is_page && PAGECONFIG.page === 'says') sco.reflashEssayWaterFall()
863
- if (PAGECONFIG.is_page) {
864
- if (document.getElementById('album_detail')) sco.reflashEssayWaterFall()
865
- }
866
- GLOBALCONFIG.covercolor && coverColor();
867
- set_fest()
1021
+ GLOBAL_CONFIG.covercolor && coverColor();
868
1022
  sco.initConsoleState()
869
1023
  if (document.getElementById('history-baidu')) sco.card_history() // 那年今日
870
1024
  if (document.getElementById('welcome-info')) sco.card_welcome() // 个性定位
871
- if (GLOBALCONFIG.comment.enable) initializeCommentBarrage() // 热评
1025
+ if (GLOBAL_CONFIG.comment.type === "twikoo" && PAGE_CONFIG.comment) initializeCommentBarrage() // 热评
872
1026
  }
873
1027
 
874
1028
  sco.initTheme()
875
1029
 
876
- let wleelw_musicPlaying = false
877
1030
  document.addEventListener('DOMContentLoaded', function () {
878
1031
  window.refreshFn()
879
1032
  })