hexo-theme-volantis 5.0.0-rc.7 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +4 -4
- package/_config.yml +173 -69
- package/layout/_meta/counter.ejs +27 -5
- package/layout/_meta/walinecount.ejs +2 -1
- package/layout/_partial/article.ejs +2 -2
- package/layout/_partial/head.ejs +29 -25
- package/layout/_partial/header.ejs +1 -1
- package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +1 -0
- package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +71 -69
- package/layout/_partial/scripts/global.ejs +49 -23
- package/layout/_partial/scripts/index.ejs +26 -9
- package/layout/_partial/scripts/toc.ejs +61 -38
- package/layout/_plugins/_page_plugins/indent/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/index.ejs +27 -7
- package/layout/_plugins/_page_plugins/snackbar/index.ejs +1 -1
- package/layout/_plugins/analytics/script.ejs +11 -1
- package/layout/_plugins/aplayer/script.ejs +2 -2
- package/layout/_plugins/comments/artalk/script.ejs +17 -11
- package/layout/_plugins/comments/beaudar/script.ejs +2 -2
- package/layout/_plugins/comments/discuss/script.ejs +30 -0
- package/layout/_plugins/comments/hashover/script.ejs +2 -2
- package/layout/_plugins/comments/index.ejs +4 -4
- package/layout/_plugins/comments/twikoo/script.ejs +1 -1
- package/layout/_plugins/comments/waline/script.ejs +40 -22
- package/layout/_plugins/parallax/script.ejs +1 -1
- package/layout/_plugins/pjax/index.ejs +3 -4
- package/layout/_plugins/pjax/pdata.ejs +0 -1
- package/layout/_plugins/rightmenu/layout.ejs +2 -2
- package/layout/_plugins/rightmenus/layout.ejs +137 -0
- package/layout/_plugins/search/script.ejs +14 -7
- package/layout/_widget/lastupdate.ejs +27 -27
- package/layout/_widget/webinfo.ejs +7 -7
- package/layout/layout.ejs +20 -3
- package/layout/tag.ejs +1 -1
- package/package.json +1 -1
- package/scripts/events/index.js +1 -0
- package/scripts/events/lib/check-configuration.js +43 -0
- package/scripts/events/lib/check-environment.js +74 -0
- package/scripts/events/lib/render-stylus.js +1 -1
- package/scripts/filters/content-visibility.js +2 -2
- package/scripts/helpers/custom-files.js +3 -1
- package/scripts/helpers/head/generate_seo.js +1 -1
- package/scripts/helpers/head/generate_title__keywords__description.js +14 -4
- package/scripts/helpers/structured-data/lib/blogposting.js +18 -6
- package/scripts/helpers/structured-data/lib/breadcrumblist.js +25 -1
- package/scripts/helpers/structured-data/lib/index.js +1 -9
- package/scripts/tags/fancybox.js +1 -1
- package/scripts/tags/note.js +24 -1
- package/scripts/tags/tabs.js +85 -86
- package/source/css/_defines/AutoPrefixCSS.styl +16 -16
- package/source/css/_defines/color.styl +23 -2
- package/source/css/_first/base_first.styl +5 -0
- package/source/css/_first/dark_first.styl +30 -29
- package/source/css/_first/navbar_first.styl +1 -1
- package/source/css/_style/_base/base.styl +2 -2
- package/source/css/_style/_layout/toc.styl +2 -2
- package/source/css/_style/_plugins/_dark/dark_async.styl +1 -1
- package/source/css/_style/_plugins/_dark/dark_plugins.styl +21 -5
- package/source/css/_style/_plugins/_highlight/highlightjs/clipboard.styl +1 -1
- package/source/css/_style/_plugins/_rightmenu/reading.styl +2 -2
- package/source/css/_style/_plugins/_rightmenu/rightmenu.styl +3 -2
- package/source/css/_style/_plugins/fontcolor.styl +1 -1
- package/source/css/_style/_plugins/index.styl +1 -1
- package/source/css/first.styl +5 -7
- package/source/js/app.js +69 -41
- package/source/js/plugins/aplayer.js +1 -3
- package/source/js/plugins/rightMenu.js +22 -22
- package/source/js/plugins/rightMenus.js +616 -0
- package/source/js/search/hexo.js +3 -0
- package/layout/_partial/scripts/import.ejs +0 -3
- package/scripts/filters/CSP.js +0 -74
|
@@ -1,86 +1,88 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
try {
|
|
3
|
+
// https://web.dev/content-visibility/
|
|
4
|
+
// https://www.caniuse.com/?search=content-visibility
|
|
5
|
+
// https://infrequently.org/2020/12/content-visibility-scroll-fix/
|
|
6
|
+
// https://infrequently.org/2020/12/resize-resilient-deferred-rendering/
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// 备注 目前已知的问题:
|
|
9
|
+
// 动态修改导致的内容高度变化(例如评论框异步渲染的外部盒子高度变化) 无法提前获知, 进而导致的首次滚动条跳动无法去除 (wontfix) 事实上不使用 content-visibility 也会有跳动, 不过是比使用 content-visibility 跳动提前
|
|
10
|
+
// scrollreveal 插件潜在问题 目前尚不明确
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let eqIsh = (a, b, fuzz = 2) => {
|
|
13
|
+
return Math.abs(a - b) <= fuzz;
|
|
14
|
+
};
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let rectNotEQ = (a, b) => {
|
|
17
|
+
return !eqIsh(a.width, b.width) || !eqIsh(a.height, b.height);
|
|
18
|
+
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// Keep a map of elements and the dimensions of
|
|
21
|
+
// their place-holders, re-setting the element's
|
|
22
|
+
// intrinsic size when we get updated measurements
|
|
23
|
+
// from observers.
|
|
24
|
+
let spaced = new WeakMap();
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
// Only call this when known cheap, post layout
|
|
27
|
+
let reserveSpace = (el, rect = el.getClientBoundingRect()) => {
|
|
28
|
+
let old = spaced.get(el);
|
|
29
|
+
// Set intrinsic size to prevent jumping on un-painting:
|
|
30
|
+
// https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override
|
|
31
|
+
if (!old || rectNotEQ(old, rect)) {
|
|
32
|
+
spaced.set(el, rect);
|
|
33
|
+
el.style["contain-intrinsic-size"] = `${rect.width}px ${rect.height}px`;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
let iObs = new IntersectionObserver(
|
|
38
|
+
(entries, o) => {
|
|
39
|
+
entries.forEach((entry) => {
|
|
40
|
+
// We don't care if the element is intersecting or
|
|
41
|
+
// has been laid out as our page structure ensures
|
|
42
|
+
// they'll get the right width.
|
|
43
|
+
reserveSpace(entry.target, entry.boundingClientRect);
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
{ rootMargin: "500px 0px 500px 0px" }
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
let rObs = new ResizeObserver((entries, o) => {
|
|
38
50
|
entries.forEach((entry) => {
|
|
39
|
-
|
|
40
|
-
// has been laid out as our page structure ensures
|
|
41
|
-
// they'll get the right width.
|
|
42
|
-
reserveSpace(entry.target, entry.boundingClientRect);
|
|
51
|
+
reserveSpace(entry.target, entry.contentRect);
|
|
43
52
|
});
|
|
44
|
-
},
|
|
45
|
-
{ rootMargin: "500px 0px 500px 0px" }
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
let rObs = new ResizeObserver((entries, o) => {
|
|
49
|
-
entries.forEach((entry) => {
|
|
50
|
-
reserveSpace(entry.target, entry.contentRect);
|
|
51
53
|
});
|
|
52
|
-
});
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
let resizeResilientDeferredRendering = (Selector) => {
|
|
56
|
+
let articles = document.querySelectorAll(Selector);
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
if (articles.length) {
|
|
59
|
+
articles.forEach((el) => {
|
|
60
|
+
iObs.observe(el);
|
|
61
|
+
rObs.observe(el);
|
|
62
|
+
});
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
requestAnimationFrame(() => {
|
|
64
|
+
// Workaround for Chrome bug, part 2.
|
|
65
|
+
//
|
|
66
|
+
// Re-enable browser management of rendering for the
|
|
67
|
+
// first article after the first paint. Double-rAF
|
|
68
|
+
// to ensure we get called after a layout.
|
|
69
69
|
requestAnimationFrame(() => {
|
|
70
|
-
|
|
70
|
+
requestAnimationFrame(() => {
|
|
71
|
+
articles[0].style["content-visibility"] = "auto";
|
|
72
|
+
});
|
|
71
73
|
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
let contentVisibilityScrollFix = () => {
|
|
78
|
+
if (!("content-visibility" in document.documentElement.style)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
resizeResilientDeferredRendering(".post-story");
|
|
82
|
+
};
|
|
83
|
+
contentVisibilityScrollFix();
|
|
84
|
+
volantis.pjax.push(contentVisibilityScrollFix);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.log(error);
|
|
87
|
+
}
|
|
86
88
|
</script>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
volantis.dom = {}; // 页面Dom see: /source/js/app.js etc.
|
|
6
6
|
|
|
7
7
|
volantis.GLOBAL_CONFIG ={
|
|
8
|
+
debug: <%- JSON.stringify(theme.debug) %>,
|
|
8
9
|
cdn: <%- JSON.stringify(theme.cdn.map) %>,
|
|
9
10
|
default: <%- JSON.stringify(theme.default) %>,
|
|
10
11
|
lastupdate: new Date(<%- theme.getStartTime %>),
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
layout: <%- JSON.stringify(theme.rightmenu.layout) %>,
|
|
35
36
|
music_alwaysShow: <%- JSON.stringify(theme.rightmenu.music.alwaysShow) %>,
|
|
36
37
|
customPicUrl: <%- JSON.stringify(theme.rightmenu.customPicUrl) %>
|
|
37
|
-
}
|
|
38
|
+
},
|
|
39
|
+
rightmenus: <%- JSON.stringify(theme.rightmenus) %>
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -179,12 +181,21 @@
|
|
|
179
181
|
error: new RunItem(),
|
|
180
182
|
send: new RunItem(),
|
|
181
183
|
};
|
|
182
|
-
volantis.pjax = {
|
|
183
|
-
...volantis.pjax,
|
|
184
|
+
volantis.pjax = Object.assign(volantis.pjax, {
|
|
184
185
|
push: volantis.pjax.method.complete.push,
|
|
185
186
|
error: volantis.pjax.method.error.push,
|
|
186
187
|
send: volantis.pjax.method.send.push,
|
|
187
|
-
};
|
|
188
|
+
});
|
|
189
|
+
/******************** RightMenu ********************************/
|
|
190
|
+
// volantis.rightmenu.handle(callBack[,"callBackName"]) 外部菜单项控制
|
|
191
|
+
// 可在 volantis.mouseEvent 处获取右键事件
|
|
192
|
+
volantis.rightmenu = {};
|
|
193
|
+
volantis.rightmenu.method = {
|
|
194
|
+
handle: new RunItem(),
|
|
195
|
+
}
|
|
196
|
+
volantis.rightmenu = Object.assign(volantis.rightmenu, {
|
|
197
|
+
handle: volantis.rightmenu.method.handle.push,
|
|
198
|
+
});
|
|
188
199
|
/******************** Dark Mode ********************************/
|
|
189
200
|
// /layout/_partial/scripts/darkmode.ejs
|
|
190
201
|
// volantis.dark.mode 当前模式 dark or light
|
|
@@ -194,10 +205,9 @@
|
|
|
194
205
|
volantis.dark.method = {
|
|
195
206
|
toggle: new RunItem(),
|
|
196
207
|
};
|
|
197
|
-
volantis.dark = {
|
|
198
|
-
...volantis.dark,
|
|
208
|
+
volantis.dark = Object.assign(volantis.dark, {
|
|
199
209
|
push: volantis.dark.method.toggle.push,
|
|
200
|
-
};
|
|
210
|
+
});
|
|
201
211
|
/******************** Message ********************************/
|
|
202
212
|
// VolantisApp.message
|
|
203
213
|
/******************** isMobile ********************************/
|
|
@@ -307,10 +317,9 @@
|
|
|
307
317
|
engine: new RunItem(),
|
|
308
318
|
unengine: new RunItem(),
|
|
309
319
|
};
|
|
310
|
-
volantis.scroll = {
|
|
311
|
-
...volantis.scroll,
|
|
320
|
+
volantis.scroll = Object.assign(volantis.scroll, {
|
|
312
321
|
push: volantis.scroll.engine.push,
|
|
313
|
-
};
|
|
322
|
+
});
|
|
314
323
|
// 滚动条距离顶部的距离
|
|
315
324
|
volantis.scroll.getScrollTop = () =>{
|
|
316
325
|
let scrollPos;
|
|
@@ -337,6 +346,8 @@
|
|
|
337
346
|
// } else {
|
|
338
347
|
// console.log("向上滚动");
|
|
339
348
|
// }
|
|
349
|
+
// 注销过期的unengine未滚动事件
|
|
350
|
+
volantis.scroll.unengine.list=[]
|
|
340
351
|
volantis.scroll.engine.start();
|
|
341
352
|
}else{
|
|
342
353
|
volantis.scroll.unengine.start();
|
|
@@ -364,24 +375,39 @@
|
|
|
364
375
|
opt.top += option.addTop
|
|
365
376
|
}
|
|
366
377
|
if (!("observerDic" in option)) {
|
|
367
|
-
option.observerDic =
|
|
378
|
+
option.observerDic = 100
|
|
368
379
|
}
|
|
369
380
|
// 滚动
|
|
370
381
|
window.scrollTo(opt);
|
|
371
382
|
// 监视器
|
|
372
|
-
// 监视并矫正元素滚动到指定位置
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
383
|
+
// 监视并矫正元素滚动到指定位置
|
|
384
|
+
// 用于处理 lazyload 引起的 cls 导致的定位失败问题
|
|
385
|
+
// option.observer = false
|
|
386
|
+
if (option.observer) {
|
|
387
|
+
setTimeout(()=>{
|
|
388
|
+
volantis.scroll.unengine.push(()=>{
|
|
389
|
+
let me = ele.getBoundingClientRect().top
|
|
390
|
+
if(!(me >= -option.observerDic && me <= option.observerDic)){
|
|
391
|
+
volantis.scroll.to(ele, option)
|
|
392
|
+
}
|
|
393
|
+
volantis.scroll.unengine.remove("unengineObserver")
|
|
394
|
+
},"unengineObserver")
|
|
395
|
+
},1000)
|
|
396
|
+
}
|
|
384
397
|
}
|
|
398
|
+
/********************** Content Visibility ********************************/
|
|
399
|
+
// 见 source/css/first.styl 如果遇到任何问题 删除 .post-story 即可
|
|
400
|
+
// 一个元素被声明 content-visibility 属性后 如果元素不在 viewport 中 浏览器不会计算其后代元素样式和属性 从而节省 Style & Layout 耗时
|
|
401
|
+
// content-visibility 的副作用: 锚点失效 等等(实验初期 暂不明确), 使用此方法清除样式
|
|
402
|
+
volantis.cleanContentVisibility = ()=>{
|
|
403
|
+
if (document.querySelector(".post-story")) {
|
|
404
|
+
console.log("cleanContentVisibility");
|
|
405
|
+
document.querySelectorAll(".post-story").forEach(e=>{
|
|
406
|
+
e.classList.remove("post-story")
|
|
407
|
+
})
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/******************************************************************************/
|
|
385
411
|
/******************************************************************************/
|
|
386
412
|
/******************************************************************************/
|
|
387
413
|
//图像加载出错时的处理
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
<%- partial('../../_plugins/rightmenu/layout') %>
|
|
36
36
|
<% } %>
|
|
37
37
|
|
|
38
|
+
<% if (theme.rightmenus.enable) { %>
|
|
39
|
+
<%- partial('../../_plugins/rightmenus/layout') %>
|
|
40
|
+
<% } %>
|
|
41
|
+
|
|
38
42
|
<!-- rightmenu要在darkmode之前(ToggleButton) darkmode要在comments之前(volantis.dark.push)-->
|
|
39
43
|
<% if (theme.plugins.darkmode.enable) { %>
|
|
40
44
|
<%- partial('../../_plugins/darkmode/script') %>
|
|
@@ -60,9 +64,27 @@
|
|
|
60
64
|
<%- partial('../../_plugins/aplayer/script') %>
|
|
61
65
|
<% } %>
|
|
62
66
|
|
|
63
|
-
<%
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
<%
|
|
68
|
+
if (theme.comments.service && theme.comments.service.length > 0) {
|
|
69
|
+
try { %>
|
|
70
|
+
<%- partial('../../_plugins/comments/' + theme.comments.service + '/script') %>
|
|
71
|
+
<% } catch (e) {
|
|
72
|
+
// error friendly
|
|
73
|
+
console.log(`
|
|
74
|
+
===============================================================================
|
|
75
|
+
没有找到评论插件:${theme.comments.service}
|
|
76
|
+
请检查是否存在该插件,或者检查插件名称是否正确:${theme.comments.service}
|
|
77
|
+
see: https://volantis.js.org/v5/theme-settings/#选择评论系统
|
|
78
|
+
================================================================================
|
|
79
|
+
There is no comments plugin: ${theme.comments.service}
|
|
80
|
+
Please check if the plugin exists, or check the plugin name is correct: ${theme.comments.service}
|
|
81
|
+
see: https://volantis.js.org/v5/theme-settings/#选择评论系统
|
|
82
|
+
=================================================================================`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
%>
|
|
86
|
+
|
|
87
|
+
|
|
66
88
|
|
|
67
89
|
<% if (theme.analytics.busuanzi) { %>
|
|
68
90
|
<script defer src="<%- theme.analytics.busuanzi %>" data-pjax></script>
|
|
@@ -89,7 +111,7 @@
|
|
|
89
111
|
<%- partial('../../_plugins/analytics/LCCounter') %>
|
|
90
112
|
<% } %>
|
|
91
113
|
|
|
92
|
-
<% if (config.google_analytics_key || config.baidu_analytics_key || config.tencent_aegis_id) { %>
|
|
114
|
+
<% if (config.google_analytics_key || config.baidu_analytics_key || config.tencent_aegis_id || config.v6_51_la) { %>
|
|
93
115
|
<%- partial('../../_plugins/analytics/script') %>
|
|
94
116
|
<% } %>
|
|
95
117
|
|
|
@@ -120,8 +142,3 @@
|
|
|
120
142
|
<%- structured_data() %>
|
|
121
143
|
<% } %>
|
|
122
144
|
|
|
123
|
-
<!-- more -->
|
|
124
|
-
<% if (config.import && config.import.script) { %>
|
|
125
|
-
<%- partial('import') %>
|
|
126
|
-
<% } %>
|
|
127
|
-
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
function listennSidebarTOC() {
|
|
3
3
|
const navItems = document.querySelectorAll(".toc li");
|
|
4
4
|
if (!navItems.length) return;
|
|
5
|
+
let targets = []
|
|
5
6
|
const sections = [...navItems].map((element) => {
|
|
6
7
|
const link = element.querySelector(".toc-link");
|
|
7
8
|
const target = document.getElementById(
|
|
8
9
|
decodeURI(link.getAttribute("href")).replace("#", "")
|
|
9
10
|
);
|
|
11
|
+
targets.push(target)
|
|
10
12
|
// 解除 a 标签 href 的 锚点定位, a 标签 href 的 锚点定位 会随机启用?? 产生错位???
|
|
11
13
|
link.setAttribute("onclick","return false;")
|
|
12
14
|
link.setAttribute("toc-action","toc-"+decodeURI(link.getAttribute("href")).replace("#", ""))
|
|
@@ -15,7 +17,7 @@
|
|
|
15
17
|
link.addEventListener("click", (event) => {
|
|
16
18
|
event.preventDefault();
|
|
17
19
|
// 这里的 addTop 是通过错位使得 toc 自动展开.
|
|
18
|
-
volantis.scroll.to(target,{addTop: 5, observer:
|
|
20
|
+
volantis.scroll.to(target,{addTop: 5, observer:true})
|
|
19
21
|
// Anchor id
|
|
20
22
|
history.pushState(null, document.title, "#" + target.id);
|
|
21
23
|
});
|
|
@@ -36,46 +38,67 @@
|
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function createIntersectionObserver(marginTop) {
|
|
57
|
-
marginTop = Math.floor(marginTop + 10000);
|
|
58
|
-
let intersectionObserver = new IntersectionObserver(
|
|
59
|
-
(entries, observe) => {
|
|
60
|
-
let scrollHeight = document.documentElement.scrollHeight;
|
|
61
|
-
if (scrollHeight > marginTop) {
|
|
62
|
-
observe.disconnect();
|
|
63
|
-
createIntersectionObserver(scrollHeight);
|
|
64
|
-
return;
|
|
41
|
+
// 方案一:
|
|
42
|
+
volantis.activateNavIndex=0
|
|
43
|
+
activateNavByIndex(navItems[volantis.activateNavIndex])
|
|
44
|
+
volantis.scroll.push(()=>{
|
|
45
|
+
if (targets[0].getBoundingClientRect().top >= 0) {
|
|
46
|
+
volantis.activateNavIndex = 0
|
|
47
|
+
}else if (targets[targets.length-1].getBoundingClientRect().top < 0) {
|
|
48
|
+
volantis.activateNavIndex = targets.length-1
|
|
49
|
+
} else {
|
|
50
|
+
for (let index = 0; index < targets.length; index++) {
|
|
51
|
+
const target0 = targets[index];
|
|
52
|
+
const target1 = targets[(index+1)%targets.length];
|
|
53
|
+
if (target0.getBoundingClientRect().top < 0&&target1.getBoundingClientRect().top >= 0) {
|
|
54
|
+
volantis.activateNavIndex=index
|
|
55
|
+
break;
|
|
65
56
|
}
|
|
66
|
-
let index = findIndex(entries);
|
|
67
|
-
activateNavByIndex(navItems[index]);
|
|
68
|
-
}, {
|
|
69
|
-
rootMargin: marginTop + "px 0px -100% 0px",
|
|
70
|
-
threshold: 0,
|
|
71
57
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
}
|
|
58
|
+
}
|
|
59
|
+
activateNavByIndex(navItems[volantis.activateNavIndex])
|
|
60
|
+
})
|
|
77
61
|
|
|
78
|
-
|
|
62
|
+
// 方案二:
|
|
63
|
+
// IntersectionObserver 不是完美精确到像素级别 也不是低延时性的
|
|
64
|
+
// function findIndex(entries) {
|
|
65
|
+
// let index = 0;
|
|
66
|
+
// let entry = entries[index];
|
|
67
|
+
// if (entry.boundingClientRect.top > 0) {
|
|
68
|
+
// index = sections.indexOf(entry.target);
|
|
69
|
+
// return index === 0 ? 0 : index - 1;
|
|
70
|
+
// }
|
|
71
|
+
// for (; index < entries.length; index++) {
|
|
72
|
+
// if (entries[index].boundingClientRect.top <= 0) {
|
|
73
|
+
// entry = entries[index];
|
|
74
|
+
// } else {
|
|
75
|
+
// return sections.indexOf(entry.target);
|
|
76
|
+
// }
|
|
77
|
+
// }
|
|
78
|
+
// return sections.indexOf(entry.target);
|
|
79
|
+
// }
|
|
80
|
+
// function createIntersectionObserver(marginTop) {
|
|
81
|
+
// marginTop = Math.floor(marginTop + 10000);
|
|
82
|
+
// let intersectionObserver = new IntersectionObserver(
|
|
83
|
+
// (entries, observe) => {
|
|
84
|
+
// let scrollHeight = document.documentElement.scrollHeight;
|
|
85
|
+
// if (scrollHeight > marginTop) {
|
|
86
|
+
// observe.disconnect();
|
|
87
|
+
// createIntersectionObserver(scrollHeight);
|
|
88
|
+
// return;
|
|
89
|
+
// }
|
|
90
|
+
// let index = findIndex(entries);
|
|
91
|
+
// activateNavByIndex(navItems[index]);
|
|
92
|
+
// }, {
|
|
93
|
+
// rootMargin: marginTop + "px 0px -100% 0px",
|
|
94
|
+
// threshold: 0,
|
|
95
|
+
// }
|
|
96
|
+
// );
|
|
97
|
+
// sections.forEach((element) => {
|
|
98
|
+
// element && intersectionObserver.observe(element);
|
|
99
|
+
// });
|
|
100
|
+
// }
|
|
101
|
+
// createIntersectionObserver(document.documentElement.scrollHeight);
|
|
79
102
|
}
|
|
80
103
|
|
|
81
104
|
document.addEventListener("DOMContentLoaded", ()=>{
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
<%_
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<%_
|
|
2
|
+
(page.plugins||[]).forEach(function(item){
|
|
3
|
+
try {
|
|
4
|
+
if (typeof item == "string") { _%>
|
|
5
|
+
<%- partial( item + "/index") %>
|
|
6
|
+
<%_ }else if(typeof item == "object"){ _%>
|
|
7
|
+
<%- partial( Object.keys(item)[0] + "/index", { pagePlugin:item }) %>
|
|
8
|
+
<%_ }
|
|
9
|
+
} catch (error) {
|
|
10
|
+
// error friendly
|
|
11
|
+
console.log(`
|
|
12
|
+
===============================================================================
|
|
13
|
+
没有找到页面插件:${item}
|
|
14
|
+
请检查是否存在该插件,或者检查插件名称是否正确:${item}
|
|
15
|
+
出问题的页面:${page.path}
|
|
16
|
+
see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins
|
|
17
|
+
================================================================================
|
|
18
|
+
There is no page plugin: ${item}
|
|
19
|
+
Please check if the plugin exists, or check the plugin name is correct: ${item}
|
|
20
|
+
The page that has problem: ${page.path}
|
|
21
|
+
see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins
|
|
22
|
+
=================================================================================`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
_%>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<% if (site.data.notification && (pagePlugin.snackbar in site.data.notification)) { %>
|
|
1
|
+
<% if (site.data.notification && (pagePlugin.snackbar in site.data.notification)) { %>
|
|
2
2
|
<% let snackbar = site.data.notification[pagePlugin.snackbar] %>
|
|
3
3
|
<% if (snackbar.position == 'bottom') { %>
|
|
4
4
|
<div id="snackbar"></div>
|
|
@@ -35,6 +35,7 @@ var _hmt = _hmt || [];
|
|
|
35
35
|
volantis.pjax.push(()=>{_hmt.push(['_trackPageview', document.location.pathname]);},'baidu_analytics')
|
|
36
36
|
</script>
|
|
37
37
|
<% } %>
|
|
38
|
+
|
|
38
39
|
<% if (config.tencent_aegis_id) { %>
|
|
39
40
|
<script>
|
|
40
41
|
const genUuid = () => {
|
|
@@ -61,4 +62,13 @@ volantis.pjax.push(()=>{_hmt.push(['_trackPageview', document.location.pathname]
|
|
|
61
62
|
}, 1000)
|
|
62
63
|
</script>
|
|
63
64
|
<% } %>
|
|
64
|
-
|
|
65
|
+
|
|
66
|
+
<% if (config.v6_51_la) { %>
|
|
67
|
+
<script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
|
|
68
|
+
<script>
|
|
69
|
+
volantis.js("https://sdk.51.la/js-sdk-pro.min.js").then(() => {
|
|
70
|
+
LA.init({id: "<%= config.v6_51_la %>",ck: "<%= config.v6_51_la %>",autoTrack:true,hashMode:true})
|
|
71
|
+
})
|
|
72
|
+
</script>
|
|
73
|
+
<% } %>
|
|
74
|
+
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// APlayer 需要在 MetingJS 之前加载
|
|
5
5
|
await volantis.js("<%- theme.plugins.aplayer.js.aplayer %>")
|
|
6
6
|
await volantis.js("<%- theme.plugins.aplayer.js.meting %>")
|
|
7
|
-
<% if (theme.rightmenu.enable && theme.rightmenu.layout.includes('music')) { %>
|
|
7
|
+
<% if ((theme.rightmenu.enable || theme.rightmenus.enable) && theme.rightmenu.layout.includes('music')) { %>
|
|
8
8
|
// 右键 music 需要在 APlayer MetingJS 之后加载
|
|
9
9
|
await volantis.js('<%- theme.cdn.addJS("plugins/aplayer") %>')
|
|
10
10
|
<% } %>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
Metings.forEach((item, index) => {
|
|
26
26
|
const aplayerItem = item.aplayer; if(!aplayerItem) return;
|
|
27
27
|
const rightAplayerCheck = '<%= theme.rightmenu.layout.includes("music") %>' === 'true'
|
|
28
|
-
&& item.meta.id === '<%= theme.plugins.aplayer.id %>';
|
|
28
|
+
&& item.meta.id === '<%= theme.plugins.aplayer.id %>';
|
|
29
29
|
if(rightAplayerCheck) RightMenuAplayer.checkAPlayer();
|
|
30
30
|
if(aplayerItem.events.events.play.every(item => {return item.name !== 'messagePlay'})) {
|
|
31
31
|
aplayerItem.on('play', function messagePlay() {
|
|
@@ -19,20 +19,24 @@
|
|
|
19
19
|
pageKey: path,
|
|
20
20
|
pageTitle: document.title,
|
|
21
21
|
placeholder: placeholder,
|
|
22
|
+
useBackendConf: true,
|
|
22
23
|
site: '<%= config.title %>',
|
|
23
|
-
darkMode: volantis.dark.mode === "dark"
|
|
24
|
+
darkMode: volantis.dark.mode === "dark",
|
|
25
|
+
pvEl: '#artalk_visitors'
|
|
24
26
|
}));
|
|
25
27
|
|
|
26
|
-
volantis.artalk.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
volantis.artalk.then(ctx => {
|
|
29
|
+
ctx.on('comments-loaded', () => {
|
|
30
|
+
if (typeof VolantisFancyBox === "undefined"){
|
|
31
|
+
const checkFancyBox = setInterval(() => {
|
|
32
|
+
if(typeof VolantisFancyBox === "undefined") return;
|
|
33
|
+
clearInterval(checkFancyBox);
|
|
34
|
+
VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
|
|
35
|
+
})
|
|
36
|
+
} else {
|
|
31
37
|
VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
|
|
35
|
-
}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
36
40
|
})
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -47,7 +51,9 @@
|
|
|
47
51
|
|
|
48
52
|
function dark_artalk() {
|
|
49
53
|
if(!document.querySelectorAll("#artalk_container")[0]) return;
|
|
50
|
-
volantis.artalk.
|
|
54
|
+
volantis.artalk.then(ctx => {
|
|
55
|
+
ctx.setDarkMode(volantis.dark.mode === "dark")
|
|
56
|
+
})
|
|
51
57
|
}
|
|
52
58
|
volantis.dark.push(dark_artalk);
|
|
53
59
|
</script>
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
const beaudarIframe = document.querySelector('iframe');
|
|
47
47
|
beaudarIframe.contentWindow.postMessage(message, 'https://beaudar.lipk.org');
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
function check_beaudar_style() {
|
|
51
51
|
// Beaudar 会往 HEAD 的首节点追加样式元素,而这个追加没有添加判断
|
|
52
52
|
// 所以 Pjax 下会多次添加样式文件,略微麻烦。
|
|
53
53
|
const checkStyle = document.querySelector('head').firstElementChild;
|
|
54
54
|
if(checkStyle.innerText.includes('beaudar')) checkStyle.remove();
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
pjax_beaudar();
|
|
58
58
|
volantis.pjax.push(check_beaudar_style);
|
|
59
59
|
volantis.pjax.push(pjax_beaudar);
|