sinzmise-cetastories 2.0.0-1731114112124 → 2.0.0-1731114615672

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. package/404/index.html +1 -4033
  2. package/about/index.html +1 -4041
  3. package/album/index.html +1 -4050
  4. package/archives/2021/12/index.html +1 -3917
  5. package/archives/2021/index.html +1 -3917
  6. package/archives/2022/12/index.html +1 -3917
  7. package/archives/2022/index.html +1 -3917
  8. package/archives/2023/01/index.html +1 -4072
  9. package/archives/2023/02/index.html +1 -3917
  10. package/archives/2023/03/index.html +1 -4063
  11. package/archives/2023/04/index.html +1 -3992
  12. package/archives/2023/07/index.html +1 -4217
  13. package/archives/2023/08/index.html +1 -4067
  14. package/archives/2023/09/index.html +1 -3917
  15. package/archives/2023/10/index.html +1 -3917
  16. package/archives/2023/11/index.html +1 -3917
  17. package/archives/2023/12/index.html +1 -3918
  18. package/archives/2023/index.html +1 -4591
  19. package/archives/2023/page/2/index.html +1 -4572
  20. package/archives/2023/page/3/index.html +1 -3930
  21. package/archives/2024/01/index.html +1 -4142
  22. package/archives/2024/02/index.html +1 -3922
  23. package/archives/2024/03/index.html +1 -3916
  24. package/archives/2024/04/index.html +1 -3997
  25. package/archives/2024/05/index.html +1 -4065
  26. package/archives/2024/06/index.html +1 -3917
  27. package/archives/2024/07/index.html +1 -3917
  28. package/archives/2024/08/index.html +1 -3992
  29. package/archives/2024/09/index.html +1 -3917
  30. package/archives/2024/10/index.html +1 -3984
  31. package/archives/2024/index.html +1 -4576
  32. package/archives/2024/page/2/index.html +1 -4433
  33. package/archives/index.html +1 -4560
  34. package/archives/page/2/index.html +1 -4560
  35. package/archives/page/3/index.html +1 -4560
  36. package/archives/page/4/index.html +1 -4560
  37. package/archives/page/5/index.html +1 -4560
  38. package/assets/algolia/algoliasearch.js +3 -7182
  39. package/assets/algolia/algoliasearchLite.js +3 -4445
  40. package/atom.xml +31 -31
  41. package/bbs/bbs.html +1 -4012
  42. package/bbs/bbs.js +2 -12
  43. package/bbs/index.html +1 -4031
  44. package/categories/index.html +1 -4050
  45. package/categories//344/270/252/344/272/272/345/260/217/350/256/260/index.html +1 -4570
  46. package/categories//344/270/252/344/272/272/345/260/217/350/256/260/page/2/index.html +1 -4485
  47. package/categories//346/255/214/346/233/262/346/224/266/351/233/206/index.html +1 -3920
  48. package/categories//346/270/270/346/210/217/347/233/270/345/205/263/index.html +1 -4148
  49. package/categories//347/253/231/347/202/271/346/212/230/350/205/276/index.html +1 -4610
  50. package/categories//347/253/231/347/202/271/346/212/230/350/205/276/page/2/index.html +1 -4148
  51. package/categories//351/241/271/347/233/256/346/212/230/350/205/276/index.html +1 -4072
  52. package/charts/index.html +1 -4039
  53. package/comments/index.html +1 -4052
  54. package/css/custom2.css +2 -3
  55. package/css/first.css +2 -1868
  56. package/css/pace/big-counter.css +2 -39
  57. package/css/pace/corner-indicator.css +2 -72
  58. package/css/pace/flash.css +2 -76
  59. package/css/pace/mac-osx.css +2 -86
  60. package/css/pace/pace.css +2 -50
  61. package/css/plane.css +2 -59
  62. package/css/style.css +2 -8585
  63. package/css/tags.css +2 -3516
  64. package/essay/index.html +1 -4050
  65. package/fcircle/index.html +1 -4075
  66. package/games +2 -2
  67. package/index.html +1 -4717
  68. package/js/app.js +2 -1341
  69. package/js/autoload.js +2 -62
  70. package/js/ceta/fancybox.css +2 -2
  71. package/js/ceta/fancybox.umd.js +2 -2
  72. package/js/ceta/iconfontInkss.js +2 -1
  73. package/js/ceta/message.css +2 -6
  74. package/js/ceta/message.js +2 -6
  75. package/js/clock.js +2 -1
  76. package/js/kslink.js +2 -38
  77. package/js/newyear.js +2 -76
  78. package/js/plane.js +2 -2200
  79. package/js/plugins/aplayer.js +2 -186
  80. package/js/plugins/parallax.js +2 -191
  81. package/js/plugins/rightMenus.js +2 -623
  82. package/js/plugins/tags/contributors.js +2 -92
  83. package/js/plugins/tags/friends.js +2 -93
  84. package/js/plugins/tags/sites.js +2 -96
  85. package/js/search/algolia.js +2 -239
  86. package/js/search/hexo.js +2 -195
  87. package/js/search/meilisearch.js +2 -220
  88. package/js/txmap.js +2 -248
  89. package/link/index.html +1 -6180
  90. package/load.html +1 -294
  91. package/maps/assets/algolia/algoliasearch.js.map +1 -0
  92. package/maps/assets/algolia/algoliasearchLite.js.map +1 -0
  93. package/maps/bbs/bbs.js.map +1 -0
  94. package/maps/css/custom2.css.map +1 -0
  95. package/maps/css/first.css.map +1 -0
  96. package/maps/css/pace/big-counter.css.map +1 -0
  97. package/maps/css/pace/corner-indicator.css.map +1 -0
  98. package/maps/css/pace/flash.css.map +1 -0
  99. package/maps/css/pace/mac-osx.css.map +1 -0
  100. package/maps/css/pace/pace.css.map +1 -0
  101. package/maps/css/plane.css.map +1 -0
  102. package/maps/css/style.css.map +1 -0
  103. package/maps/css/tags.css.map +1 -0
  104. package/maps/js/app.js.map +1 -0
  105. package/maps/js/autoload.js.map +1 -0
  106. package/maps/js/ceta/fancybox.css.map +1 -0
  107. package/maps/js/ceta/fancybox.umd.js.map +1 -0
  108. package/maps/js/ceta/iconfontInkss.js.map +1 -0
  109. package/maps/js/ceta/message.css.map +1 -0
  110. package/maps/js/ceta/message.js.map +1 -0
  111. package/maps/js/clock.js.map +1 -0
  112. package/maps/js/kslink.js.map +1 -0
  113. package/maps/js/newyear.js.map +1 -0
  114. package/maps/js/plane.js.map +1 -0
  115. package/maps/js/plugins/aplayer.js.map +1 -0
  116. package/maps/js/plugins/parallax.js.map +1 -0
  117. package/maps/js/plugins/rightMenus.js.map +1 -0
  118. package/maps/js/plugins/tags/contributors.js.map +1 -0
  119. package/maps/js/plugins/tags/friends.js.map +1 -0
  120. package/maps/js/plugins/tags/sites.js.map +1 -0
  121. package/maps/js/search/algolia.js.map +1 -0
  122. package/maps/js/search/hexo.js.map +1 -0
  123. package/maps/js/search/meilisearch.js.map +1 -0
  124. package/maps/js/txmap.js.map +1 -0
  125. package/maps/sw.js.map +1 -0
  126. package/maps/weichuncai/css/style.css.map +1 -0
  127. package/maps/weichuncai/js/common.js.map +1 -0
  128. package/maps/weichuncai/js/jquery.js.map +1 -0
  129. package/maps/weichuncai/wcc-config.js.map +1 -0
  130. package/music/index.html +1 -4033
  131. package/package.json +1 -1
  132. package/page/2/index.html +1 -4578
  133. package/page/3/index.html +1 -4575
  134. package/page/4/index.html +1 -4572
  135. package/page/5/index.html +1 -3924
  136. package/posts/10021/index.html +5 -4130
  137. package/posts/10045/index.html +1 -4224
  138. package/posts/10733/index.html +1 -4125
  139. package/posts/10996/index.html +5 -4127
  140. package/posts/12779/index.html +1 -4134
  141. package/posts/13624/index.html +1 -4179
  142. package/posts/15688/index.html +1 -4133
  143. package/posts/15748/index.html +5 -4121
  144. package/posts/15799/index.html +1 -4130
  145. package/posts/15842/index.html +5 -4121
  146. package/posts/16107/index.html +1 -4111
  147. package/posts/18063/index.html +1 -4124
  148. package/posts/20412/index.html +1 -4134
  149. package/posts/21375/index.html +1 -4124
  150. package/posts/22945/index.html +4 -4169
  151. package/posts/23021/index.html +1 -4104
  152. package/posts/27531/index.html +5 -4121
  153. package/posts/28536/index.html +1 -4116
  154. package/posts/28733/index.html +1 -4168
  155. package/posts/29196/index.html +1 -4106
  156. package/posts/38917/index.html +1 -4144
  157. package/posts/38964/index.html +1 -4208
  158. package/posts/42487/index.html +1 -4135
  159. package/posts/42580/index.html +1 -4128
  160. package/posts/45875/index.html +1 -4118
  161. package/posts/46640/index.html +1 -4147
  162. package/posts/48762/index.html +1 -4109
  163. package/posts/50710/index.html +1 -4114
  164. package/posts/52677/index.html +1 -4125
  165. package/posts/53662/index.html +1 -4123
  166. package/posts/54386/index.html +1 -4116
  167. package/posts/54481/index.html +1 -4133
  168. package/posts/54787/index.html +5 -4124
  169. package/posts/56467/index.html +1 -4121
  170. package/posts/57692/index.html +1 -4143
  171. package/posts/58203/index.html +1 -4116
  172. package/posts/61417/index.html +1 -4117
  173. package/posts/61712/index.html +1 -4113
  174. package/posts/646/index.html +1 -4106
  175. package/posts/64856/index.html +1 -4120
  176. package/posts/64935/index.html +1 -4120
  177. package/search.xml +95 -95
  178. package/seas/index.html +1 -4050
  179. package/sw.js +2 -798
  180. package/tags/Flash/347/233/270/345/205/263/index.html +1 -3924
  181. package/tags/Steam/346/270/270/346/210/217/index.html +1 -3924
  182. package/tags/Windows/350/275/257/344/273/266/index.html +1 -3997
  183. package/tags/index.html +1 -4033
  184. package/tags//344/270/252/344/272/272/345/260/217/350/256/260/index.html +1 -4570
  185. package/tags//344/270/252/344/272/272/345/260/217/350/256/260/page/2/index.html +1 -4485
  186. package/tags//345/205/266/345/256/203/346/270/270/346/210/217/index.html +1 -4073
  187. package/tags//345/212/240/350/275/275/345/212/250/347/224/273/index.html +1 -3924
  188. package/tags//346/202/254/346/265/256/345/256/240/347/211/251-/347/234/213/346/235/277/345/250/230/index.html +1 -3925
  189. package/tags//346/255/214/346/233/262/346/224/266/351/233/206/index.html +1 -3920
  190. package/tags//346/270/270/346/210/217/347/233/270/345/205/263/index.html +1 -4148
  191. package/tags//347/253/231/347/202/271/345/272/225/351/203/250/351/255/224/346/224/271/index.html +1 -3924
  192. package/tags//347/253/231/347/202/271/346/212/230/350/205/276/index.html +1 -4610
  193. package/tags//347/253/231/347/202/271/346/212/230/350/205/276/page/2/index.html +1 -4148
  194. package/tags//350/207/252/345/273/272/351/203/250/347/275/262/index.html +1 -4224
  195. package/tags//351/241/265/351/235/242/351/255/224/346/224/271/index.html +1 -4075
  196. package/tags//351/241/271/347/233/256/346/212/230/350/205/276/index.html +1 -4072
  197. package/update/index.html +1 -4112
  198. package/weichuncai/css/style.css +2 -25
  199. package/weichuncai/js/common.js +2 -449
  200. package/weichuncai/js/jquery.js +2 -139
  201. package/weichuncai/wcc-config.js +2 -17
