hexo-theme-volantis 5.8.0 → 6.0.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 +3 -37
- package/_cdn.yml +449 -0
- package/_config.yml +155 -157
- package/languages/en.yml +9 -10
- package/languages/zh-CN.yml +11 -15
- package/languages/zh-TW.yml +10 -11
- package/layout/_meta/category.ejs +10 -5
- package/layout/_meta/counter.ejs +14 -17
- package/layout/_meta/tags.ejs +3 -0
- package/layout/_meta/walinecount.ejs +1 -1
- package/layout/_partial/article.ejs +8 -3
- package/layout/_partial/cover.ejs +4 -4
- package/layout/_partial/footer.ejs +1 -1
- package/layout/_partial/head.ejs +7 -18
- package/layout/_partial/header.ejs +6 -6
- package/layout/_partial/post.ejs +3 -3
- package/layout/_partial/scripts/_ctrl.ejs +43 -2
- package/layout/_partial/scripts/config.ejs +69 -0
- package/layout/_partial/scripts/global.ejs +137 -60
- package/layout/_partial/scripts/index.ejs +16 -23
- package/layout/_plugins/_page_plugins/artitalk/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/bbtalk/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/fcircle/index.ejs +9 -8
- package/layout/_plugins/_page_plugins/katex/index.ejs +3 -3
- package/layout/_plugins/_page_plugins/mathjax/index.ejs +1 -1
- package/layout/_plugins/aplayer/layout.ejs +31 -23
- package/layout/_plugins/aplayer/script.ejs +93 -65
- package/layout/_plugins/comments/artalk/script.ejs +9 -2
- package/layout/_plugins/comments/discuss/script.ejs +1 -1
- package/layout/_plugins/comments/disqusjs/script.ejs +2 -2
- package/layout/_plugins/comments/gitalk/script.ejs +1 -1
- package/layout/_plugins/comments/twikoo/script.ejs +1 -1
- package/layout/_plugins/comments/vssue/script.ejs +3 -3
- package/layout/_plugins/comments/waline/script.ejs +2 -2
- package/layout/_plugins/github-api/script.ejs +3 -3
- package/layout/_plugins/lazyload/script.ejs +1 -1
- package/layout/_plugins/nodewaves/script.ejs +1 -1
- package/layout/_plugins/pace/script.ejs +15 -0
- package/layout/_plugins/parallax/script.ejs +1 -1
- package/layout/_plugins/pjax/index.ejs +66 -11
- package/layout/_plugins/pjax/pdata.ejs +5 -5
- package/layout/_plugins/preload/script.ejs +2 -2
- package/layout/_plugins/rightmenus/layout.ejs +4 -4
- package/layout/_plugins/scrollreveal/script.ejs +2 -2
- package/layout/_plugins/search/script.ejs +11 -8
- package/layout/_plugins/swiper/script.ejs +2 -2
- package/layout/{_partial/scripts/toc.ejs → _plugins/toc/script.ejs} +40 -36
- package/layout/_widget/webinfo.ejs +13 -14
- package/layout/friends.ejs +2 -2
- package/layout/layout.ejs +1 -15
- package/package.json +4 -4
- package/scripts/events/lib/cdn.js +206 -0
- package/scripts/events/lib/check-configuration.js +7 -7
- package/scripts/events/lib/check-environment.js +17 -17
- package/scripts/events/lib/config.js +0 -24
- package/scripts/events/lib/render-stylus.js +5 -5
- package/scripts/events/lib/stellar-tag-utils.js +2 -2
- package/scripts/filters/hexo-blog-encrypt-callback.js +44 -0
- package/scripts/filters/img.js +1 -1
- package/scripts/filters/replace.js +3 -3
- package/scripts/filters/z-lazyload.js +3 -5
- package/scripts/helpers/first-style.js +2 -2
- package/scripts/helpers/head/generate_seo.js +11 -9
- package/scripts/helpers/head/generate_title__keywords__description.js +19 -6
- package/scripts/helpers/related-posts.js +3 -3
- package/scripts/helpers/structured-data/lib/blogposting.js +1 -1
- package/scripts/helpers/structured-data/lib/breadcrumblist.js +1 -1
- package/scripts/helpers/structured-data/lib/config.js +1 -1
- package/scripts/helpers/structured-data/lib/website.js +1 -1
- package/scripts/helpers//346/226/207/347/253/240/346/216/250/350/215/220.js +184 -0
- package/scripts/tags/btn.js +2 -2
- package/scripts/tags/btns.js +3 -3
- package/scripts/tags/checkbox.js +6 -6
- package/scripts/tags/contributors.js +7 -7
- package/scripts/tags/dropmenu.js +8 -8
- package/scripts/tags/fancybox.js +6 -6
- package/scripts/tags/folding.js +5 -5
- package/scripts/tags/frame.js +3 -3
- package/scripts/tags/friends.js +8 -8
- package/scripts/tags/ghcard.js +7 -7
- package/scripts/tags/image.js +6 -6
- package/scripts/tags/inline-labels.js +6 -6
- package/scripts/tags/link.js +5 -5
- package/scripts/tags/md.js +4 -4
- package/scripts/tags/media.js +5 -5
- package/scripts/tags/note.js +12 -12
- package/scripts/tags/pandown.js +29 -29
- package/scripts/tags/site.js +4 -4
- package/scripts/tags/span.js +4 -4
- package/scripts/tags/table.js +2 -2
- package/scripts/tags/tabs.js +23 -23
- package/scripts/tags/timeline.js +5 -5
- package/source/css/_first/base_first.styl +1 -1
- package/source/css/_style/_layout/article.styl +43 -0
- package/source/css/_style/_layout/main.styl +1 -1
- package/source/css/_style/_layout/search.styl +206 -14
- package/source/css/_style/_plugins/index.styl +1 -3
- package/source/js/app.js +133 -160
- package/source/js/plugins/parallax.js +1 -1
- package/source/js/plugins/rightMenus.js +24 -20
- package/source/js/search/algolia.js +239 -0
- package/source/js/search/hexo.js +8 -2
- package/source/js/search/meilisearch.js +220 -0
- package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +0 -127
- package/layout/_partial/scripts/_ctrl/coverCtrl.ejs +0 -43
- package/layout/_plugins/analytics/LCCounter.ejs +0 -207
- package/layout/_plugins/pjax/animate.ejs +0 -31
- package/layout/_plugins/rightmenu/layout.ejs +0 -119
- package/scripts/helpers/revisioned.js +0 -167
- package/source/css/_style/_plugins/pjaxanimate.styl +0 -160
- package/source/js/plugins/rightMenu.js +0 -577
- /package/layout/{_partial/scripts/content-visibility-scroll-fix.ejs → _plugins/content-visibility/script.ejs} +0 -0
|
@@ -1,74 +1,102 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
volantis.css("<%- theme.
|
|
3
|
-
(async () => {
|
|
4
|
-
// APlayer 需要在 MetingJS 之前加载
|
|
5
|
-
await volantis.js("<%- theme.plugins.aplayer.js.aplayer %>")
|
|
6
|
-
await volantis.js("<%- theme.plugins.aplayer.js.meting %>")
|
|
7
|
-
<% if ((theme.rightmenu.enable || theme.rightmenus.enable) && theme.rightmenu.layout.includes('music')) { %>
|
|
8
|
-
// 右键 music 需要在 APlayer MetingJS 之后加载
|
|
9
|
-
await volantis.js('<%- theme.cdn.addJS("plugins/aplayer") %>')
|
|
10
|
-
<% } %>
|
|
11
|
-
})();
|
|
2
|
+
volantis.css("<%- theme.cdn.aplayer_css %>");
|
|
12
3
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
let title = aplayerItem.list.audios[index].title;
|
|
48
|
-
let artist = aplayerItem.list.audios[index].artist;
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
// 歌曲播放结束也会触发 pause 事件,为了避免错误提示,等待一会儿
|
|
51
|
-
if(aplayerItem.paused) {
|
|
4
|
+
<% if (theme.plugins.aplayer.source == "meting") { %>
|
|
5
|
+
(async () => {
|
|
6
|
+
// APlayer 需要在 MetingJS 之前加载
|
|
7
|
+
await volantis.js("<%- theme.cdn.aplayer_js %>")
|
|
8
|
+
await volantis.js("<%- theme.cdn.meting %>")
|
|
9
|
+
<% if (theme.rightmenus.enable && theme.rightmenus.order.includes('music')) { %>
|
|
10
|
+
// 右键 music 需要在 APlayer MetingJS 之后加载
|
|
11
|
+
await volantis.js('<%- theme.cdn.volantis_aplayer %>')
|
|
12
|
+
<% } %>
|
|
13
|
+
})();
|
|
14
|
+
|
|
15
|
+
function SetAPlayerPlugin(){
|
|
16
|
+
let Metings = document.querySelectorAll('meting-js');
|
|
17
|
+
if (Metings.length === 0) {return;};
|
|
18
|
+
if (Metings[0].aplayer && Metings[0].aplayer.on) {
|
|
19
|
+
// improve the accessibility https://web.dev/button-name/
|
|
20
|
+
document.querySelectorAll(".aplayer-icon-menu").forEach(e=>{
|
|
21
|
+
e.setAttribute("aria-label","Aplayer Menu")
|
|
22
|
+
})
|
|
23
|
+
// message see: /layout/_plugins/message/script.ejs
|
|
24
|
+
<% if (theme.plugins.message.enable && theme.plugins.message.aplayer.enable) { %>
|
|
25
|
+
try {
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
Metings.forEach((item, index) => {
|
|
28
|
+
const aplayerItem = item.aplayer; if(!aplayerItem) return;
|
|
29
|
+
const rightAplayerCheck = '<%= theme.rightmenus.order.includes("music") %>' === 'true'
|
|
30
|
+
&& item.meta.id === '<%= theme.plugins.aplayer.id %>';
|
|
31
|
+
if(rightAplayerCheck && typeof RightMenuAplayer !="undefined") RightMenuAplayer.checkAPlayer();
|
|
32
|
+
if(aplayerItem.events.events.play.every(item => {return item.name !== 'messagePlay'})) {
|
|
33
|
+
aplayerItem.on('play', function messagePlay() {
|
|
34
|
+
let index = aplayerItem.list.index;
|
|
35
|
+
let title = aplayerItem.list.audios[index].title;
|
|
36
|
+
let artist = aplayerItem.list.audios[index].artist;
|
|
37
|
+
setTimeout(() => {
|
|
52
38
|
VolantisApp.message('音乐通知', title + ' - ' + artist, {
|
|
53
|
-
icon: '<%- theme.plugins.message.aplayer.
|
|
39
|
+
icon: '<%- theme.plugins.message.aplayer.play %>',
|
|
54
40
|
transitionIn: 'flipInX',
|
|
55
41
|
transitionOut: 'flipOutX'
|
|
56
42
|
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
43
|
+
}, 100)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if(aplayerItem.events.events.pause.every(item => {return item.name !== 'messagePause'})) {
|
|
47
|
+
aplayerItem.on('pause', function messagePause() {
|
|
48
|
+
let index = aplayerItem.list.index;
|
|
49
|
+
let title = aplayerItem.list.audios[index].title;
|
|
50
|
+
let artist = aplayerItem.list.audios[index].artist;
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
// 歌曲播放结束也会触发 pause 事件,为了避免错误提示,等待一会儿
|
|
53
|
+
if(aplayerItem.paused) {
|
|
54
|
+
VolantisApp.message('音乐通知', title + ' - ' + artist, {
|
|
55
|
+
icon: '<%- theme.plugins.message.aplayer.pause %>',
|
|
56
|
+
transitionIn: 'flipInX',
|
|
57
|
+
transitionOut: 'flipOutX'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, 100)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}, 500)
|
|
65
|
+
} catch (error) { console.error(error); }
|
|
66
|
+
<% } %>
|
|
67
|
+
}else{
|
|
68
|
+
volantis.requestAnimationFrame(SetAPlayerPlugin)
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
|
-
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
document.addEventListener("DOMContentLoaded", ()=>{
|
|
73
|
+
SetAPlayerPlugin();
|
|
74
|
+
});
|
|
75
|
+
volantis.pjax.push(SetAPlayerPlugin);
|
|
76
|
+
<% } else { %>
|
|
77
|
+
volantis.js("<%- theme.cdn.aplayer_js %>").then(()=>{
|
|
78
|
+
document.querySelectorAll('.aplayer-local').forEach(e=>{
|
|
79
|
+
new APlayer({
|
|
80
|
+
container: e,
|
|
81
|
+
fixed: <%- theme.plugins.aplayer.fixed %>,
|
|
82
|
+
order: "<%-theme.plugins.aplayer.order %>",
|
|
83
|
+
volume: "<%-theme.plugins.aplayer.volume %>",
|
|
84
|
+
autoplay: <%-theme.plugins.aplayer.autoplay %>,
|
|
85
|
+
loop: "<%-theme.plugins.aplayer.loop %>",
|
|
86
|
+
theme: "<%-theme.plugins.aplayer.theme %>",
|
|
87
|
+
listMaxHeight: "<%-theme.plugins.aplayer.list_max_height %>",
|
|
88
|
+
listFolded: "<%-theme.plugins.aplayer.list_folded %>",
|
|
89
|
+
preload: 'auto',
|
|
90
|
+
lrcType: 3,
|
|
91
|
+
audio: <%- JSON.stringify(theme.plugins.aplayer.audio) %>
|
|
92
|
+
});
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// post.music 迷你模式 pjax todo...
|
|
96
|
+
// document.querySelectorAll('.aplayer-local-min').forEach(e=>{
|
|
97
|
+
// // todo...
|
|
98
|
+
// })
|
|
99
|
+
// 右键 todo...
|
|
100
|
+
})
|
|
101
|
+
<% } %>
|
|
74
102
|
</script>
|
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
volantis.layoutHelper("comments",`<div id="artalk_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`);
|
|
3
3
|
function load_artalk() {
|
|
4
4
|
if(!document.querySelectorAll("#artalk_container")[0])return;
|
|
5
|
-
volantis.css("<%- theme.
|
|
6
|
-
|
|
5
|
+
volantis.css("<%- theme.cdn.artalk_css %>");
|
|
6
|
+
<% if (theme.comments.artalk.latex) { %>
|
|
7
|
+
volantis.css("<%- theme.cdn.katex_css %>");
|
|
8
|
+
volantis.js("<%- theme.cdn.katex_js %>");
|
|
9
|
+
volantis.js("<%- theme.cdn.artalk_js %>");
|
|
10
|
+
volantis.js("<%- theme.cdn.artalk_katex %>").then(pjax_artalk);
|
|
11
|
+
<% } else { %>
|
|
12
|
+
volantis.js("<%- theme.cdn.artalk_js %>").then(pjax_artalk);
|
|
13
|
+
<% } %>
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
function pjax_artalk() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
volantis.layoutHelper("comments",`<div id="discuss_container"></div>`)
|
|
3
3
|
function load_discuss() {
|
|
4
4
|
if(!document.querySelectorAll("#discuss_container")[0])return;
|
|
5
|
-
volantis.js("<%- theme.
|
|
5
|
+
volantis.js("<%- theme.cdn.discuss %>", pjax_discuss)
|
|
6
6
|
}
|
|
7
7
|
function pjax_discuss() {
|
|
8
8
|
if(!document.querySelectorAll("#discuss_container")[0])return;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
volantis.layoutHelper("comments",`<div id="disqus_thread"></div>`)
|
|
3
3
|
// from: https://github.com/ChrAlpha/hexo-theme-cards/blob/master/layout/_plugins/comments/disqusjs/source.ejs
|
|
4
4
|
function loadDisqusJS() {
|
|
5
|
-
volantis.js('<%= theme.
|
|
6
|
-
volantis.css('<%= theme.
|
|
5
|
+
volantis.js('<%= theme.cdn.disqusjs_js %>', pjax_DisqusJS)
|
|
6
|
+
volantis.css('<%= theme.cdn.disqusjs_css %>')
|
|
7
7
|
}
|
|
8
8
|
let path = pdata.commentPath;
|
|
9
9
|
if (path.length == 0) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
volantis.layoutHelper("comments",`<div id="twikoo_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
|
|
3
3
|
function load_twikoo() {
|
|
4
4
|
if(!document.querySelectorAll("#twikoo_container")[0])return;
|
|
5
|
-
volantis.js("<%- theme.
|
|
5
|
+
volantis.js("<%- theme.cdn.twikoo %>", pjax_twikoo)
|
|
6
6
|
}
|
|
7
7
|
function pjax_twikoo() {
|
|
8
8
|
if(!document.querySelectorAll("#twikoo_container")[0])return;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
<script src="<%- theme.
|
|
3
|
-
<script src="<%- theme.
|
|
2
|
+
<script src="<%- theme.cdn.vssue_vue %>"></script>
|
|
3
|
+
<script src="<%- theme.cdn.vssue_js %>"></script>
|
|
4
4
|
<script>
|
|
5
|
-
volantis.css("<%- theme.
|
|
5
|
+
volantis.css("<%- theme.cdn.vssue_css %>");
|
|
6
6
|
function fancybox_vssue() {
|
|
7
7
|
if(typeof VolantisFancyBox === "undefined") {
|
|
8
8
|
const checkFancyBox = setInterval(() => {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
volantis.css('<%= theme.
|
|
60
|
-
volantis.js('<%- theme.
|
|
59
|
+
volantis.css('<%= theme.cdn.waline_css %>')
|
|
60
|
+
volantis.js('<%- theme.cdn.waline_js %>').then(pjax_waline)
|
|
61
61
|
volantis.pjax.push(pjax_waline);
|
|
62
62
|
</script>
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
<% if (theme.plugins.sitesjs.enable) { %>
|
|
4
4
|
const sites_api = document.getElementById('sites-api');
|
|
5
5
|
if (sites_api != undefined && typeof SitesJS === 'undefined') {
|
|
6
|
-
volantis.js("<%- theme.cdn.
|
|
6
|
+
volantis.js("<%- theme.cdn.volantis_tags_sites %>")
|
|
7
7
|
}
|
|
8
8
|
<% } %>
|
|
9
9
|
<% if (theme.plugins.friendsjs.enable) { %>
|
|
10
10
|
const friends_api = document.getElementById('friends-api');
|
|
11
11
|
if (friends_api != undefined && typeof FriendsJS === 'undefined') {
|
|
12
|
-
volantis.js("<%- theme.cdn.
|
|
12
|
+
volantis.js("<%- theme.cdn.volantis_tags_friends %>")
|
|
13
13
|
}
|
|
14
14
|
<% } %>
|
|
15
15
|
<% if (theme.plugins.contributorsjs.enable) { %>
|
|
16
16
|
const contributors_api = document.getElementById('contributors-api');
|
|
17
17
|
if (contributors_api != undefined && typeof ContributorsJS === 'undefined') {
|
|
18
|
-
volantis.js("<%- theme.cdn.
|
|
18
|
+
volantis.js("<%- theme.cdn.volantis_tags_contributors %>")
|
|
19
19
|
}
|
|
20
20
|
<% } %>
|
|
21
21
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
volantis.css("<%- theme.cdn.pace_css %>");
|
|
3
|
+
volantis.js("<%- theme.cdn.pace_js %>").then(() => {
|
|
4
|
+
Pace.options.restartOnPushState = false;
|
|
5
|
+
volantis.pjax.send(Pace.restart);
|
|
6
|
+
// 阅读进度
|
|
7
|
+
volantis.scroll.push(() => {
|
|
8
|
+
Pace.stop();
|
|
9
|
+
Pace.trigger('start');
|
|
10
|
+
Pace.bar.update(volantis.scroll.progress() * 100);
|
|
11
|
+
document.body.className = document.body.className.replaceAll("pace-running ","");
|
|
12
|
+
},"阅读进度")
|
|
13
|
+
// todo:配置项开关, 哪些页面添加阅读进度
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
@@ -63,7 +63,7 @@ _%>
|
|
|
63
63
|
var runningOnBrowser = typeof window !== "undefined";
|
|
64
64
|
var isBot = runningOnBrowser && !("onscroll" in window) || typeof navigator !== "undefined" && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent);
|
|
65
65
|
if (!isBot) {
|
|
66
|
-
volantis.js('<%- theme.cdn.
|
|
66
|
+
volantis.js('<%- theme.cdn.volantis_parallax %>').then(()=>{
|
|
67
67
|
parallax()
|
|
68
68
|
})
|
|
69
69
|
volantis.pjax.send(()=>{
|
|
@@ -6,18 +6,47 @@
|
|
|
6
6
|
4. .pjax
|
|
7
7
|
-->
|
|
8
8
|
<%
|
|
9
|
-
var
|
|
9
|
+
var excludeList = theme.plugins.pjax.exclude || [];
|
|
10
10
|
%>
|
|
11
11
|
|
|
12
|
-
<%- js(theme.
|
|
13
|
-
<% if (theme.plugins.pjax.animation){ %>
|
|
14
|
-
<%- partial('animate') %>
|
|
15
|
-
<% } %>
|
|
12
|
+
<%- js(theme.cdn.pjax) %>
|
|
16
13
|
<script>
|
|
14
|
+
// 性能监控与降级控制
|
|
15
|
+
const performanceMonitor = {
|
|
16
|
+
slowThreshold: 800, // 慢请求阈值(毫秒)
|
|
17
|
+
slowCount: 0, // 连续慢请求计数
|
|
18
|
+
maxSlowAllowed: 2, // 允许的最大连续慢请求数
|
|
19
|
+
requestStartTime: 0, // 请求开始时间戳
|
|
20
|
+
|
|
21
|
+
// 记录请求开始时间
|
|
22
|
+
start() {
|
|
23
|
+
this.requestStartTime = Date.now();
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// 计算请求耗时并判断
|
|
27
|
+
check() {
|
|
28
|
+
const duration = Date.now() - this.requestStartTime;
|
|
29
|
+
|
|
30
|
+
if (duration > this.slowThreshold) {
|
|
31
|
+
this.slowCount++;
|
|
32
|
+
} else {
|
|
33
|
+
this.slowCount = 0; // 耗时正常,重置计数
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
// 测试结果
|
|
37
|
+
res(){
|
|
38
|
+
// 连续慢请求达到阈值,强制刷新
|
|
39
|
+
if (this.slowCount >= this.maxSlowAllowed) {
|
|
40
|
+
return true; // 需要降级
|
|
41
|
+
}
|
|
42
|
+
return false; // 无需降级
|
|
43
|
+
}
|
|
44
|
+
};
|
|
17
45
|
var pjax;
|
|
18
46
|
document.addEventListener('DOMContentLoaded', function () {
|
|
19
47
|
pjax = new Pjax({
|
|
20
48
|
elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox]):not([onclick="return false;"]):not([onclick="return!1"]):not([target="_blank"]):not([target="view_window"]):not([href$=".xml"])',
|
|
49
|
+
// 这里的 selectors 需要保证每个页面都含有相同的数目
|
|
21
50
|
selectors: [
|
|
22
51
|
"head title",
|
|
23
52
|
"head meta[name=keywords]",
|
|
@@ -27,7 +56,14 @@
|
|
|
27
56
|
"#pjax-header-nav-list",
|
|
28
57
|
".pjax",
|
|
29
58
|
"pjax", // <pjax></pjax> 标签
|
|
30
|
-
|
|
59
|
+
// 临时测试
|
|
60
|
+
"meta[name=robots]",
|
|
61
|
+
"link[rel=canonical]",
|
|
62
|
+
"meta[property='og:title']",
|
|
63
|
+
"meta[property='og:description']",
|
|
64
|
+
"meta[property='og:url']",
|
|
65
|
+
"meta[property='og:image']",
|
|
66
|
+
"script[type='application/ld+json']",
|
|
31
67
|
],
|
|
32
68
|
cacheBust: <%= theme.plugins.pjax.cacheBust %>, // url 地址追加时间戳,用以避免浏览器缓存
|
|
33
69
|
timeout: <%= theme.plugins.pjax.timeout %>,
|
|
@@ -36,19 +72,23 @@
|
|
|
36
72
|
});
|
|
37
73
|
|
|
38
74
|
document.addEventListener('pjax:send', function (e) {
|
|
39
|
-
|
|
75
|
+
window.stop(); // 相当于点击了浏览器的停止按钮
|
|
76
|
+
performanceMonitor.start(); // 请求开始计时
|
|
40
77
|
|
|
41
78
|
try {
|
|
42
79
|
var currentUrl = window.location.pathname;
|
|
43
80
|
var targetUrl = e.triggerElement.href;
|
|
44
|
-
var
|
|
45
|
-
if (
|
|
46
|
-
|
|
81
|
+
var excludeList = <%- '["' + excludeList.join('", "') + '"]' %>;
|
|
82
|
+
if (excludeList[0] != "") {
|
|
83
|
+
excludeList.forEach(item => {
|
|
47
84
|
if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
|
|
48
85
|
window.location.href = targetUrl;
|
|
49
86
|
}
|
|
50
87
|
});
|
|
51
88
|
}
|
|
89
|
+
if (performanceMonitor.res()){
|
|
90
|
+
window.location.href = targetUrl;
|
|
91
|
+
}
|
|
52
92
|
} catch (error) {}
|
|
53
93
|
|
|
54
94
|
// 使用 volantis.pjax.send 方法传入pjax:send回调函数 参见layout/_partial/scripts/global.ejs
|
|
@@ -56,12 +96,27 @@
|
|
|
56
96
|
});
|
|
57
97
|
|
|
58
98
|
document.addEventListener('pjax:complete', function () {
|
|
99
|
+
// 降级控制检测
|
|
100
|
+
performanceMonitor.check()
|
|
101
|
+
// 这里的 script 不需要保证每个页面都含有相同的数目
|
|
102
|
+
document.querySelectorAll('script[data-pjax], .pjax-reload script').forEach(e=>{
|
|
103
|
+
const code = e.text || e.textContent || e.innerHTML || '';
|
|
104
|
+
const script = document.createElement('script');
|
|
105
|
+
Object.keys(e.attributes).forEach(i=>{
|
|
106
|
+
script.setAttribute(e.attributes[i].nodeName,e.attributes[i].nodeValue)
|
|
107
|
+
})
|
|
108
|
+
if (code) {
|
|
109
|
+
script.appendChild(document.createTextNode(code));
|
|
110
|
+
}
|
|
111
|
+
e.parentNode.replaceChild(script, e);
|
|
112
|
+
});
|
|
113
|
+
|
|
59
114
|
// 使用 volantis.pjax.push 方法传入重载函数 参见layout/_partial/scripts/global.ejs
|
|
60
115
|
volantis.pjax.method.complete.start();
|
|
61
116
|
});
|
|
62
117
|
|
|
63
118
|
document.addEventListener('pjax:error', function (e) {
|
|
64
|
-
if(volantis.debug) {
|
|
119
|
+
if(volantis.debug === "pjax") {
|
|
65
120
|
console.error(e);
|
|
66
121
|
console.log('pjax error: \n' + JSON.stringify(e));
|
|
67
122
|
}else{
|
|
@@ -34,11 +34,11 @@ if (page && page.layout == 'post' && page.title) {
|
|
|
34
34
|
pdata.commentPath="<%=commentPath%>";
|
|
35
35
|
pdata.commentPlaceholder="<%=commentPlaceholder%>";
|
|
36
36
|
pdata.commentConfig=<%- JSON.stringify(commentConfig) %>;
|
|
37
|
-
// see: /layout/_partial/scripts/_ctrl
|
|
37
|
+
// see: /layout/_partial/scripts/_ctrl.ejs
|
|
38
38
|
<% if (theme.plugins.pjax.enable) {%>
|
|
39
39
|
// header
|
|
40
40
|
var l_header=document.getElementById("l_header");
|
|
41
|
-
<% if (theme.
|
|
41
|
+
<% if (theme.cover_ctrl.frontMatterCover == "none") {%>
|
|
42
42
|
l_header.classList.add("show");
|
|
43
43
|
<% } else {%>
|
|
44
44
|
l_header.classList.remove("show");
|
|
@@ -47,9 +47,9 @@ if (page && page.layout == 'post' && page.title) {
|
|
|
47
47
|
// cover
|
|
48
48
|
var cover_wrapper=document.querySelector('#l_cover .cover-wrapper');
|
|
49
49
|
var scroll_down=document.getElementById('scroll-down');
|
|
50
|
-
cover_wrapper.id="<%=theme.
|
|
51
|
-
cover_wrapper.style.display="<%=theme.
|
|
52
|
-
scroll_down.style.display="<%=theme.
|
|
50
|
+
cover_wrapper.id="<%=theme.cover_ctrl.frontMatterCover%>";
|
|
51
|
+
cover_wrapper.style.display="<%=theme.cover_ctrl.coverWrapperDisplay%>";
|
|
52
|
+
scroll_down.style.display="<%=theme.cover_ctrl.scrollDownDisplay%>";
|
|
53
53
|
<% }%>
|
|
54
54
|
<% }%>
|
|
55
55
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<% let preload = theme.plugins.preload; %>
|
|
2
2
|
<% if (preload.service == 'instant_page') { %>
|
|
3
|
-
<script async src="<%-
|
|
3
|
+
<script async src="<%- theme.cdn.instant_page %>" type="module" defer integrity="sha384-OeDn4XE77tdHo8pGtE1apMPmAipjoxUQ++eeJa6EtJCfHlvijigWiJpD7VDPWXV1"></script>
|
|
4
4
|
<% } else if (preload.service == 'flying_pages') { %>
|
|
5
5
|
<script>
|
|
6
6
|
window.FPConfig = {
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
hoverDelay: 0
|
|
11
11
|
};
|
|
12
12
|
</script>
|
|
13
|
-
<script defer src="<%-
|
|
13
|
+
<script defer src="<%- theme.cdn['flying-pages'] %>"></script>
|
|
14
14
|
<% } %>
|
|
@@ -100,13 +100,13 @@
|
|
|
100
100
|
<p class='nav music-title fix-cursor-default'></p>
|
|
101
101
|
</li>
|
|
102
102
|
<li class='music ctrl'>
|
|
103
|
-
<a class='nav icon-only backward fix-cursor-default'
|
|
103
|
+
<a class='nav icon-only backward fix-cursor-default' title="backward">
|
|
104
104
|
<i class='<%= theme.rightmenus.options.iconPrefix %> fa-step-backward fa-fw'></i>
|
|
105
105
|
</a>
|
|
106
|
-
<a class='nav icon-only toggle fix-cursor-default'
|
|
106
|
+
<a class='nav icon-only toggle fix-cursor-default' title="toggle">
|
|
107
107
|
<i class='<%= theme.rightmenus.options.iconPrefix %> fa-play fa-fw'></i>
|
|
108
108
|
</a>
|
|
109
|
-
<a class='nav icon-only forward fix-cursor-default'
|
|
109
|
+
<a class='nav icon-only forward fix-cursor-default' title="forward">
|
|
110
110
|
<i class='<%= theme.rightmenus.options.iconPrefix %> fa-step-forward fa-fw'></i>
|
|
111
111
|
</a>
|
|
112
112
|
</li>
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
<% rightMenu.initMenu() %>
|
|
131
131
|
</ul>
|
|
132
132
|
</div>
|
|
133
|
-
<script src="<%- theme.cdn.
|
|
133
|
+
<script src="<%- theme.cdn.volantis_rightMenus %>"></script>
|
|
134
134
|
<script>
|
|
135
135
|
const RightMenusFunction = {};
|
|
136
136
|
<% rightMenu.initFunction() %>
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
pjax_scrollrebeal();
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
volantis.js("<%- theme.
|
|
19
|
-
document.addEventListener("DOMContentLoaded", init_scrollrebeal)
|
|
18
|
+
volantis.js("<%- theme.cdn.scrollreveal %>");
|
|
19
|
+
document.addEventListener("DOMContentLoaded", init_scrollrebeal)
|
|
20
20
|
volantis.pjax.push(
|
|
21
21
|
pjax_scrollrebeal,
|
|
22
22
|
"pjax_scrollrebeal",
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
async function loadSearchScript() {
|
|
3
|
+
<% if(theme.search.service === 'algolia') { %>
|
|
4
|
+
await volantis.js("<%- theme.cdn.algolia_search_v4 %>")
|
|
5
|
+
await volantis.js("<%- theme.cdn.instantsearch_v4 %>")
|
|
6
|
+
<% } %>
|
|
7
|
+
|
|
8
|
+
<% if(theme.search.service === 'meilisearch') { %>
|
|
9
|
+
await volantis.js("<%- theme.cdn.instantsearch_v4 %>")
|
|
10
|
+
await volantis.js("<%- theme.cdn.instant_meilisearch %>")
|
|
11
|
+
<% } %>
|
|
12
|
+
return volantis.js("<%- theme.cdn['volantis_search_' + theme.search.service] %>");
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
function loadSearchService() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
function load_swiper() {
|
|
3
3
|
if (!document.querySelectorAll(".swiper-container")[0]) return;
|
|
4
|
-
volantis.css("<%- theme.
|
|
5
|
-
volantis.js("<%- theme.
|
|
4
|
+
volantis.css("<%- theme.cdn.swiper_css %>");
|
|
5
|
+
volantis.js("<%- theme.cdn.swiper_js %>").then(() => {
|
|
6
6
|
pjax_swiper();
|
|
7
7
|
});
|
|
8
8
|
}
|