package/js/app.js CHANGED
@@ -1,1341 +1,2 @@
1
- document.addEventListener("DOMContentLoaded", function () {
2
- volantis.requestAnimationFrame(() => {
3
- VolantisApp.init();
4
- VolantisApp.subscribe();
5
- VolantisFancyBox.init();
6
- VolantisFancyBox.bind('#post-body img:not([fancybox])');
7
- highlightKeyWords.startFromURL();
8
- locationHash();
9
- //changeTitle();
10
-
11
- volantis.pjax.push(() => {
12
- VolantisApp.pjaxReload();
13
- VolantisFancyBox.init();
14
- VolantisFancyBox.bind('#post-body img:not([fancybox])');
15
- sessionStorage.setItem("domTitle", document.title);
16
- highlightKeyWords.startFromURL();
17
- }, 'app.js');
18
- volantis.pjax.send(() => {
19
- volantis.dom.switcher?.removeClass('active'); // 关闭移动端激活的搜索框
20
- volantis.dom.header?.removeClass('z_search-open'); // 关闭移动端激活的搜索框
21
- volantis.dom.wrapper?.removeClass('sub'); // 跳转页面时关闭二级导航
22
- volantis.EventListener?.remove() // 移除事件监听器 see: layout/_partial/scripts/global.ejs
23
- }, 'app.js');
24
- });
25
- });
26
-
27
- // 动态修改标题
28
- const changeTitle = () => {
29
- sessionStorage.setItem("domTitle", document.title);
30
- document.addEventListener('visibilitychange', function () {
31
- const title = sessionStorage.getItem("domTitle") || document.title;
32
- const titleArr = title.split(' - ') || [];
33
- if (document.visibilityState == 'hidden') {
34
- document.title = titleArr.length === 2 ? titleArr[1] : titleArr[0];
35
- } else {
36
- document.title = title;
37
- }
38
- });
39
- }
40
-
41
- /*锚点定位*/
42
- const locationHash = () => {
43
- if (window.location.hash) {
44
- let locationID = decodeURI(window.location.hash.split('#')[1]).replace(/\ /g, '-');
45
- let target = document.getElementById(locationID);
46
- if (target) {
47
- setTimeout(() => {
48
- if (window.location.hash.startsWith('#fn')) { // hexo-reference https://github.com/volantis-x/hexo-theme-volantis/issues/647
49
- volantis.scroll.to(target, { addTop: - volantis.dom.header.offsetHeight - 5, behavior: 'instant', observer: true })
50
- } else {
51
- // 锚点中上半部有大片空白 高度大概是 volantis.dom.header.offsetHeight
52
- volantis.scroll.to(target, { addTop: 5, behavior: 'instant', observer: true })
53
- }
54
- }, 1000)
55
- }
56
- }
57
- }
58
- Object.freeze(locationHash);
59
-
60
- /* Main */
61
- const VolantisApp = (() => {
62
- const fn = {},
63
- COPYHTML = '<button class="btn-copy" data-clipboard-snippet=""><i class="fa-solid fa-copy"></i><span>COPY</span></button>';
64
- let scrollCorrection = 80;
65
-
66
- fn.init = () => {
67
- if (volantis.dom.header) {
68
- scrollCorrection = volantis.dom.header.clientHeight + 16;
69
- }
70
-
71
- window.onresize = () => {
72
- if (document.documentElement.clientWidth < 500) {
73
- volantis.isMobile = 1;
74
- } else {
75
- volantis.isMobile = 0;
76
- }
77
- if (volantis.isMobile != volantis.isMobileOld) {
78
- fn.setGlobalHeaderMenuEvent();
79
- fn.setHeader();
80
- fn.setHeaderSearch();
81
- }
82
- }
83
- volantis.scroll.push(fn.scrollEventCallBack, "scrollEventCallBack")
84
- }
85
-
86
- fn.event = () => {
87
- volantis.dom.$(document.getElementById("scroll-down"))?.on('click', function () {
88
- fn.scrolltoElement(volantis.dom.bodyAnchor);
89
- });
90
-
91
- // 如果 sidebar 为空,隐藏 sidebar。
92
- const sidebar = document.querySelector("#l_side")
93
- if (sidebar) {
94
- const sectionList = sidebar.querySelectorAll("section")
95
- if (!sectionList.length) {
96
- document.querySelector("#l_main").classList.add("no_sidebar")
97
- }
98
- }
99
-
100
- // 站点信息 最后活动日期
101
- if (volantis.GLOBAL_CONFIG.sidebar.for_page.includes('webinfo') || volantis.GLOBAL_CONFIG.sidebar.for_post.includes('webinfo')) {
102
- const lastupd = volantis.GLOBAL_CONFIG.sidebar.webinfo.lastupd;
103
- if (!!document.getElementById('last-update-show') && lastupd.enable && lastupd.friendlyShow) {
104
- document.getElementById('last-update-show').innerHTML = fn.utilTimeAgo(volantis.GLOBAL_CONFIG.lastupdate);
105
- }
106
- }
107
-
108
- // 站点信息 运行时间
109
- if (!!document.getElementById('webinfo-runtime-count')) {
110
- let BirthDay = new Date(volantis.GLOBAL_CONFIG.sidebar.webinfo.runtime.data);
111
- let timeold = (new Date().getTime() - BirthDay.getTime());
112
- let daysold = Math.floor(timeold / (24 * 60 * 60 * 1000));
113
- let count = document.querySelector('#webinfo-runtime-count');
114
- count.innerHTML = `${(daysold/365).toFixed(2)} ${volantis.GLOBAL_CONFIG.sidebar.webinfo.runtime.unit}`;
115
- count.title = `${count.title} 👾 ${daysold} 天`;
116
- }
117
-
118
- // 消息提示 复制时弹出
119
- document.body.oncopy = function () {
120
- fn.messageCopyright()
121
- };
122
-
123
- // artalk 侧边栏
124
- fn.genArtalkContent('#widget-artalk-hotarticle', 'pv_most_pages', 10, 30); // 热门文章
125
- fn.genArtalkContent('#widget-artalk-randpages', 'rand_pages', 10, 1); // 随机文章
126
- fn.genArtalkContent('#widget-artalk-hotcomment', 'latest_comments', 10, 10); // 最新评论
127
-
128
- // NextSite 侧边栏绑定事件
129
- document.querySelector('.nextsite div.site-nav-toggle')?.addEventListener('click', () => {
130
- let menu = document.querySelector('.nextsite nav.site-nav');
131
- if (menu) {
132
- menu.style.display = menu.style.display === 'none' || menu.style.display === '' ? 'block' : 'none';
133
- }
134
- })
135
- }
136
-
137
- /**
138
- * 填充侧边栏
139
- * @param {*} selector Dom 选择器
140
- * @param {*} type Api
141
- * @param {*} limit 请求数限制
142
- * @param {*} time 时间(单位分 min)
143
- */
144
- fn.genArtalkContent = async (selector, type, limit, time) => {
145
- const genArtalkTime = localStorage.getItem(`GenArtalkTime-${type}`) || 0;
146
- const element = document.querySelector(selector);
147
- if (!!element) {
148
- const content = element.querySelector('.tab-pane-content');
149
- try {
150
- let json;
151
- if (genArtalkTime > Date.now()) {
152
- json = JSON.parse(localStorage.getItem(type))
153
- } else {
154
- json = await VolantisRequest.POST('https://artalk.szyink.com/api/stat', {
155
- site_name: '枋柚梓的猫会发光',
156
- type: type,
157
- limit: limit
158
- })
159
- localStorage.setItem(type, JSON.stringify(json))
160
- localStorage.setItem(`GenArtalkTime-${type}`, Date.now() + time * 60000)
161
- }
162
- let html = '';
163
- json.forEach((item, index) => {
164
- switch (type) {
165
- case 'pv_most_pages':
166
- case 'rand_pages':
167
- const title = item?.title.replaceAll(' - 枋柚梓的猫会发光', '');
168
- html = `${html}<li><span>${index + 1}</span><a title='${title}' href='${item?.key}'>${title}</a></li>`;
169
- break;
170
- case 'latest_comments':
171
- if (item?.is_collapsed === true) break;
172
- let avatar = '';
173
- if (item?.link === "") {
174
- avatar = `<div class="avatar"><img src="https://cravatar.cn/avatar/${item?.email_encrypted}?d=mp&amp;s=80"></div>`
175
- } else {
176
- avatar = `<div class="avatar"><a target="_blank" rel="noreferrer noopener nofollow" href="${item?.link}"><img src="https://cravatar.cn/avatar/${item?.email_encrypted}?d=mp&amp;s=80"></a></div>`
177
- }
178
- let content = item?.content_marked.replace(/<img\b.*?(?:\>|\/>)/g, '[图片]');
179
- html = `${html}<li>${avatar}<div class="main"><a href="${item?.page_key}#atk-comment-${item?.id}"><p>${item?.nick}</p>${content}</a></div></li>`;
180
- break;
181
- }
182
- })
183
- content.innerHTML = `<ul>${html}</ul>`;
184
- if (typeof pjax !== 'undefined') pjax.refresh(content)
185
- } catch (error) {
186
- console.error(error)
187
- content.innerHTML = `加载失败 /(ㄒoㄒ)/~~`
188
- }
189
- }
190
- }
191
-
192
- fn.restData = () => {
193
- scrollCorrection = volantis.dom.header ? volantis.dom.header.clientHeight : 80;
194
- }
195
-
196
- fn.setIsMobile = () => {
197
- if (document.documentElement.clientWidth < 500) {
198
- volantis.isMobile = 1;
199
- volantis.isMobileOld = 1;
200
- } else {
201
- volantis.isMobile = 0;
202
- volantis.isMobileOld = 0;
203
- }
204
- }
205
-
206
- // 校正页面定位(被导航栏挡住的区域)
207
- fn.scrolltoElement = (elem, correction = scrollCorrection) => {
208
- volantis.scroll.to(elem, {
209
- top: elem.getBoundingClientRect().top + document.documentElement.scrollTop - correction
210
- })
211
- }
212
-
213
- // 滚动事件回调们
214
- fn.scrollEventCallBack = () => {
215
- // 【移动端 PC】//////////////////////////////////////////////////////////////////////
216
-
217
- // 显示/隐藏 Header导航 topBtn 【移动端 PC】
218
- const showHeaderPoint = volantis.dom.bodyAnchor.offsetTop - scrollCorrection;
219
- const scrollTop = volantis.scroll.getScrollTop(); // 滚动条距离顶部的距离
220
-
221
- // topBtn
222
- if (volantis.dom.topBtn) {
223
- if (scrollTop > volantis.dom.bodyAnchor.offsetTop) {
224
- volantis.dom.topBtn.addClass('show');
225
- // 向上滚动高亮 topBtn
226
- if (volantis.scroll.del > 0) {
227
- volantis.dom.topBtn.removeClass('hl');
228
- } else {
229
- volantis.dom.topBtn.addClass('hl');
230
- }
231
- } else {
232
- volantis.dom.topBtn.removeClass('show').removeClass('hl');
233
- }
234
- }
235
-
236
- // 决定一二级导航栏的切换 【向上滚动切换为一级导航栏;向下滚动切换为二级导航栏】 【移动端 PC】
237
- if (pdata.ispage && volantis.dom.wrapper) {
238
- if (volantis.scroll.del > 0 && scrollTop > 100) { // 向下滚动
239
- volantis.dom.wrapper.addClass('sub'); // <---- 二级导航显示
240
- } else if (volantis.scroll.del < 0) { // 向上滚动
241
- volantis.dom.wrapper.removeClass('sub'); // <---- 取消二级导航显示 一级导航显示
242
- }
243
- }
244
-
245
- // 【移动端】//////////////////////////////////////////////////////////////////////
246
- if (volantis.isMobile) {
247
- // 【移动端】 页面滚动 隐藏 移动端toc目录按钮
248
- if (pdata.ispage && volantis.dom.tocTarget && volantis.dom.toc) {
249
- volantis.dom.tocTarget.removeClass('active');
250
- volantis.dom.toc.removeClass('active');
251
- }
252
- // 【移动端】 滚动时隐藏子菜单
253
- if (volantis.dom.mPhoneList) {
254
- volantis.dom.mPhoneList.forEach(function (e) {
255
- volantis.dom.$(e).hide();
256
- })
257
- }
258
- }
259
- }
260
-
261
- // 设置滚动锚点
262
- fn.setScrollAnchor = () => {
263
- // click topBtn 滚动至bodyAnchor 【移动端 PC】
264
- if (volantis.dom.topBtn && volantis.dom.bodyAnchor) {
265
- volantis.dom.topBtn.click(e => {
266
- e.preventDefault();
267
- e.stopPropagation();
268
- fn.scrolltoElement(volantis.dom.bodyAnchor);
269
- e.stopImmediatePropagation();
270
- });
271
- }
272
-
273
- }
274
-
275
- // 设置导航栏
276
- fn.setHeader = () => {
277
- // !!! 此处的Dom对象需要重载 !!!
278
- if (!pdata.ispage) return;
279
-
280
- // 填充二级导航文章标题 【移动端 PC】
281
- volantis.dom.wrapper?.find('.nav-sub .title')?.html(document.title.split(" - ")[0]);
282
-
283
- // ====== bind events to every btn =========
284
- // 评论按钮 【移动端 PC】
285
- volantis.dom.comment = volantis.dom.$(document.getElementById("s-comment")); // 评论按钮 桌面端 移动端
286
- volantis.dom.commentTarget = volantis.dom.$(document.querySelector('#l_main article#comments')); // 评论区域
287
- if (volantis.dom.commentTarget && volantis.dom.comment) {
288
- volantis.dom.comment.click(e => { // 评论按钮点击后 跳转到评论区域
289
- e.preventDefault();
290
- e.stopPropagation();
291
- volantis.cleanContentVisibility();
292
- fn.scrolltoElement(volantis.dom.commentTarget);
293
- e.stopImmediatePropagation();
294
- });
295
- } else {
296
- if (volantis.dom.comment) volantis.dom.comment.style.display = 'none'; // 关闭了评论,则隐藏评论按钮
297
- }
298
-
299
- // 移动端toc目录按钮 【移动端】
300
- if (volantis.isMobile) {
301
- volantis.dom.toc = volantis.dom.$(document.getElementById("s-toc")); // 目录按钮 仅移动端
302
- volantis.dom.tocTarget = volantis.dom.$(document.querySelector('#l_side .toc-wrapper')); // 侧边栏的目录列表
303
- if (volantis.dom.tocTarget && volantis.dom.toc) {
304
- // 点击移动端目录按钮 激活目录按钮 显示侧边栏的目录列表
305
- volantis.dom.toc.click((e) => {
306
- e.stopPropagation();
307
- volantis.dom.tocTarget.toggleClass('active');
308
- volantis.dom.toc.toggleClass('active');
309
- });
310
- // 点击空白 隐藏
311
- volantis.dom.$(document).click(function (e) {
312
- e.stopPropagation();
313
- if (volantis.dom.tocTarget) {
314
- volantis.dom.tocTarget.removeClass('active');
315
- }
316
- volantis.dom.toc?.removeClass('active');
317
- });
318
- } else if (volantis.dom.toc) volantis.dom.toc.style.display = 'none'; // 隐藏toc目录按钮
319
- }
320
- }
321
-
322
- // 设置导航栏菜单选中状态 【移动端 PC】
323
- fn.setHeaderMenuSelection = () => {
324
- // !!! 此处的Dom对象需要重载 !!!
325
- volantis.dom.headerMenu = volantis.dom.$(document.querySelectorAll('#l_header .navigation,#l_cover .navigation,#l_side .navigation')); // 导航列表
326
-
327
- // 先把已经激活的取消激活
328
- volantis.dom.headerMenu.forEach(element => {
329
- let li = volantis.dom.$(element).find('li a.active')
330
- if (li)
331
- li.removeClass('active')
332
- let div = volantis.dom.$(element).find('div a.active')
333
- if (div)
334
- div.removeClass('active')
335
- });
336
-
337
- // replace '%' '/' '.'
338
- var idname = location.pathname.replace(/\/|%|\./g, '');
339
- if (idname.length == 0) {
340
- idname = 'home';
341
- }
342
- var page = idname.match(/page\d{0,}$/g);
343
- if (page) {
344
- page = page[0];
345
- idname = idname.split(page)[0];
346
- }
347
- var index = idname.match(/index.html/);
348
- if (index) {
349
- index = index[0];
350
- idname = idname.split(index)[0];
351
- }
352
- // 转义字符如 [, ], ~, #, @
353
- idname = idname.replace(/(\[|\]|~|#|@)/g, '\\$1');
354
- if (idname && volantis.dom.headerMenu) {
355
- volantis.dom.headerMenu.forEach(element => {
356
- // idname 不能为数字开头, 加一个 action- 前缀
357
- let id = element.querySelector("[active-action=action-" + idname + "]")
358
- if (id) {
359
- volantis.dom.$(id).addClass('active')
360
- }
361
- });
362
- }
363
- }
364
-
365
- // 导航栏激活设定
366
- fn.nextSiteMenu = () => {
367
- const element = document.querySelector('.widget.nextsite');
368
- if (element) {
369
- let activeItem = element.querySelector('li.menu-item-active');
370
- if (activeItem) {
371
- activeItem.removeClass('.menu-item-active');
372
- }
373
- let idname = location.pathname.replace(/\/|%|\./g, '');
374
- if (idname.length == 0) {
375
- idname = 'home';
376
- }
377
- var page = idname.match(/page\d{0,}$/g);
378
- if (page) {
379
- page = page[0];
380
- idname = idname.split(page)[0];
381
- }
382
- var index = idname.match(/index.html/);
383
- if (index) {
384
- index = index[0];
385
- idname = idname.split(index)[0];
386
- }
387
- // 转义字符如 [, ], ~, #, @
388
- idname = idname.replace(/(\[|\]|~|#|@)/g, '\\$1');
389
- let nowItem = element.querySelector("[active-action=action-" + idname + "]");
390
- if (nowItem?.parentElement) {
391
- volantis.dom.$(nowItem.parentElement).addClass('menu-item-active')
392
- }
393
- }
394
- }
395
-
396
- // 设置全局事件
397
- fn.setGlobalHeaderMenuEvent = () => {
398
- if (volantis.isMobile) {
399
- // 【移动端】 关闭已经展开的子菜单 点击展开子菜单
400
- document.querySelectorAll('#l_header .m-phone li').forEach(function (e) {
401
- if (e.querySelector(".list-v")) {
402
- // 点击菜单
403
- volantis.dom.$(e).click(function (e) {
404
- e.stopPropagation();
405
- // 关闭已经展开的子菜单
406
- e.currentTarget.parentElement.childNodes.forEach(function (e) {
407
- if (Object.prototype.toString.call(e) == '[object HTMLLIElement]') {
408
- e.childNodes.forEach(function (e) {
409
- if (Object.prototype.toString.call(e) == '[object HTMLUListElement]') {
410
- volantis.dom.$(e).hide()
411
- }
412
- })
413
- }
414
- })
415
- // 点击展开子菜单
416
- let array = e.currentTarget.children
417
- for (let index = 0; index < array.length; index++) {
418
- const element = array[index];
419
- if (volantis.dom.$(element).title === 'menu') { // 移动端菜单栏异常
420
- volantis.dom.$(element).display = "flex" // https://github.com/volantis-x/hexo-theme-volantis/issues/706
421
- } else {
422
- volantis.dom.$(element).show()
423
- }
424
- }
425
- }, 0);
426
- }
427
- })
428
- } else {
429
- // 【PC端】 hover时展开子菜单,点击时[target.baseURI==origin时]隐藏子菜单? 现有逻辑大部分情况不隐藏子菜单
430
- document.querySelectorAll('#wrapper .m-pc li > a[href]').forEach(function (e) {
431
- volantis.dom.$(e.parentElement).click(function (e) {
432
- e.stopPropagation();
433
- if (e.target.origin == e.target.baseURI) {
434
- document.querySelectorAll('#wrapper .m-pc .list-v').forEach(function (e) {
435
- volantis.dom.$(e).hide(); // 大概率不会执行
436
- })
437
- }
438
- }, 0);
439
- })
440
- }
441
- fn.setPageHeaderMenuEvent();
442
- }
443
-
444
- // 【移动端】隐藏子菜单
445
- fn.setPageHeaderMenuEvent = () => {
446
- if (!volantis.isMobile) return
447
- // 【移动端】 点击空白处隐藏子菜单
448
- volantis.dom.$(document).click(function (e) {
449
- volantis.dom.mPhoneList.forEach(function (e) {
450
- volantis.dom.$(e).hide();
451
- })
452
- });
453
- }
454
-
455
- // 设置导航栏搜索框 【移动端】
456
- fn.setHeaderSearch = () => {
457
- if (!volantis.isMobile) return;
458
- if (!volantis.dom.switcher) return;
459
- // 点击移动端搜索按钮
460
- volantis.dom.switcher.click(function (e) {
461
- e.stopPropagation();
462
- volantis.dom.header.toggleClass('z_search-open'); // 激活移动端搜索框
463
- volantis.dom.switcher.toggleClass('active'); // 移动端搜索按钮
464
- }, false); // false : pjax 不移除监听
465
- // 点击空白取消激活
466
- volantis.dom.$(document).click(function (e) {
467
- volantis.dom.header.removeClass('z_search-open');
468
- volantis.dom.switcher.removeClass('active');
469
- }, false); // false : pjax 不移除监听
470
- // 移动端点击搜索框 停止事件传播
471
- volantis.dom.search.click(function (e) {
472
- e.stopPropagation();
473
- }, false); // false : pjax 不移除监听
474
- }
475
-
476
- // 设置 tabs 标签 【移动端 PC】
477
- fn.setTabs = () => {
478
- let tabs = document.querySelectorAll('#l_main .tabs .nav-tabs, .widget .tabs .nav-tabs')
479
- if (!tabs) return
480
- tabs.forEach(function (e) {
481
- e.querySelectorAll('a').forEach(function (e) {
482
- volantis.dom.$(e).on('click', (e) => {
483
- e.preventDefault();
484
- e.stopPropagation();
485
- const $tab = volantis.dom.$(e.target.parentElement.parentElement.parentElement);
486
- $tab.find('.nav-tabs .active').removeClass('active');
487
- volantis.dom.$(e.target.parentElement).addClass('active');
488
- $tab.find('.tab-content .active').removeClass('active');
489
- $tab.find(e.target.className).addClass('active');
490
- return false;
491
- });
492
- })
493
- })
494
- }
495
-
496
- // 评论切换
497
- volantis.selectComment = 'beaudar';
498
- fn.switchComment = () => {
499
- const _btn = document.getElementById('switchBtn');
500
- if (_btn) {
501
- if (volantis.selectComment !== 'beaudar') {
502
- _btn.classList.remove('move');
503
- }
504
- _btn.onclick = function () {
505
- const _twikoo = document.getElementById('twikoo');
506
- const _beaudar = document.getElementById('beaudar_container');
507
- if (volantis.selectComment === 'twikoo') {
508
- _twikoo.classList.toggle('content-in');
509
- _beaudar.classList.toggle('content-in');
510
- volantis.selectComment = 'beaudar';
511
- _twikoo.style.display = 'none';
512
- _twikoo.classList.remove('content-in');
513
- _beaudar.style.display = 'block';
514
- _beaudar.classList.add('content-in');
515
- } else {
516
- volantis.selectComment = 'twikoo';
517
- _twikoo.style.display = 'block';
518
- _twikoo.classList.add('content-in');
519
- _beaudar.style.display = 'none';
520
- _beaudar.classList.remove('content-in');
521
- }
522
- _btn.classList.toggle("move");
523
- }
524
- }
525
- // console.clear();
526
- // console.log("%c ", "background:url(https://api.btstu.cn/sjbz/?lx=dongman) no-repeat center;background-size:cover;padding-left:100%;padding-bottom:55%;overflow:hidden;border-radius:10px;margin:5px 0");
527
- }
528
-
529
- // hexo-reference 页脚跳转 https://github.com/volantis-x/hexo-theme-volantis/issues/647
530
- fn.footnotes = () => {
531
- let ref = document.querySelectorAll('#l_main .footnote-backref, #l_main .footnote-ref > a');
532
- ref.forEach(function (e, i) {
533
- ref[i].click = () => { }; // 强制清空原 click 事件
534
- volantis.dom.$(e).on('click', (e) => {
535
- e.stopPropagation();
536
- e.preventDefault();
537
- let targetID = decodeURI(e.target.hash.split('#')[1]).replace(/\ /g, '-');
538
- let target = document.getElementById(targetID);
539
- if (target) {
540
- let tempHeight = volantis.dom.header ? volantis.dom.header.offsetHeight : 0;
541
- volantis.scroll.to(target, { addTop: - tempHeight - 5, behavior: 'instant' })
542
- }
543
- });
544
- })
545
- }
546
-
547
- // 工具类:代码块复制
548
- fn.utilCopyCode = (Selector) => {
549
- document.querySelectorAll(Selector).forEach(node => {
550
- const test = node.insertAdjacentHTML("beforebegin", COPYHTML);
551
- const _BtnCopy = node.previousSibling;
552
- _BtnCopy.onclick = e => {
553
- e.stopPropagation();
554
- const _icon = _BtnCopy.querySelector('i');
555
- const _span = _BtnCopy.querySelector('span');
556
-
557
- node.focus();
558
- const range = new Range();
559
- range.selectNodeContents(node);
560
- document.getSelection().removeAllRanges();
561
- document.getSelection().addRange(range);
562
-
563
- const str = document.getSelection().toString();
564
- fn.utilWriteClipText(str).then(() => {
565
- fn.messageCopyright();
566
- _BtnCopy.classList.add('copied');
567
- _icon.classList.remove('fa-copy');
568
- _icon.classList.add('fa-check-circle');
569
- _span.innerText = "COPIED";
570
- setTimeout(() => {
571
- _icon.classList.remove('fa-check-circle');
572
- _icon.classList.add('fa-copy');
573
- _span.innerText = "COPY";
574
- }, 2000)
575
- }).catch(e => {
576
- VolantisApp.message('系统提示', e, {
577
- icon: 'fal fa-exclamation-circle red'
578
- });
579
- _BtnCopy.classList.add('copied-failed');
580
- _icon.classList.remove('fa-copy');
581
- _icon.classList.add('fa-exclamation-circle');
582
- _span.innerText = "COPY FAILED";
583
- setTimeout(() => {
584
- _icon.classList.remove('fa-exclamation-circle');
585
- _icon.classList.add('fa-copy');
586
- _span.innerText = "COPY";
587
- })
588
- })
589
- }
590
- });
591
- }
592
-
593
- // 工具类:复制字符串到剪切板
594
- fn.utilWriteClipText = (str) => {
595
- return navigator.clipboard
596
- .writeText(str)
597
- .then(() => {
598
- return Promise.resolve()
599
- })
600
- .catch(e => {
601
- const input = document.createElement('textarea');
602
- input.setAttribute('readonly', 'readonly');
603
- document.body.appendChild(input);
604
- input.innerHTML = str;
605
- input.select();
606
- try {
607
- let result = document.execCommand('copy')
608
- document.body.removeChild(input);
609
- if (!result || result === 'unsuccessful') {
610
- return Promise.reject('复制文本失败!')
611
- } else {
612
- return Promise.resolve()
613
- }
614
- } catch (e) {
615
- document.body.removeChild(input);
616
- return Promise.reject(
617
- '当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作!'
618
- )
619
- }
620
- })
621
- }
622
-
623
- // 工具类:返回时间间隔
624
- fn.utilTimeAgo = (date, limit = 30) => {
625
- try {
626
- const oldTime = date.getTime()
627
- const currTime = new Date().getTime()
628
- const diffValue = currTime - oldTime
629
- const days = Math.floor(diffValue / (24 * 3600 * 1000))
630
- if (days === 0) {
631
- const leave1 = diffValue % (24 * 3600 * 1000)
632
- const hours = Math.floor(leave1 / (3600 * 1000))
633
- if (hours === 0) {
634
- const leave2 = leave1 % (3600 * 1000)
635
- const minutes = Math.floor(leave2 / (60 * 1000))
636
- if (minutes === 0) {
637
- const leave3 = leave2 % (60 * 1000)
638
- const seconds = Math.round(leave3 / 1000)
639
- return `${seconds} 秒前`
640
- }
641
- return `${minutes} 分钟前`
642
- }
643
- return `${hours} 小时前`
644
- }
645
- if (days < 0) return '刚刚'
646
-
647
- if (days < limit) {
648
- return `${days} 天前`
649
- }
650
-
651
- const Nyear = date.getFullYear();
652
- const Nmonth = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
653
- const Ndate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
654
- return `${Nyear}年${Nmonth}月${Ndate}日`
655
- } catch (error) {
656
- console.error(error)
657
- return ' - '
658
- }
659
- }
660
-
661
- // 消息提示:标准
662
- fn.message = (title, message, option = {}, done = null) => {
663
- if (typeof iziToast === "undefined") {
664
- volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css)
665
- volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js, () => {
666
- tozashMessage(title, message, option, done);
667
- });
668
- } else {
669
- tozashMessage(title, message, option, done);
670
- }
671
- function tozashMessage(title, message, option, done) {
672
- const {
673
- icon,
674
- time,
675
- position,
676
- transitionIn,
677
- transitionOut,
678
- messageColor,
679
- titleColor,
680
- backgroundColor,
681
- zindex,
682
- displayMode
683
- } = option;
684
- iziToast.show({
685
- layout: '2',
686
- icon: 'Fontawesome',
687
- closeOnEscape: 'true',
688
- displayMode: displayMode || 'replace',
689
- transitionIn: transitionIn || volantis.GLOBAL_CONFIG.plugins.message.transitionIn,
690
- transitionOut: transitionOut || volantis.GLOBAL_CONFIG.plugins.message.transitionOut,
691
- messageColor: messageColor || volantis.GLOBAL_CONFIG.plugins.message.messageColor,
692
- titleColor: titleColor || volantis.GLOBAL_CONFIG.plugins.message.titleColor,
693
- backgroundColor: backgroundColor || volantis.GLOBAL_CONFIG.plugins.message.backgroundColor,
694
- zindex: zindex || volantis.GLOBAL_CONFIG.plugins.message.zindex,
695
- icon: icon || volantis.GLOBAL_CONFIG.plugins.message.icon.default,
696
- timeout: time || volantis.GLOBAL_CONFIG.plugins.message.time.default,
697
- position: position || volantis.GLOBAL_CONFIG.plugins.message.position,
698
- title: title,
699
- message: message,
700
- onClosed: () => {
701
- if (done) done();
702
- },
703
- });
704
- }
705
- }
706
-
707
- // 消息提示:询问
708
- fn.question = (title, message, option = {}, success = null, cancel = null, done = null) => {
709
- if (typeof iziToast === "undefined") {
710
- volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css)
711
- volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js, () => {
712
- tozashQuestion(title, message, option, success, cancel, done);
713
- });
714
- } else {
715
- tozashQuestion(title, message, option, success, cancel, done);
716
- }
717
-
718
- function tozashQuestion(title, message, option, success, cancel, done) {
719
- const {
720
- icon,
721
- time,
722
- position,
723
- transitionIn,
724
- transitionOut,
725
- messageColor,
726
- titleColor,
727
- backgroundColor,
728
- zindex
729
- } = option;
730
- iziToast.question({
731
- id: 'question',
732
- icon: 'Fontawesome',
733
- close: false,
734
- overlay: true,
735
- displayMode: 'once',
736
- position: 'center',
737
- messageColor: messageColor || volantis.GLOBAL_CONFIG.plugins.message.messageColor,
738
- titleColor: titleColor || volantis.GLOBAL_CONFIG.plugins.message.titleColor,
739
- backgroundColor: backgroundColor || volantis.GLOBAL_CONFIG.plugins.message.backgroundColor,
740
- zindex: zindex || volantis.GLOBAL_CONFIG.plugins.message.zindex,
741
- icon: icon || volantis.GLOBAL_CONFIG.plugins.message.icon.quection,
742
- timeout: time || volantis.GLOBAL_CONFIG.plugins.message.time.quection,
743
- title: title,
744
- message: message,
745
- buttons: [
746
- ['<button><b>是</b></button>', (instance, toast) => {
747
- instance.hide({ transitionOut: transitionOut || 'fadeOut' }, toast, 'button');
748
- if (success) success(instance, toast)
749
- }],
750
- ['<button><b>否</b></button>', (instance, toast) => {
751
- instance.hide({ transitionOut: transitionOut || 'fadeOut' }, toast, 'button');
752
- if (cancel) cancel(instance, toast)
753
- }]
754
- ],
755
- onClosed: (instance, toast, closedBy) => {
756
- if (done) done(instance, toast, closedBy);
757
- }
758
- });
759
- }
760
- }
761
-
762
- // 消息提示:隐藏
763
- fn.hideMessage = (done = null) => {
764
- const toast = document.querySelector('.iziToast');
765
- if (!toast) {
766
- if (done) done()
767
- return;
768
- }
769
-
770
- if (typeof iziToast === "undefined") {
771
- volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css)
772
- volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js, () => {
773
- hideMessage(done);
774
- });
775
- } else {
776
- hideMessage(done);
777
- }
778
-
779
- function hideMessage(done) {
780
- iziToast.hide({}, toast);
781
- if (done) done();
782
- }
783
- }
784
-
785
- // 消息提示:复制
786
- let messageCopyrightShow = 0;
787
- fn.messageCopyright = () => {
788
- // 消息提示 复制时弹出
789
- if (volantis.GLOBAL_CONFIG.plugins.message.enable
790
- && volantis.GLOBAL_CONFIG.plugins.message.copyright.enable
791
- && messageCopyrightShow < 1) {
792
- messageCopyrightShow++;
793
- VolantisApp.message(volantis.GLOBAL_CONFIG.plugins.message.copyright.title,
794
- volantis.GLOBAL_CONFIG.plugins.message.copyright.message, {
795
- icon: volantis.GLOBAL_CONFIG.plugins.message.copyright.icon,
796
- transitionIn: 'flipInX',
797
- transitionOut: 'flipOutX',
798
- displayMode: 1
799
- });
800
- }
801
- }
802
-
803
- // 转换时间
804
- fn.dataToShow = () => {
805
- document.querySelectorAll('.dataToShow').forEach(item => {
806
- try {
807
- let time = fn.utilTimeAgo(new Date(item.getAttribute('datetime')), 60).trim();
808
- item.textContent = time ? time : item.textContent;
809
- } catch (error) { }
810
- })
811
- }
812
-
813
- return {
814
- init: () => {
815
- fn.init();
816
- fn.event();
817
- },
818
- subscribe: () => {
819
- fn.setIsMobile();
820
- fn.setHeader();
821
- fn.setHeaderMenuSelection();
822
- fn.setGlobalHeaderMenuEvent();
823
- fn.setHeaderSearch();
824
- fn.setScrollAnchor();
825
- fn.setTabs();
826
- fn.footnotes();
827
- fn.dataToShow();
828
- fn.nextSiteMenu();
829
- // fn.switchComment();
830
- },
831
- pjaxReload: () => {
832
- fn.event();
833
- fn.restData();
834
- fn.setHeader();
835
- fn.setHeaderMenuSelection();
836
- fn.setPageHeaderMenuEvent();
837
- fn.setScrollAnchor();
838
- fn.setTabs();
839
- fn.footnotes();
840
- fn.dataToShow();
841
- fn.nextSiteMenu();
842
- // fn.switchComment();
843
-
844
- // 移除小尾巴的移除
845
- document.querySelector("#l_header .nav-main")?.querySelectorAll('.list-v:not(.menu-phone)')?.forEach(function (e) {
846
- e.removeAttribute("style")
847
- })
848
- document.querySelector("#l_header .menu-phone.list-v")?.removeAttribute("style");
849
- messageCopyrightShow = 0;
850
- },
851
- utilCopyCode: fn.utilCopyCode,
852
- utilWriteClipText: fn.utilWriteClipText,
853
- utilTimeAgo: fn.utilTimeAgo,
854
- message: fn.message,
855
- question: fn.question,
856
- hideMessage: fn.hideMessage,
857
- messageCopyright: fn.messageCopyright,
858
- scrolltoElement: fn.scrolltoElement
859
- }
860
- })()
861
- Object.freeze(VolantisApp);
862
-
863
- /* FancyBox */
864
- const VolantisFancyBox = (() => {
865
- const fn = {};
866
-
867
- fn.loadFancyBox = (done) => {
868
- volantis.css(volantis.GLOBAL_CONFIG.cdn.fancybox_css);
869
- volantis.js(volantis.GLOBAL_CONFIG.cdn.fancybox_js).then(() => {
870
- if (done) done();
871
- })
872
- }
873
-
874
- /**
875
- * 加载及处理
876
- *
877
- * @param {*} checkMain 是否只处理文章区域的文章
878
- * @param {*} done FancyBox 加载完成后的动作,默认执行分组绑定
879
- * @returns
880
- */
881
- fn.init = (checkMain = true, done = fn.groupBind) => {
882
- if (!document.querySelector(".md .gallery img, .fancybox") && checkMain) return;
883
- if (typeof Fancybox === "undefined") {
884
- fn.loadFancyBox(done);
885
- } else {
886
- done();
887
- }
888
- }
889
-
890
- /**
891
- * 图片元素预处理
892
- *
893
- * @param {*} selectors 选择器
894
- * @param {*} name 分组
895
- */
896
- fn.elementHandling = (selectors, name) => {
897
- const nodeList = document.querySelectorAll(selectors);
898
- nodeList.forEach($item => {
899
- if ($item.hasAttribute('fancybox')) return;
900
- $item.setAttribute('fancybox', '');
901
- const $link = document.createElement('a');
902
- $link.setAttribute('href', $item.src);
903
- $link.setAttribute('data-caption', $item.alt);
904
- $link.setAttribute('data-fancybox', name);
905
- $link.classList.add('fancybox');
906
- $link.append($item.cloneNode());
907
- $item.replaceWith($link);
908
- })
909
- }
910
-
911
- /**
912
- * 原生绑定
913
- *
914
- * @param {*} selectors 选择器
915
- */
916
- fn.bind = (selectors) => {
917
- fn.init(false, () => {
918
- Fancybox.bind(selectors, {
919
- groupAll: true,
920
- Hash: false,
921
- hideScrollbar: false,
922
- Thumbs: {
923
- autoStart: false,
924
- },
925
- caption: function (fancybox, carousel, slide) {
926
- return slide.$trigger.alt || null
927
- }
928
- });
929
- });
930
- }
931
-
932
- /**
933
- * 分组绑定
934
- *
935
- * @param {*} groupName 分组名称
936
- */
937
- fn.groupBind = (groupName = null) => {
938
- const group = new Set();
939
-
940
- document.querySelectorAll(".gallery").forEach(ele => {
941
- if (ele.querySelector("img")) {
942
- group.add(ele.getAttribute('data-group') || 'default');
943
- }
944
- })
945
-
946
- if (!!groupName) group.add(groupName);
947
-
948
- for (const iterator of group) {
949
- Fancybox.unbind('[data-fancybox="' + iterator + '"]');
950
- Fancybox.bind('[data-fancybox="' + iterator + '"]', {
951
- Hash: false,
952
- hideScrollbar: false,
953
- Thumbs: {
954
- autoStart: false,
955
- }
956
- });
957
- }
958
- }
959
-
960
- return {
961
- init: fn.init,
962
- bind: fn.bind,
963
- groupBind: (selectors, groupName = 'default') => {
964
- try {
965
- fn.elementHandling(selectors, groupName);
966
- fn.init(false, () => {
967
- fn.groupBind(groupName)
968
- });
969
- } catch (error) {
970
- console.error(error)
971
- }
972
- }
973
- }
974
- })()
975
- Object.freeze(VolantisFancyBox);
976
-
977
- // highlightKeyWords 与 搜索功能搭配 https://github.com/next-theme/hexo-theme-next/blob/eb194a7258058302baf59f02d4b80b6655338b01/source/js/third-party/search/local-search.js
978
- // Question: 锚点稳定性未知
979
- // ToDo: 查找模式
980
- // 0. (/////////要知道浏览器自带全页面查找功能 CTRL + F)
981
- // 1. 右键开启查找模式 / 导航栏菜单开启?? / CTRL + F ???
982
- // 2. 查找模式面板 (可拖动? or 固定?)
983
- // 3. keyword mark id 从 0 开始编号 查找下一处 highlightKeyWords.scrollToNextHighlightKeywordMark() 查找上一处 scrollToPrevHighlightKeywordMark() 循环查找(取模%)
984
- // 4. 可输入修改 查找关键词 keywords(type:list)
985
- // 5. 区分大小写 caseSensitive (/ 全字匹配?? / 正则匹配??)
986
- // 6. 在选定区域中查找 querySelector ??
987
- // 7. 关闭查找模式
988
- // 8. 搜索跳转 (URL 入口) 自动开启查找模式 调用 scrollToNextHighlightKeywordMark()
989
- const highlightKeyWords = (() => {
990
- let fn = {}
991
- fn.markNum = 0
992
- fn.markNextId = -1
993
- fn.startFromURL = () => {
994
- const params = decodeURI(new URL(location.href).searchParams.get('keyword'));
995
- const keywords = params ? params.split(' ') : [];
996
- const post = document.querySelector('#l_main');
997
- if (keywords.length == 1 && keywords[0] == "null") {
998
- return;
999
- }
1000
- fn.start(keywords, post); // 渲染耗时较长
1001
- fn.scrollToFirstHighlightKeywordMark()
1002
- }
1003
- fn.scrollToFirstHighlightKeywordMark = () => {
1004
- volantis.cleanContentVisibility();
1005
- let target = fn.scrollToNextHighlightKeywordMark("0");
1006
- if (!target) {
1007
- volantis.requestAnimationFrame(fn.scrollToFirstHighlightKeywordMark)
1008
- }
1009
- }
1010
- fn.scrollToNextHighlightKeywordMark = (id) => {
1011
- // Next Id
1012
- let input = id || (fn.markNextId + 1) % fn.markNum;
1013
- fn.markNextId = parseInt(input)
1014
- let target = document.getElementById("keyword-mark-" + fn.markNextId);
1015
- if (!target) {
1016
- fn.markNextId = (fn.markNextId + 1) % fn.markNum;
1017
- target = document.getElementById("keyword-mark-" + fn.markNextId);
1018
- }
1019
- if (target) {
1020
- let tempHeight = volantis.dom.header ? volantis.dom.header.offsetHeight : 0;
1021
- volantis.scroll.to(target, { addTop: - tempHeight - 5, behavior: 'instant' })
1022
- }
1023
- // Current target
1024
- return target
1025
- }
1026
- fn.scrollToPrevHighlightKeywordMark = (id) => {
1027
- // Prev Id
1028
- let input = id || (fn.markNextId - 1 + fn.markNum) % fn.markNum;
1029
- fn.markNextId = parseInt(input)
1030
- let target = document.getElementById("keyword-mark-" + fn.markNextId);
1031
- if (!target) {
1032
- fn.markNextId = (fn.markNextId - 1 + fn.markNum) % fn.markNum;
1033
- target = document.getElementById("keyword-mark-" + fn.markNextId);
1034
- }
1035
- if (target) {
1036
- let tempHeight = volantis.dom.header ? volantis.dom.header.offsetHeight : 0;
1037
- volantis.scroll.to(target, { addTop: - tempHeight - 5, behavior: 'instant' })
1038
- }
1039
- // Current target
1040
- return target
1041
- }
1042
- fn.start = (keywords, querySelector) => {
1043
- fn.markNum = 0
1044
- if (!keywords.length || !querySelector || (keywords.length == 1 && keywords[0] == "null")) return;
1045
- console.log(keywords);
1046
- const walk = document.createTreeWalker(querySelector, NodeFilter.SHOW_TEXT, null);
1047
- const allNodes = [];
1048
- while (walk.nextNode()) {
1049
- if (!walk.currentNode.parentNode.matches('button, select, textarea')) allNodes.push(walk.currentNode);
1050
- }
1051
- allNodes.forEach(node => {
1052
- const [indexOfNode] = fn.getIndexByWord(keywords, node.nodeValue);
1053
- if (!indexOfNode.length) return;
1054
- const slice = fn.mergeIntoSlice(0, node.nodeValue.length, indexOfNode);
1055
- fn.highlightText(node, slice, 'keyword');
1056
- fn.highlightStyle()
1057
- });
1058
- }
1059
- fn.getIndexByWord = (words, text, caseSensitive = false) => {
1060
- const index = [];
1061
- const included = new Set();
1062
- words.forEach(word => {
1063
- const div = document.createElement('div');
1064
- div.innerText = word;
1065
- word = div.innerHTML;
1066
-
1067
- const wordLen = word.length;
1068
- if (wordLen === 0) return;
1069
- let startPosition = 0;
1070
- let position = -1;
1071
- if (!caseSensitive) {
1072
- text = text.toLowerCase();
1073
- word = word.toLowerCase();
1074
- }
1075
- while ((position = text.indexOf(word, startPosition)) > -1) {
1076
- index.push({ position, word });
1077
- included.add(word);
1078
- startPosition = position + wordLen;
1079
- }
1080
- });
1081
- index.sort((left, right) => {
1082
- if (left.position !== right.position) {
1083
- return left.position - right.position;
1084
- }
1085
- return right.word.length - left.word.length;
1086
- });
1087
- return [index, included];
1088
- };
1089
- fn.mergeIntoSlice = (start, end, index) => {
1090
- let item = index[0];
1091
- let { position, word } = item;
1092
- const hits = [];
1093
- const count = new Set();
1094
- while (position + word.length <= end && index.length !== 0) {
1095
- count.add(word);
1096
- hits.push({
1097
- position,
1098
- length: word.length
1099
- });
1100
- const wordEnd = position + word.length;
1101
-
1102
- index.shift();
1103
- while (index.length !== 0) {
1104
- item = index[0];
1105
- position = item.position;
1106
- word = item.word;
1107
- if (wordEnd > position) {
1108
- index.shift();
1109
- } else {
1110
- break;
1111
- }
1112
- }
1113
- }
1114
- return {
1115
- hits,
1116
- start,
1117
- end,
1118
- count: count.size
1119
- };
1120
- };
1121
- fn.highlightText = (node, slice, className) => {
1122
- const val = node.nodeValue;
1123
- let index = slice.start;
1124
- const children = [];
1125
- for (const { position, length } of slice.hits) {
1126
- const text = document.createTextNode(val.substring(index, position));
1127
- index = position + length;
1128
- let mark = document.createElement('mark');
1129
- mark.className = className;
1130
- mark = fn.highlightStyle(mark)
1131
- mark.appendChild(document.createTextNode(val.substr(position, length)));
1132
- children.push(text, mark);
1133
- }
1134
- node.nodeValue = val.substring(index, slice.end);
1135
- children.forEach(element => {
1136
- node.parentNode.insertBefore(element, node);
1137
- });
1138
- }
1139
- fn.highlightStyle = (mark) => {
1140
- if (!mark) return;
1141
- mark.id = "keyword-mark-" + fn.markNum;
1142
- fn.markNum++;
1143
- mark.style.background = "#ff0";
1144
- mark.style["border-bottom"] = "1px dashed #ff2a2a";
1145
- mark.style["color"] = "#ff2a2a";
1146
- mark.style["font-weight"] = "bold";
1147
- return mark
1148
- }
1149
- fn.cleanHighlightStyle = () => {
1150
- document.querySelectorAll(".keyword").forEach(mark => {
1151
- mark.style.background = "transparent";
1152
- mark.style["border-bottom"] = null;
1153
- mark.style["color"] = null;
1154
- mark.style["font-weight"] = null;
1155
- })
1156
- }
1157
- return {
1158
- start: (keywords, querySelector) => {
1159
- fn.start(keywords, querySelector)
1160
- },
1161
- startFromURL: () => {
1162
- fn.startFromURL()
1163
- },
1164
- scrollToNextHighlightKeywordMark: (id) => {
1165
- fn.scrollToNextHighlightKeywordMark(id)
1166
- },
1167
- scrollToPrevHighlightKeywordMark: (id) => {
1168
- fn.scrollToPrevHighlightKeywordMark(id)
1169
- },
1170
- cleanHighlightStyle: () => {
1171
- fn.cleanHighlightStyle()
1172
- },
1173
- }
1174
- })()
1175
- Object.freeze(highlightKeyWords);
1176
-
1177
- /* DOM 控制 */
1178
- const DOMController = {
1179
- /**
1180
- * 控制元素显隐
1181
- */
1182
- visible: (ele, type = true) => {
1183
- if (ele) ele.style.display = type === true ? 'block' : 'none';
1184
- },
1185
-
1186
- /**
1187
- * 移除元素
1188
- */
1189
- remove: (param) => {
1190
- const node = document.querySelectorAll(param);
1191
- node.forEach(ele => {
1192
- ele.remove();
1193
- })
1194
- },
1195
-
1196
- removeList: (list) => {
1197
- list.forEach(param => {
1198
- DOMController.remove(param)
1199
- })
1200
- },
1201
-
1202
- /**
1203
- * 设置属性
1204
- */
1205
- setAttribute: (param, attrName, attrValue) => {
1206
- const node = document.querySelectorAll(param);
1207
- node.forEach(ele => {
1208
- ele.setAttribute(attrName, attrValue)
1209
- })
1210
- },
1211
-
1212
- setAttributeList: (list) => {
1213
- list.forEach(item => {
1214
- DOMController.setAttribute(item[0], item[1], item[2])
1215
- })
1216
- },
1217
-
1218
- /**
1219
- * 设置样式
1220
- */
1221
- setStyle: (param, styleName, styleValue) => {
1222
- const node = document.querySelectorAll(param);
1223
- node.forEach(ele => {
1224
- ele.style[styleName] = styleValue;
1225
- })
1226
- },
1227
-
1228
- setStyleList: (list) => {
1229
- list.forEach(item => {
1230
- DOMController.setStyle(item[0], item[1], item[2])
1231
- })
1232
- },
1233
-
1234
- fadeIn: (e) => {
1235
- if (!e) return;
1236
- e.style.visibility = "visible";
1237
- e.style.opacity = 1;
1238
- e.style.display = "block";
1239
- e.style.transition = "all 0.5s linear";
1240
- return e
1241
- },
1242
-
1243
- fadeOut: (e) => {
1244
- if (!e) return;
1245
- e.style.visibility = "hidden";
1246
- e.style.opacity = 0;
1247
- e.style.display = "none";
1248
- e.style.transition = "all 0.5s linear";
1249
- return e
1250
- },
1251
-
1252
- fadeToggle: (e) => {
1253
- if (!e) return;
1254
- if (e.style.visibility == "hidden") {
1255
- e = DOMController.fadeIn(e)
1256
- } else {
1257
- e = DOMController.fadeOut(e)
1258
- }
1259
- return e
1260
- },
1261
-
1262
- fadeToggleList: (list) => {
1263
- list.forEach(param => {
1264
- DOMController.fadeToggle(param)
1265
- })
1266
- },
1267
-
1268
- hasClass: (e, c) => {
1269
- if (!e) return;
1270
- return e.className.match(new RegExp('(\\s|^)' + c + '(\\s|$)'));
1271
- },
1272
-
1273
- addClass: (e, c) => {
1274
- if (!e) return;
1275
- e.classList.add(c);
1276
- return e
1277
- },
1278
-
1279
- removeClass: (e, c) => {
1280
- if (!e) return;
1281
- e.classList.remove(c);
1282
- return e
1283
- },
1284
-
1285
- toggleClass: (e, c) => {
1286
- if (!e) return;
1287
- if (DOMController.hasClass(e, c)) {
1288
- DOMController.removeClass(e, c)
1289
- } else {
1290
- DOMController.addClass(e, c)
1291
- }
1292
- return e
1293
- },
1294
-
1295
- toggleClassList: (list) => {
1296
- list.forEach(item => {
1297
- DOMController.toggleClass(item[0], item[1])
1298
- })
1299
- }
1300
- }
1301
- Object.freeze(DOMController);
1302
-
1303
- const VolantisRequest = {
1304
- timeoutFetch: (url, ms, requestInit) => {
1305
- const controller = new AbortController()
1306
- requestInit.signal?.addEventListener('abort', () => controller.abort())
1307
- let promise = fetch(url, { ...requestInit, signal: controller.signal })
1308
- if (ms > 0) {
1309
- const timer = setTimeout(() => controller.abort(), ms)
1310
- promise.finally(() => { clearTimeout(timer) })
1311
- }
1312
- promise = promise.catch((err) => {
1313
- throw ((err || {}).name === 'AbortError') ? new Error(`Fetch timeout: ${url}`) : err
1314
- })
1315
- return promise
1316
- },
1317
-
1318
- Fetch: async (url, requestInit, timeout = 15000) => {
1319
- const resp = await VolantisRequest.timeoutFetch(url, timeout, requestInit);
1320
- if (!resp.ok) throw new Error(`Fetch error: ${url} | ${resp.status}`);
1321
- let json = await resp.json()
1322
- if (!json.success) throw json
1323
- return json
1324
- },
1325
-
1326
- POST: async (url, data) => {
1327
- const requestInit = {
1328
- method: 'POST',
1329
- }
1330
- if (data) {
1331
- const formData = new FormData();
1332
- Object.keys(data).forEach(key => formData.append(key, String(data[key])))
1333
- requestInit.body = formData;
1334
- }
1335
- const json = await VolantisRequest.Fetch(url, requestInit)
1336
- return json.data;
1337
- }
1338
- }
1339
- Object.freeze(VolantisRequest);
1340
-
1341
-
1
+ document.addEventListener("DOMContentLoaded",(function(){volantis.requestAnimationFrame((()=>{VolantisApp.init(),VolantisApp.subscribe(),VolantisFancyBox.init(),VolantisFancyBox.bind("#post-body img:not([fancybox])"),highlightKeyWords.startFromURL(),locationHash(),volantis.pjax.push((()=>{VolantisApp.pjaxReload(),VolantisFancyBox.init(),VolantisFancyBox.bind("#post-body img:not([fancybox])"),sessionStorage.setItem("domTitle",document.title),highlightKeyWords.startFromURL()}),"app.js"),volantis.pjax.send((()=>{volantis.dom.switcher?.removeClass("active"),volantis.dom.header?.removeClass("z_search-open"),volantis.dom.wrapper?.removeClass("sub"),volantis.EventListener?.remove()}),"app.js")}))}));const changeTitle=()=>{sessionStorage.setItem("domTitle",document.title),document.addEventListener("visibilitychange",(function(){const e=sessionStorage.getItem("domTitle")||document.title,t=e.split(" - ")||[];"hidden"==document.visibilityState?document.title=2===t.length?t[1]:t[0]:document.title=e}))},locationHash=()=>{if(window.location.hash){let e=decodeURI(window.location.hash.split("#")[1]).replace(/\ /g,"-"),t=document.getElementById(e);t&&setTimeout((()=>{window.location.hash.startsWith("#fn")?volantis.scroll.to(t,{addTop:-volantis.dom.header.offsetHeight-5,behavior:"instant",observer:!0}):volantis.scroll.to(t,{addTop:5,behavior:"instant",observer:!0})}),1e3)}};Object.freeze(locationHash);const VolantisApp=(()=>{const e={};let t=80;e.init=()=>{volantis.dom.header&&(t=volantis.dom.header.clientHeight+16),window.onresize=()=>{document.documentElement.clientWidth<500?volantis.isMobile=1:volantis.isMobile=0,volantis.isMobile!=volantis.isMobileOld&&(e.setGlobalHeaderMenuEvent(),e.setHeader(),e.setHeaderSearch())},volantis.scroll.push(e.scrollEventCallBack,"scrollEventCallBack")},e.event=()=>{volantis.dom.$(document.getElementById("scroll-down"))?.on("click",(function(){e.scrolltoElement(volantis.dom.bodyAnchor)}));const t=document.querySelector("#l_side");if(t){t.querySelectorAll("section").length||document.querySelector("#l_main").classList.add("no_sidebar")}if(volantis.GLOBAL_CONFIG.sidebar.for_page.includes("webinfo")||volantis.GLOBAL_CONFIG.sidebar.for_post.includes("webinfo")){const t=volantis.GLOBAL_CONFIG.sidebar.webinfo.lastupd;document.getElementById("last-update-show")&&t.enable&&t.friendlyShow&&(document.getElementById("last-update-show").innerHTML=e.utilTimeAgo(volantis.GLOBAL_CONFIG.lastupdate))}if(document.getElementById("webinfo-runtime-count")){let e=new Date(volantis.GLOBAL_CONFIG.sidebar.webinfo.runtime.data),t=(new Date).getTime()-e.getTime(),o=Math.floor(t/864e5),n=document.querySelector("#webinfo-runtime-count");n.innerHTML=`${(o/365).toFixed(2)} ${volantis.GLOBAL_CONFIG.sidebar.webinfo.runtime.unit}`,n.title=`${n.title} 👾 ${o} 天`}document.body.oncopy=function(){e.messageCopyright()},e.genArtalkContent("#widget-artalk-hotarticle","pv_most_pages",10,30),e.genArtalkContent("#widget-artalk-randpages","rand_pages",10,1),e.genArtalkContent("#widget-artalk-hotcomment","latest_comments",10,10),document.querySelector(".nextsite div.site-nav-toggle")?.addEventListener("click",(()=>{let e=document.querySelector(".nextsite nav.site-nav");e&&(e.style.display="none"===e.style.display||""===e.style.display?"block":"none")}))},e.genArtalkContent=async(e,t,o,n)=>{const a=localStorage.getItem(`GenArtalkTime-${t}`)||0,i=document.querySelector(e);if(i){const e=i.querySelector(".tab-pane-content");try{let i;a>Date.now()?i=JSON.parse(localStorage.getItem(t)):(i=await VolantisRequest.POST("https://artalk.szyink.com/api/stat",{site_name:"枋柚梓的猫会发光",type:t,limit:o}),localStorage.setItem(t,JSON.stringify(i)),localStorage.setItem(`GenArtalkTime-${t}`,Date.now()+6e4*n));let l="";i.forEach(((e,o)=>{switch(t){case"pv_most_pages":case"rand_pages":const t=e?.title.replaceAll(" - 枋柚梓的猫会发光","");l=`${l}<li><span>${o+1}</span><a title='${t}' href='${e?.key}'>${t}</a></li>`;break;case"latest_comments":if(!0===e?.is_collapsed)break;let n="";n=""===e?.link?`<div class="avatar"><img src="https://cravatar.cn/avatar/${e?.email_encrypted}?d=mp&amp;s=80"></div>`:`<div class="avatar"><a target="_blank" rel="noreferrer noopener nofollow" href="${e?.link}"><img src="https://cravatar.cn/avatar/${e?.email_encrypted}?d=mp&amp;s=80"></a></div>`;let a=e?.content_marked.replace(/<img\b.*?(?:\>|\/>)/g,"[图片]");l=`${l}<li>${n}<div class="main"><a href="${e?.page_key}#atk-comment-${e?.id}"><p>${e?.nick}</p>${a}</a></div></li>`}})),e.innerHTML=`<ul>${l}</ul>`,"undefined"!=typeof pjax&&pjax.refresh(e)}catch(t){console.error(t),e.innerHTML="加载失败 /(ㄒoㄒ)/~~"}}},e.restData=()=>{t=volantis.dom.header?volantis.dom.header.clientHeight:80},e.setIsMobile=()=>{document.documentElement.clientWidth<500?(volantis.isMobile=1,volantis.isMobileOld=1):(volantis.isMobile=0,volantis.isMobileOld=0)},e.scrolltoElement=(e,o=t)=>{volantis.scroll.to(e,{top:e.getBoundingClientRect().top+document.documentElement.scrollTop-o})},e.scrollEventCallBack=()=>{volantis.dom.bodyAnchor.offsetTop;const e=volantis.scroll.getScrollTop();volantis.dom.topBtn&&(e>volantis.dom.bodyAnchor.offsetTop?(volantis.dom.topBtn.addClass("show"),volantis.scroll.del>0?volantis.dom.topBtn.removeClass("hl"):volantis.dom.topBtn.addClass("hl")):volantis.dom.topBtn.removeClass("show").removeClass("hl")),pdata.ispage&&volantis.dom.wrapper&&(volantis.scroll.del>0&&e>100?volantis.dom.wrapper.addClass("sub"):volantis.scroll.del<0&&volantis.dom.wrapper.removeClass("sub")),volantis.isMobile&&(pdata.ispage&&volantis.dom.tocTarget&&volantis.dom.toc&&(volantis.dom.tocTarget.removeClass("active"),volantis.dom.toc.removeClass("active")),volantis.dom.mPhoneList&&volantis.dom.mPhoneList.forEach((function(e){volantis.dom.$(e).hide()})))},e.setScrollAnchor=()=>{volantis.dom.topBtn&&volantis.dom.bodyAnchor&&volantis.dom.topBtn.click((t=>{t.preventDefault(),t.stopPropagation(),e.scrolltoElement(volantis.dom.bodyAnchor),t.stopImmediatePropagation()}))},e.setHeader=()=>{pdata.ispage&&(volantis.dom.wrapper?.find(".nav-sub .title")?.html(document.title.split(" - ")[0]),volantis.dom.comment=volantis.dom.$(document.getElementById("s-comment")),volantis.dom.commentTarget=volantis.dom.$(document.querySelector("#l_main article#comments")),volantis.dom.commentTarget&&volantis.dom.comment?volantis.dom.comment.click((t=>{t.preventDefault(),t.stopPropagation(),volantis.cleanContentVisibility(),e.scrolltoElement(volantis.dom.commentTarget),t.stopImmediatePropagation()})):volantis.dom.comment&&(volantis.dom.comment.style.display="none"),volantis.isMobile&&(volantis.dom.toc=volantis.dom.$(document.getElementById("s-toc")),volantis.dom.tocTarget=volantis.dom.$(document.querySelector("#l_side .toc-wrapper")),volantis.dom.tocTarget&&volantis.dom.toc?(volantis.dom.toc.click((e=>{e.stopPropagation(),volantis.dom.tocTarget.toggleClass("active"),volantis.dom.toc.toggleClass("active")})),volantis.dom.$(document).click((function(e){e.stopPropagation(),volantis.dom.tocTarget&&volantis.dom.tocTarget.removeClass("active"),volantis.dom.toc?.removeClass("active")}))):volantis.dom.toc&&(volantis.dom.toc.style.display="none")))},e.setHeaderMenuSelection=()=>{volantis.dom.headerMenu=volantis.dom.$(document.querySelectorAll("#l_header .navigation,#l_cover .navigation,#l_side .navigation")),volantis.dom.headerMenu.forEach((e=>{let t=volantis.dom.$(e).find("li a.active");t&&t.removeClass("active");let o=volantis.dom.$(e).find("div a.active");o&&o.removeClass("active")}));var e=location.pathname.replace(/\/|%|\./g,"");0==e.length&&(e="home");var t=e.match(/page\d{0,}$/g);t&&(t=t[0],e=e.split(t)[0]);var o=e.match(/index.html/);o&&(o=o[0],e=e.split(o)[0]),(e=e.replace(/(\[|\]|~|#|@)/g,"\\$1"))&&volantis.dom.headerMenu&&volantis.dom.headerMenu.forEach((t=>{let o=t.querySelector("[active-action=action-"+e+"]");o&&volantis.dom.$(o).addClass("active")}))},e.nextSiteMenu=()=>{const e=document.querySelector(".widget.nextsite");if(e){let n=e.querySelector("li.menu-item-active");n&&n.removeClass(".menu-item-active");let a=location.pathname.replace(/\/|%|\./g,"");0==a.length&&(a="home");var t=a.match(/page\d{0,}$/g);t&&(t=t[0],a=a.split(t)[0]);var o=a.match(/index.html/);o&&(o=o[0],a=a.split(o)[0]),a=a.replace(/(\[|\]|~|#|@)/g,"\\$1");let i=e.querySelector("[active-action=action-"+a+"]");i?.parentElement&&volantis.dom.$(i.parentElement).addClass("menu-item-active")}},e.setGlobalHeaderMenuEvent=()=>{volantis.isMobile?document.querySelectorAll("#l_header .m-phone li").forEach((function(e){e.querySelector(".list-v")&&volantis.dom.$(e).click((function(e){e.stopPropagation(),e.currentTarget.parentElement.childNodes.forEach((function(e){"[object HTMLLIElement]"==Object.prototype.toString.call(e)&&e.childNodes.forEach((function(e){"[object HTMLUListElement]"==Object.prototype.toString.call(e)&&volantis.dom.$(e).hide()}))}));let t=e.currentTarget.children;for(let e=0;e<t.length;e++){const o=t[e];"menu"===volantis.dom.$(o).title?volantis.dom.$(o).display="flex":volantis.dom.$(o).show()}}),0)})):document.querySelectorAll("#wrapper .m-pc li > a[href]").forEach((function(e){volantis.dom.$(e.parentElement).click((function(e){e.stopPropagation(),e.target.origin==e.target.baseURI&&document.querySelectorAll("#wrapper .m-pc .list-v").forEach((function(e){volantis.dom.$(e).hide()}))}),0)})),e.setPageHeaderMenuEvent()},e.setPageHeaderMenuEvent=()=>{volantis.isMobile&&volantis.dom.$(document).click((function(e){volantis.dom.mPhoneList.forEach((function(e){volantis.dom.$(e).hide()}))}))},e.setHeaderSearch=()=>{volantis.isMobile&&volantis.dom.switcher&&(volantis.dom.switcher.click((function(e){e.stopPropagation(),volantis.dom.header.toggleClass("z_search-open"),volantis.dom.switcher.toggleClass("active")}),!1),volantis.dom.$(document).click((function(e){volantis.dom.header.removeClass("z_search-open"),volantis.dom.switcher.removeClass("active")}),!1),volantis.dom.search.click((function(e){e.stopPropagation()}),!1))},e.setTabs=()=>{let e=document.querySelectorAll("#l_main .tabs .nav-tabs, .widget .tabs .nav-tabs");e&&e.forEach((function(e){e.querySelectorAll("a").forEach((function(e){volantis.dom.$(e).on("click",(e=>{e.preventDefault(),e.stopPropagation();const t=volantis.dom.$(e.target.parentElement.parentElement.parentElement);return t.find(".nav-tabs .active").removeClass("active"),volantis.dom.$(e.target.parentElement).addClass("active"),t.find(".tab-content .active").removeClass("active"),t.find(e.target.className).addClass("active"),!1}))}))}))},volantis.selectComment="beaudar",e.switchComment=()=>{const e=document.getElementById("switchBtn");e&&("beaudar"!==volantis.selectComment&&e.classList.remove("move"),e.onclick=function(){const t=document.getElementById("twikoo"),o=document.getElementById("beaudar_container");"twikoo"===volantis.selectComment?(t.classList.toggle("content-in"),o.classList.toggle("content-in"),volantis.selectComment="beaudar",t.style.display="none",t.classList.remove("content-in"),o.style.display="block",o.classList.add("content-in")):(volantis.selectComment="twikoo",t.style.display="block",t.classList.add("content-in"),o.style.display="none",o.classList.remove("content-in")),e.classList.toggle("move")})},e.footnotes=()=>{let e=document.querySelectorAll("#l_main .footnote-backref, #l_main .footnote-ref > a");e.forEach((function(t,o){e[o].click=()=>{},volantis.dom.$(t).on("click",(e=>{e.stopPropagation(),e.preventDefault();let t=decodeURI(e.target.hash.split("#")[1]).replace(/\ /g,"-"),o=document.getElementById(t);if(o){let e=volantis.dom.header?volantis.dom.header.offsetHeight:0;volantis.scroll.to(o,{addTop:-e-5,behavior:"instant"})}}))}))},e.utilCopyCode=t=>{document.querySelectorAll(t).forEach((t=>{t.insertAdjacentHTML("beforebegin",'<button class="btn-copy" data-clipboard-snippet=""><i class="fa-solid fa-copy"></i><span>COPY</span></button>');const o=t.previousSibling;o.onclick=n=>{n.stopPropagation();const a=o.querySelector("i"),i=o.querySelector("span");t.focus();const l=new Range;l.selectNodeContents(t),document.getSelection().removeAllRanges(),document.getSelection().addRange(l);const s=document.getSelection().toString();e.utilWriteClipText(s).then((()=>{e.messageCopyright(),o.classList.add("copied"),a.classList.remove("fa-copy"),a.classList.add("fa-check-circle"),i.innerText="COPIED",setTimeout((()=>{a.classList.remove("fa-check-circle"),a.classList.add("fa-copy"),i.innerText="COPY"}),2e3)})).catch((e=>{VolantisApp.message("系统提示",e,{icon:"fal fa-exclamation-circle red"}),o.classList.add("copied-failed"),a.classList.remove("fa-copy"),a.classList.add("fa-exclamation-circle"),i.innerText="COPY FAILED",setTimeout((()=>{a.classList.remove("fa-exclamation-circle"),a.classList.add("fa-copy"),i.innerText="COPY"}))}))}}))},e.utilWriteClipText=e=>navigator.clipboard.writeText(e).then((()=>Promise.resolve())).catch((t=>{const o=document.createElement("textarea");o.setAttribute("readonly","readonly"),document.body.appendChild(o),o.innerHTML=e,o.select();try{let e=document.execCommand("copy");return document.body.removeChild(o),e&&"unsuccessful"!==e?Promise.resolve():Promise.reject("复制文本失败!")}catch(t){return document.body.removeChild(o),Promise.reject("当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作!")}})),e.utilTimeAgo=(e,t=30)=>{try{const o=e.getTime(),n=(new Date).getTime()-o,a=Math.floor(n/864e5);if(0===a){const e=n%864e5,t=Math.floor(e/36e5);if(0===t){const t=e%36e5,o=Math.floor(t/6e4);if(0===o){const e=t%6e4;return`${Math.round(e/1e3)} 秒前`}return`${o} 分钟前`}return`${t} 小时前`}if(a<0)return"刚刚";if(a<t)return`${a} 天前`;const i=e.getFullYear(),l=e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1;return`${i}年${l}月${e.getDate()<10?"0"+e.getDate():e.getDate()}日`}catch(e){return console.error(e)," - "}},e.message=(e,t,o={},n=null)=>{function a(e,t,o,n){const{icon:a,time:i,position:l,transitionIn:s,transitionOut:r,messageColor:c,titleColor:d,backgroundColor:m,zindex:u,displayMode:g}=o;iziToast.show({layout:"2",icon:"Fontawesome",closeOnEscape:"true",displayMode:g||"replace",transitionIn:s||volantis.GLOBAL_CONFIG.plugins.message.transitionIn,transitionOut:r||volantis.GLOBAL_CONFIG.plugins.message.transitionOut,messageColor:c||volantis.GLOBAL_CONFIG.plugins.message.messageColor,titleColor:d||volantis.GLOBAL_CONFIG.plugins.message.titleColor,backgroundColor:m||volantis.GLOBAL_CONFIG.plugins.message.backgroundColor,zindex:u||volantis.GLOBAL_CONFIG.plugins.message.zindex,icon:a||volantis.GLOBAL_CONFIG.plugins.message.icon.default,timeout:i||volantis.GLOBAL_CONFIG.plugins.message.time.default,position:l||volantis.GLOBAL_CONFIG.plugins.message.position,title:e,message:t,onClosed:()=>{n&&n()}})}"undefined"==typeof iziToast?(volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js,(()=>{a(e,t,o,n)}))):a(e,t,o,n)},e.question=(e,t,o={},n=null,a=null,i=null)=>{function l(e,t,o,n,a,i){const{icon:l,time:s,position:r,transitionIn:c,transitionOut:d,messageColor:m,titleColor:u,backgroundColor:g,zindex:v}=o;iziToast.question({id:"question",icon:"Fontawesome",close:!1,overlay:!0,displayMode:"once",position:"center",messageColor:m||volantis.GLOBAL_CONFIG.plugins.message.messageColor,titleColor:u||volantis.GLOBAL_CONFIG.plugins.message.titleColor,backgroundColor:g||volantis.GLOBAL_CONFIG.plugins.message.backgroundColor,zindex:v||volantis.GLOBAL_CONFIG.plugins.message.zindex,icon:l||volantis.GLOBAL_CONFIG.plugins.message.icon.quection,timeout:s||volantis.GLOBAL_CONFIG.plugins.message.time.quection,title:e,message:t,buttons:[["<button><b>是</b></button>",(e,t)=>{e.hide({transitionOut:d||"fadeOut"},t,"button"),n&&n(e,t)}],["<button><b>否</b></button>",(e,t)=>{e.hide({transitionOut:d||"fadeOut"},t,"button"),a&&a(e,t)}]],onClosed:(e,t,o)=>{i&&i(e,t,o)}})}"undefined"==typeof iziToast?(volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js,(()=>{l(e,t,o,n,a,i)}))):l(e,t,o,n,a,i)},e.hideMessage=(e=null)=>{const t=document.querySelector(".iziToast");function o(e){iziToast.hide({},t),e&&e()}t?"undefined"==typeof iziToast?(volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js,(()=>{o(e)}))):o(e):e&&e()};let o=0;return e.messageCopyright=()=>{volantis.GLOBAL_CONFIG.plugins.message.enable&&volantis.GLOBAL_CONFIG.plugins.message.copyright.enable&&o<1&&(o++,VolantisApp.message(volantis.GLOBAL_CONFIG.plugins.message.copyright.title,volantis.GLOBAL_CONFIG.plugins.message.copyright.message,{icon:volantis.GLOBAL_CONFIG.plugins.message.copyright.icon,transitionIn:"flipInX",transitionOut:"flipOutX",displayMode:1}))},e.dataToShow=()=>{document.querySelectorAll(".dataToShow").forEach((t=>{try{let o=e.utilTimeAgo(new Date(t.getAttribute("datetime")),60).trim();t.textContent=o||t.textContent}catch(e){}}))},{init:()=>{e.init(),e.event()},subscribe:()=>{e.setIsMobile(),e.setHeader(),e.setHeaderMenuSelection(),e.setGlobalHeaderMenuEvent(),e.setHeaderSearch(),e.setScrollAnchor(),e.setTabs(),e.footnotes(),e.dataToShow(),e.nextSiteMenu()},pjaxReload:()=>{e.event(),e.restData(),e.setHeader(),e.setHeaderMenuSelection(),e.setPageHeaderMenuEvent(),e.setScrollAnchor(),e.setTabs(),e.footnotes(),e.dataToShow(),e.nextSiteMenu(),document.querySelector("#l_header .nav-main")?.querySelectorAll(".list-v:not(.menu-phone)")?.forEach((function(e){e.removeAttribute("style")})),document.querySelector("#l_header .menu-phone.list-v")?.removeAttribute("style"),o=0},utilCopyCode:e.utilCopyCode,utilWriteClipText:e.utilWriteClipText,utilTimeAgo:e.utilTimeAgo,message:e.message,question:e.question,hideMessage:e.hideMessage,messageCopyright:e.messageCopyright,scrolltoElement:e.scrolltoElement}})();Object.freeze(VolantisApp);const VolantisFancyBox=(()=>{const e={loadFancyBox:e=>{volantis.css(volantis.GLOBAL_CONFIG.cdn.fancybox_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.fancybox_js).then((()=>{e&&e()}))},init:(t=!0,o=e.groupBind)=>{!document.querySelector(".md .gallery img, .fancybox")&&t||("undefined"==typeof Fancybox?e.loadFancyBox(o):o())},elementHandling:(e,t)=>{document.querySelectorAll(e).forEach((e=>{if(e.hasAttribute("fancybox"))return;e.setAttribute("fancybox","");const o=document.createElement("a");o.setAttribute("href",e.src),o.setAttribute("data-caption",e.alt),o.setAttribute("data-fancybox",t),o.classList.add("fancybox"),o.append(e.cloneNode()),e.replaceWith(o)}))},bind:t=>{e.init(!1,(()=>{Fancybox.bind(t,{groupAll:!0,Hash:!1,hideScrollbar:!1,Thumbs:{autoStart:!1},caption:function(e,t,o){return o.$trigger.alt||null}})}))},groupBind:(e=null)=>{const t=new Set;document.querySelectorAll(".gallery").forEach((e=>{e.querySelector("img")&&t.add(e.getAttribute("data-group")||"default")})),e&&t.add(e);for(const e of t)Fancybox.unbind('[data-fancybox="'+e+'"]'),Fancybox.bind('[data-fancybox="'+e+'"]',{Hash:!1,hideScrollbar:!1,Thumbs:{autoStart:!1}})}};return{init:e.init,bind:e.bind,groupBind:(t,o="default")=>{try{e.elementHandling(t,o),e.init(!1,(()=>{e.groupBind(o)}))}catch(e){console.error(e)}}}})();Object.freeze(VolantisFancyBox);const highlightKeyWords=(()=>{let e={markNum:0,markNextId:-1,startFromURL:()=>{const t=decodeURI(new URL(location.href).searchParams.get("keyword")),o=t?t.split(" "):[],n=document.querySelector("#l_main");1==o.length&&"null"==o[0]||(e.start(o,n),e.scrollToFirstHighlightKeywordMark())},scrollToFirstHighlightKeywordMark:()=>{volantis.cleanContentVisibility(),e.scrollToNextHighlightKeywordMark("0")||volantis.requestAnimationFrame(e.scrollToFirstHighlightKeywordMark)},scrollToNextHighlightKeywordMark:t=>{let o=t||(e.markNextId+1)%e.markNum;e.markNextId=parseInt(o);let n=document.getElementById("keyword-mark-"+e.markNextId);if(n||(e.markNextId=(e.markNextId+1)%e.markNum,n=document.getElementById("keyword-mark-"+e.markNextId)),n){let e=volantis.dom.header?volantis.dom.header.offsetHeight:0;volantis.scroll.to(n,{addTop:-e-5,behavior:"instant"})}return n},scrollToPrevHighlightKeywordMark:t=>{let o=t||(e.markNextId-1+e.markNum)%e.markNum;e.markNextId=parseInt(o);let n=document.getElementById("keyword-mark-"+e.markNextId);if(n||(e.markNextId=(e.markNextId-1+e.markNum)%e.markNum,n=document.getElementById("keyword-mark-"+e.markNextId)),n){let e=volantis.dom.header?volantis.dom.header.offsetHeight:0;volantis.scroll.to(n,{addTop:-e-5,behavior:"instant"})}return n},start:(t,o)=>{if(e.markNum=0,!t.length||!o||1==t.length&&"null"==t[0])return;console.log(t);const n=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,null),a=[];for(;n.nextNode();)n.currentNode.parentNode.matches("button, select, textarea")||a.push(n.currentNode);a.forEach((o=>{const[n]=e.getIndexByWord(t,o.nodeValue);if(!n.length)return;const a=e.mergeIntoSlice(0,o.nodeValue.length,n);e.highlightText(o,a,"keyword"),e.highlightStyle()}))},getIndexByWord:(e,t,o=!1)=>{const n=[],a=new Set;return e.forEach((e=>{const i=document.createElement("div");i.innerText=e;const l=(e=i.innerHTML).length;if(0===l)return;let s=0,r=-1;for(o||(t=t.toLowerCase(),e=e.toLowerCase());(r=t.indexOf(e,s))>-1;)n.push({position:r,word:e}),a.add(e),s=r+l})),n.sort(((e,t)=>e.position!==t.position?e.position-t.position:t.word.length-e.word.length)),[n,a]},mergeIntoSlice:(e,t,o)=>{let n=o[0],{position:a,word:i}=n;const l=[],s=new Set;for(;a+i.length<=t&&0!==o.length;){s.add(i),l.push({position:a,length:i.length});const e=a+i.length;for(o.shift();0!==o.length&&(n=o[0],a=n.position,i=n.word,e>a);)o.shift()}return{hits:l,start:e,end:t,count:s.size}},highlightText:(t,o,n)=>{const a=t.nodeValue;let i=o.start;const l=[];for(const{position:t,length:s}of o.hits){const o=document.createTextNode(a.substring(i,t));i=t+s;let r=document.createElement("mark");r.className=n,r=e.highlightStyle(r),r.appendChild(document.createTextNode(a.substr(t,s))),l.push(o,r)}t.nodeValue=a.substring(i,o.end),l.forEach((e=>{t.parentNode.insertBefore(e,t)}))},highlightStyle:t=>{if(t)return t.id="keyword-mark-"+e.markNum,e.markNum++,t.style.background="#ff0",t.style["border-bottom"]="1px dashed #ff2a2a",t.style.color="#ff2a2a",t.style["font-weight"]="bold",t},cleanHighlightStyle:()=>{document.querySelectorAll(".keyword").forEach((e=>{e.style.background="transparent",e.style["border-bottom"]=null,e.style.color=null,e.style["font-weight"]=null}))}};return{start:(t,o)=>{e.start(t,o)},startFromURL:()=>{e.startFromURL()},scrollToNextHighlightKeywordMark:t=>{e.scrollToNextHighlightKeywordMark(t)},scrollToPrevHighlightKeywordMark:t=>{e.scrollToPrevHighlightKeywordMark(t)},cleanHighlightStyle:()=>{e.cleanHighlightStyle()}}})();Object.freeze(highlightKeyWords);const DOMController={visible:(e,t=!0)=>{e&&(e.style.display=!0===t?"block":"none")},remove:e=>{document.querySelectorAll(e).forEach((e=>{e.remove()}))},removeList:e=>{e.forEach((e=>{DOMController.remove(e)}))},setAttribute:(e,t,o)=>{document.querySelectorAll(e).forEach((e=>{e.setAttribute(t,o)}))},setAttributeList:e=>{e.forEach((e=>{DOMController.setAttribute(e[0],e[1],e[2])}))},setStyle:(e,t,o)=>{document.querySelectorAll(e).forEach((e=>{e.style[t]=o}))},setStyleList:e=>{e.forEach((e=>{DOMController.setStyle(e[0],e[1],e[2])}))},fadeIn:e=>{if(e)return e.style.visibility="visible",e.style.opacity=1,e.style.display="block",e.style.transition="all 0.5s linear",e},fadeOut:e=>{if(e)return e.style.visibility="hidden",e.style.opacity=0,e.style.display="none",e.style.transition="all 0.5s linear",e},fadeToggle:e=>{if(e)return e="hidden"==e.style.visibility?DOMController.fadeIn(e):DOMController.fadeOut(e)},fadeToggleList:e=>{e.forEach((e=>{DOMController.fadeToggle(e)}))},hasClass:(e,t)=>{if(e)return e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:(e,t)=>{if(e)return e.classList.add(t),e},removeClass:(e,t)=>{if(e)return e.classList.remove(t),e},toggleClass:(e,t)=>{if(e)return DOMController.hasClass(e,t)?DOMController.removeClass(e,t):DOMController.addClass(e,t),e},toggleClassList:e=>{e.forEach((e=>{DOMController.toggleClass(e[0],e[1])}))}};Object.freeze(DOMController);const VolantisRequest={timeoutFetch:(e,t,o)=>{const n=new AbortController;o.signal?.addEventListener("abort",(()=>n.abort()));let a=fetch(e,{...o,signal:n.signal});if(t>0){const e=setTimeout((()=>n.abort()),t);a.finally((()=>{clearTimeout(e)}))}return a=a.catch((t=>{throw"AbortError"===(t||{}).name?new Error(`Fetch timeout: ${e}`):t})),a},Fetch:async(e,t,o=15e3)=>{const n=await VolantisRequest.timeoutFetch(e,o,t);if(!n.ok)throw new Error(`Fetch error: ${e} | ${n.status}`);let a=await n.json();if(!a.success)throw a;return a},POST:async(e,t)=>{const o={method:"POST"};if(t){const e=new FormData;Object.keys(t).forEach((o=>e.append(o,String(t[o])))),o.body=e}return(await VolantisRequest.Fetch(e,o)).data}};Object.freeze(VolantisRequest);
2
+ //# sourceMappingURL=../maps/js/app.js.map