hexo-theme-shokax 0.3.14 → 0.3.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/scripts/filters/locals.js +52 -0
  3. package/scripts/filters/post.js +5 -0
  4. package/scripts/generaters/archive.js +133 -0
  5. package/scripts/generaters/config.js +48 -0
  6. package/scripts/generaters/images.js +23 -0
  7. package/scripts/generaters/index.js +107 -0
  8. package/scripts/generaters/pages.js +15 -0
  9. package/scripts/generaters/script.js +118 -0
  10. package/scripts/helpers/asset.js +147 -0
  11. package/scripts/helpers/engine.js +153 -0
  12. package/scripts/helpers/list_categories.js +84 -0
  13. package/scripts/helpers/summary_ai.js +107 -0
  14. package/scripts/helpers/symbols_count_time.js +69 -0
  15. package/scripts/plugin/check.js +32 -0
  16. package/scripts/plugin/index.js +78 -0
  17. package/scripts/plugin/lib/injects-point.js +20 -0
  18. package/scripts/plugin/lib/injects.js +89 -0
  19. package/scripts/tags/links.js +44 -0
  20. package/scripts/tags/media.js +19 -0
  21. package/scripts/utils.js +14 -0
  22. package/source/js/_app/components/sidebar.js +209 -0
  23. package/source/js/_app/fireworks.js +10 -0
  24. package/source/js/_app/globals/globalVars.js +80 -0
  25. package/source/js/_app/globals/handles.js +98 -0
  26. package/source/js/_app/globals/themeColor.js +62 -0
  27. package/source/js/_app/globals/thirdparty.js +62 -0
  28. package/source/js/_app/globals/tools.js +66 -0
  29. package/source/js/_app/library/anime.js +106 -0
  30. package/source/js/_app/library/dom.js +34 -0
  31. package/source/js/_app/library/loadFile.js +36 -0
  32. package/source/js/_app/library/proto.js +163 -0
  33. package/source/js/_app/library/scriptPjax.js +70 -0
  34. package/source/js/_app/library/storage.js +12 -0
  35. package/source/js/_app/library/vue.js +53 -0
  36. package/source/js/_app/page/comment.js +23 -0
  37. package/source/js/_app/page/common.js +41 -0
  38. package/source/js/_app/page/fancybox.js +65 -0
  39. package/source/js/_app/page/post.js +244 -0
  40. package/source/js/_app/page/search.js +118 -0
  41. package/source/js/_app/page/tab.js +53 -0
  42. package/source/js/_app/pjax/domInit.js +76 -0
  43. package/source/js/_app/pjax/refresh.js +52 -0
  44. package/source/js/_app/pjax/siteInit.js +51 -0
  45. package/source/js/_app/player.js +771 -0
@@ -0,0 +1,244 @@
1
+ import loadComments from './comment';
2
+ import { $dom } from '../library/dom';
3
+ import { postFancybox } from './fancybox';
4
+ import { clipBoard, showtip } from '../globals/tools';
5
+ import { BODY } from '../globals/globalVars';
6
+ import { pageScroll, transition } from '../library/anime';
7
+ import { mediaPlayer } from '../player';
8
+ export const postBeauty = () => {
9
+ loadComments();
10
+ if (!$dom('.md')) {
11
+ return;
12
+ }
13
+ postFancybox('.post.block');
14
+ $dom('.post.block').oncopy = async (event) => {
15
+ showtip(LOCAL.copyright);
16
+ if (LOCAL.nocopy) {
17
+ event.preventDefault();
18
+ return;
19
+ }
20
+ const copyright = await $dom.asyncify('#copyright');
21
+ if (window.getSelection().toString().length > 30 && copyright) {
22
+ event.preventDefault();
23
+ const author = '# ' + copyright.child('.author').innerText;
24
+ const link = '# ' + copyright.child('.link').innerText;
25
+ const license = '# ' + copyright.child('.license').innerText;
26
+ const htmlData = author + '<br>' + link + '<br>' + license + '<br><br>' + window.getSelection().toString().replace(/\r\n/g, '<br>');
27
+ const textData = author + '\n' + link + '\n' + license + '\n\n' + window.getSelection().toString().replace(/\r\n/g, '\n');
28
+ if (event.clipboardData) {
29
+ event.clipboardData.setData('text/html', htmlData);
30
+ event.clipboardData.setData('text/plain', textData);
31
+ }
32
+ else {
33
+ // @ts-ignore
34
+ if (window.clipboardData) {
35
+ // @ts-ignore
36
+ return window.clipboardData.setData('text', textData);
37
+ }
38
+ }
39
+ }
40
+ };
41
+ $dom.each('li ruby', (element) => {
42
+ let parent = element.parentNode;
43
+ // @ts-ignore
44
+ if (element.parentNode.tagName !== 'LI') {
45
+ parent = element.parentNode.parentNode;
46
+ }
47
+ parent.addClass('ruby');
48
+ });
49
+ $dom.each('ol[start]', (element) => {
50
+ // @ts-ignore
51
+ element.style.counterReset = 'counter ' + parseInt(element.attr('start') - 1);
52
+ });
53
+ $dom.each('.md table', (element) => {
54
+ element.wrapObject({
55
+ className: 'table-container'
56
+ });
57
+ });
58
+ $dom.each('.highlight > .table-container', (element) => {
59
+ element.className = 'code-container';
60
+ });
61
+ $dom.each('figure.highlight', (element) => {
62
+ const code_container = element.child('.code-container');
63
+ const caption = element.child('figcaption');
64
+ element.insertAdjacentHTML('beforeend', '<div class="operation"><span class="breakline-btn"><i class="ic i-align-left"></i></span><span class="copy-btn"><i class="ic i-clipboard"></i></span><span class="fullscreen-btn"><i class="ic i-expand"></i></span></div>');
65
+ const copyBtn = element.child('.copy-btn');
66
+ if (LOCAL.nocopy) {
67
+ copyBtn.remove();
68
+ }
69
+ else {
70
+ copyBtn.addEventListener('click', (event) => {
71
+ const target = event.currentTarget;
72
+ let comma = '';
73
+ let code = '';
74
+ code_container.find('pre').forEach((line) => {
75
+ code += comma + line.innerText;
76
+ comma = '\n';
77
+ });
78
+ clipBoard(code, (result) => {
79
+ target.child('.ic').className = result ? 'ic i-check' : 'ic i-times';
80
+ target.blur();
81
+ showtip(LOCAL.copyright);
82
+ });
83
+ }, { passive: true });
84
+ copyBtn.addEventListener('mouseleave', (event) => {
85
+ setTimeout(() => {
86
+ event.target.child('.ic').className = 'ic i-clipboard';
87
+ }, 1000);
88
+ });
89
+ }
90
+ const breakBtn = element.child('.breakline-btn');
91
+ breakBtn.addEventListener('click', (event) => {
92
+ const target = event.currentTarget;
93
+ if (element.hasClass('breakline')) {
94
+ element.removeClass('breakline');
95
+ target.child('.ic').className = 'ic i-align-left';
96
+ }
97
+ else {
98
+ element.addClass('breakline');
99
+ target.child('.ic').className = 'ic i-align-justify';
100
+ }
101
+ });
102
+ const fullscreenBtn = element.child('.fullscreen-btn');
103
+ const removeFullscreen = () => {
104
+ element.removeClass('fullscreen');
105
+ element.scrollTop = 0;
106
+ BODY.removeClass('fullscreen');
107
+ fullscreenBtn.child('.ic').className = 'ic i-expand';
108
+ };
109
+ const fullscreenHandle = () => {
110
+ if (element.hasClass('fullscreen')) {
111
+ removeFullscreen();
112
+ if (code_container && code_container.find('tr').length > 15) {
113
+ const showBtn = code_container.child('.show-btn');
114
+ code_container.style.maxHeight = '300px';
115
+ showBtn.removeClass('open');
116
+ }
117
+ pageScroll(element);
118
+ }
119
+ else {
120
+ element.addClass('fullscreen');
121
+ BODY.addClass('fullscreen');
122
+ fullscreenBtn.child('.ic').className = 'ic i-compress';
123
+ if (code_container && code_container.find('tr').length > 15) {
124
+ const showBtn = code_container.child('.show-btn');
125
+ code_container.style.maxHeight = '';
126
+ showBtn.addClass('open');
127
+ }
128
+ }
129
+ };
130
+ fullscreenBtn.addEventListener('click', fullscreenHandle);
131
+ caption && caption.addEventListener('click', fullscreenHandle);
132
+ if (code_container && code_container.find('tr').length > 15) {
133
+ code_container.style.maxHeight = '300px';
134
+ code_container.insertAdjacentHTML('beforeend', '<div class="show-btn"><i class="ic i-angle-down"></i></div>');
135
+ const showBtn = code_container.child('.show-btn');
136
+ const hideCode = () => {
137
+ code_container.style.maxHeight = '300px';
138
+ showBtn.removeClass('open');
139
+ };
140
+ const showCode = () => {
141
+ code_container.style.maxHeight = '';
142
+ showBtn.addClass('open');
143
+ };
144
+ showBtn.addEventListener('click', () => {
145
+ if (showBtn.hasClass('open')) {
146
+ removeFullscreen();
147
+ hideCode();
148
+ pageScroll(code_container);
149
+ }
150
+ else {
151
+ showCode();
152
+ }
153
+ });
154
+ }
155
+ });
156
+ $dom.asyncifyEach('pre.mermaid > svg', (element) => {
157
+ const temp = element;
158
+ temp.style.maxWidth = '';
159
+ });
160
+ $dom.each('.reward button', (element) => {
161
+ element.addEventListener('click', (event) => {
162
+ event.preventDefault();
163
+ const qr = $dom('#qr');
164
+ if (qr.display() === 'inline-flex') {
165
+ transition(qr, 0);
166
+ }
167
+ else {
168
+ transition(qr, 1, () => {
169
+ qr.display('inline-flex');
170
+ }); // slideUpBigIn
171
+ }
172
+ });
173
+ });
174
+ // quiz
175
+ $dom.asyncifyEach('.quiz > ul.options li', (element) => {
176
+ element.addEventListener('click', () => {
177
+ if (element.hasClass('correct')) {
178
+ element.toggleClass('right');
179
+ element.parentNode.parentNode.addClass('show');
180
+ }
181
+ else {
182
+ element.toggleClass('wrong');
183
+ }
184
+ });
185
+ });
186
+ $dom.asyncifyEach('.quiz > p', (element) => {
187
+ element.addEventListener('click', () => {
188
+ element.parentNode.toggleClass('show');
189
+ });
190
+ });
191
+ $dom.asyncifyEach('.quiz > p:first-child', (element) => {
192
+ const quiz = element.parentNode;
193
+ let type = 'choice';
194
+ if (quiz.hasClass('true') || quiz.hasClass('false')) {
195
+ type = 'true_false';
196
+ }
197
+ if (quiz.hasClass('multi')) {
198
+ type = 'multiple';
199
+ }
200
+ if (quiz.hasClass('fill')) {
201
+ type = 'gap_fill';
202
+ }
203
+ if (quiz.hasClass('essay')) {
204
+ type = 'essay';
205
+ }
206
+ element.attr('data-type', LOCAL.quiz[type]);
207
+ });
208
+ $dom.asyncifyEach('.quiz .mistake', (element) => {
209
+ element.attr('data-type', LOCAL.quiz.mistake);
210
+ });
211
+ $dom.each('div.tags a', (element) => {
212
+ element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)];
213
+ });
214
+ $dom.asyncifyEach('.md div.player', (element) => {
215
+ mediaPlayer(element, {
216
+ type: element.attr('data-type'),
217
+ mode: 'order',
218
+ btns: []
219
+ }).player.load(JSON.parse(element.attr('data-src'))).fetch();
220
+ });
221
+ const angleDown = document.querySelectorAll('.show-btn .i-angle-down');
222
+ if (angleDown.length) {
223
+ const io = new IntersectionObserver((entries) => {
224
+ entries.forEach(entry => {
225
+ if (entry.isIntersecting) {
226
+ angleDown.forEach(i => {
227
+ i.classList.remove('stop-animation');
228
+ });
229
+ }
230
+ else {
231
+ angleDown.forEach(i => {
232
+ i.classList.add('stop-animation');
233
+ });
234
+ }
235
+ });
236
+ }, {
237
+ root: null,
238
+ threshold: 0.5
239
+ });
240
+ angleDown.forEach(i => {
241
+ io.observe(i);
242
+ });
243
+ }
244
+ };
@@ -0,0 +1,118 @@
1
+ import { BODY, setSiteSearch, siteSearch } from '../globals/globalVars';
2
+ import { transition } from '../library/anime';
3
+ import { $dom } from '../library/dom';
4
+ export function algoliaSearch(pjax) {
5
+ if (CONFIG.search === null) {
6
+ return;
7
+ }
8
+ if (!siteSearch) {
9
+ setSiteSearch(BODY.createChild('div', {
10
+ id: 'search',
11
+ innerHTML: '<div class="inner"><div class="header"><span class="icon"><i class="ic i-search"></i></span><div class="search-input-container"></div><span class="close-btn"><i class="ic i-times-circle"></i></span></div><div class="results"><div class="inner"><div id="search-stats"></div><div id="search-hits"></div><div id="search-pagination"></div></div></div></div>'
12
+ }));
13
+ }
14
+ const search = instantsearch({
15
+ indexName: CONFIG.search.indexName,
16
+ searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
17
+ searchFunction(helper) {
18
+ const searchInput = $dom('.search-input');
19
+ if (searchInput.value) {
20
+ helper.search();
21
+ }
22
+ }
23
+ });
24
+ search.on('render', () => {
25
+ pjax.refresh($dom('#search-hits'));
26
+ });
27
+ // Registering Widgets
28
+ search.addWidgets([
29
+ instantsearch.widgets.configure({
30
+ hitsPerPage: CONFIG.search.hits.per_page || 10
31
+ }),
32
+ instantsearch.widgets.searchBox({
33
+ container: '.search-input-container',
34
+ placeholder: LOCAL.search.placeholder,
35
+ // Hide default icons of algolia search
36
+ showReset: false,
37
+ showSubmit: false,
38
+ showLoadingIndicator: false,
39
+ cssClasses: {
40
+ input: 'search-input'
41
+ }
42
+ }),
43
+ instantsearch.widgets.stats({
44
+ container: '#search-stats',
45
+ templates: {
46
+ text(data) {
47
+ const stats = LOCAL.search.stats
48
+ .replace(/\$\{hits}/, data.nbHits)
49
+ .replace(/\$\{time}/, data.processingTimeMS);
50
+ return stats + '<span class="algolia-powered"></span><hr>';
51
+ }
52
+ }
53
+ }),
54
+ instantsearch.widgets.hits({
55
+ container: '#search-hits',
56
+ templates: {
57
+ item(data) {
58
+ const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : '';
59
+ return '<a href="' + CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>';
60
+ },
61
+ empty(data) {
62
+ return '<div id="hits-empty">' +
63
+ LOCAL.search.empty.replace(/\$\{query}/, data.query) +
64
+ '</div>';
65
+ }
66
+ },
67
+ cssClasses: {
68
+ item: 'item'
69
+ }
70
+ }),
71
+ instantsearch.widgets.pagination({
72
+ container: '#search-pagination',
73
+ scrollTo: false,
74
+ showFirst: false,
75
+ showLast: false,
76
+ templates: {
77
+ first: '<i class="ic i-angle-double-left"></i>',
78
+ last: '<i class="ic i-angle-double-right"></i>',
79
+ previous: '<i class="ic i-angle-left"></i>',
80
+ next: '<i class="ic i-angle-right"></i>'
81
+ },
82
+ cssClasses: {
83
+ root: 'pagination',
84
+ item: 'pagination-item',
85
+ link: 'page-number',
86
+ selectedItem: 'current',
87
+ disabledItem: 'disabled-item'
88
+ }
89
+ })
90
+ ]);
91
+ search.start();
92
+ // Handle and trigger popup window
93
+ $dom.each('.search', (element) => {
94
+ element.addEventListener('click', () => {
95
+ document.body.style.overflow = 'hidden';
96
+ transition(siteSearch, 'shrinkIn', () => {
97
+ $dom('.search-input').focus();
98
+ }); // transition.shrinkIn
99
+ });
100
+ });
101
+ // Monitor main search box
102
+ const onPopupClose = () => {
103
+ document.body.style.overflow = '';
104
+ transition(siteSearch, 0); // "transition.shrinkOut"
105
+ };
106
+ siteSearch.addEventListener('click', (event) => {
107
+ if (event.target === siteSearch) {
108
+ onPopupClose();
109
+ }
110
+ });
111
+ $dom('.close-btn').addEventListener('click', onPopupClose);
112
+ window.addEventListener('pjax:success', onPopupClose);
113
+ window.addEventListener('keyup', (event) => {
114
+ if (event.key === 'Escape') {
115
+ onPopupClose();
116
+ }
117
+ });
118
+ }
@@ -0,0 +1,53 @@
1
+ import { pageScroll } from '../library/anime';
2
+ import { $dom } from '../library/dom';
3
+ export const tabFormat = () => {
4
+ // tab
5
+ let first_tab;
6
+ $dom.each('div.tab', (element) => {
7
+ if (element.attr('data-ready')) {
8
+ return;
9
+ }
10
+ const id = element.attr('data-id');
11
+ const title = element.attr('data-title');
12
+ let box = $dom('#' + id);
13
+ if (!box) {
14
+ box = document.createElement('div');
15
+ box.className = 'tabs';
16
+ box.id = id;
17
+ box.innerHTML = '<div class="show-btn"></div>';
18
+ const showBtn = box.child('.show-btn');
19
+ showBtn.addEventListener('click', () => {
20
+ pageScroll(box);
21
+ });
22
+ element.parentNode.insertBefore(box, element);
23
+ first_tab = true;
24
+ }
25
+ else {
26
+ first_tab = false;
27
+ }
28
+ let ul = box.child('.nav ul');
29
+ if (!ul) {
30
+ ul = box.createChild('div', {
31
+ className: 'nav',
32
+ innerHTML: '<ul></ul>'
33
+ }).child('ul');
34
+ }
35
+ const li = ul.createChild('li', {
36
+ innerHTML: title
37
+ });
38
+ if (first_tab) {
39
+ li.addClass('active');
40
+ element.addClass('active');
41
+ }
42
+ li.addEventListener('click', (event) => {
43
+ const target = event.currentTarget;
44
+ box.find('.active').forEach((el) => {
45
+ el.removeClass('active');
46
+ });
47
+ element.addClass('active');
48
+ target.addClass('active');
49
+ });
50
+ box.appendChild(element);
51
+ element.attr('data-ready', String(true));
52
+ });
53
+ };
@@ -0,0 +1,76 @@
1
+ import { backToTopHandle, goToBottomHandle, goToCommentHandle, sideBarToggleHandle } from '../components/sidebar';
2
+ import { backToTop, goToComment, loadCat, menuToggle, quickBtn, setBackToTop, setGoToComment, setShowContents, setToolBtn, setToolPlayer, showContents, siteHeader, siteNav, toolBtn, toolPlayer } from '../globals/globalVars';
3
+ import { Loader } from '../globals/thirdparty';
4
+ import { $dom } from '../library/dom';
5
+ import { mediaPlayer } from '../player';
6
+ export default function domInit() {
7
+ $dom.each('.overview .menu > .item', (el) => {
8
+ siteNav.child('.menu').appendChild(el.cloneNode(true));
9
+ });
10
+ loadCat.addEventListener('click', Loader.vanish);
11
+ menuToggle.addEventListener('click', sideBarToggleHandle);
12
+ $dom('.dimmer').addEventListener('click', sideBarToggleHandle);
13
+ quickBtn.child('.down').addEventListener('click', goToBottomHandle);
14
+ quickBtn.child('.up').addEventListener('click', backToTopHandle);
15
+ if (!toolBtn) {
16
+ setToolBtn(siteHeader.createChild('div', {
17
+ id: 'tool',
18
+ innerHTML: '<div class="item player"></div><div class="item contents"><i class="ic i-list-ol"></i></div><div class="item chat"><i class="ic i-comments"></i></div><div class="item back-to-top"><i class="ic i-arrow-up"></i><span>0%</span></div>'
19
+ }));
20
+ }
21
+ setToolPlayer(toolBtn.child('.player'));
22
+ setBackToTop(toolBtn.child('.back-to-top'));
23
+ setGoToComment(toolBtn.child('.chat'));
24
+ setShowContents(toolBtn.child('.contents'));
25
+ backToTop.addEventListener('click', backToTopHandle);
26
+ goToComment.addEventListener('click', goToCommentHandle);
27
+ showContents.addEventListener('click', sideBarToggleHandle);
28
+ if (typeof mediaPlayer !== 'undefined' && !CONFIG.noPlayer) {
29
+ /* @__PURE__ */ mediaPlayer(toolPlayer);
30
+ $dom('main').addEventListener('click', () => {
31
+ toolPlayer.player.mini();
32
+ });
33
+ }
34
+ const createIntersectionObserver = () => {
35
+ // waves在视口外时停止动画
36
+ new IntersectionObserver(([entry]) => {
37
+ if (entry.isIntersecting) {
38
+ document.querySelectorAll('.parallax>use').forEach(i => {
39
+ i.classList.remove('stop-animation');
40
+ });
41
+ document.querySelectorAll('#imgs .item').forEach(i => {
42
+ i.classList.remove('stop-animation');
43
+ });
44
+ }
45
+ else {
46
+ document.querySelectorAll('.parallax>use').forEach(i => {
47
+ i.classList.add('stop-animation');
48
+ });
49
+ // waves不可见时imgs也应该不可见了
50
+ document.querySelectorAll('#imgs .item').forEach(i => {
51
+ i.classList.add('stop-animation');
52
+ });
53
+ }
54
+ }, {
55
+ root: null,
56
+ threshold: 0.2
57
+ }).observe(document.getElementById('waves'));
58
+ // sakura在视口外时停止动画
59
+ new IntersectionObserver(([entry]) => {
60
+ if (entry.isIntersecting) {
61
+ document.querySelectorAll('.with-love>i').forEach(i => {
62
+ i.classList.remove('stop-animation');
63
+ });
64
+ }
65
+ else {
66
+ document.querySelectorAll('.with-love>i').forEach(i => {
67
+ i.classList.add('stop-animation');
68
+ });
69
+ }
70
+ }, {
71
+ root: null,
72
+ threshold: 0.2
73
+ }).observe(document.querySelector('.with-love'));
74
+ };
75
+ createIntersectionObserver();
76
+ }
@@ -0,0 +1,52 @@
1
+ import { $dom } from '../library/dom';
2
+ import { cardActive } from '../page/common';
3
+ import { postBeauty } from '../page/post';
4
+ import { pageScroll, transition } from '../library/anime';
5
+ import { vendorCss, vendorJs } from '../library/loadFile';
6
+ import { pjaxScript } from '../library/scriptPjax';
7
+ import { resizeHandle } from '../globals/handles';
8
+ import { loadCat, menuToggle, setLocalHash, setLocalUrl, setOriginTitle, sideBar, toolPlayer } from '../globals/globalVars';
9
+ import { mediaPlayer } from '../player';
10
+ import { pagePosition, positionInit } from '../globals/tools';
11
+ import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar';
12
+ import { Loader, isOutime } from '../globals/thirdparty';
13
+ import { tabFormat } from '../page/tab';
14
+ export const pjaxReload = () => {
15
+ pagePosition();
16
+ if (sideBar.hasClass('on')) {
17
+ transition(sideBar, 0, () => {
18
+ sideBar.removeClass('on');
19
+ menuToggle.removeClass('close');
20
+ }); // 'transition.slideRightOut'
21
+ }
22
+ const mainNode = $dom('#main');
23
+ mainNode.innerHTML = '';
24
+ mainNode.appendChild(loadCat.lastChild.cloneNode(true));
25
+ pageScroll(0);
26
+ };
27
+ export const siteRefresh = (reload) => {
28
+ setLocalHash(0);
29
+ setLocalUrl(window.location.href);
30
+ vendorCss('katex');
31
+ vendorJs('copy_tex');
32
+ vendorCss('mermaid');
33
+ if (reload !== 1) {
34
+ $dom.each('script[data-pjax]', pjaxScript);
35
+ }
36
+ setOriginTitle(document.title);
37
+ resizeHandle();
38
+ menuActive();
39
+ sideBarTab();
40
+ sidebarTOC();
41
+ postBeauty();
42
+ tabFormat();
43
+ if (typeof mediaPlayer !== 'undefined' && !CONFIG.noPlayer) {
44
+ toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {});
45
+ }
46
+ Loader.hide();
47
+ setTimeout(() => {
48
+ positionInit();
49
+ }, 500);
50
+ cardActive();
51
+ isOutime();
52
+ };
@@ -0,0 +1,51 @@
1
+ import domInit from './domInit';
2
+ import { pjaxReload, siteRefresh } from './refresh';
3
+ import { cloudflareInit } from '../library/scriptPjax';
4
+ import { algoliaSearch } from '../page/search';
5
+ import { pjax, setPjax } from '../globals/globalVars';
6
+ import { autoDarkmode, themeColorListener } from '../globals/themeColor';
7
+ import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles';
8
+ import { pagePosition } from '../globals/tools';
9
+ import { initFireworks } from '../fireworks';
10
+ import Pjax from 'theme-shokax-pjax';
11
+ import { initVue } from '../library/vue';
12
+ import { lazyLoad } from 'unlazy';
13
+ const siteInit = () => {
14
+ domInit();
15
+ initVue();
16
+ setPjax(new Pjax({
17
+ selectors: [
18
+ 'head title',
19
+ '.languages',
20
+ '.twikoo',
21
+ '.pjax',
22
+ '.leancloud-recent-comment',
23
+ 'script[data-config]'
24
+ ],
25
+ cacheBust: false
26
+ }));
27
+ CONFIG.quicklink.ignores = LOCAL.ignores;
28
+ quicklink.listen(CONFIG.quicklink);
29
+ autoDarkmode();
30
+ if (!CONFIG.disableVL) {
31
+ visibilityListener();
32
+ }
33
+ themeColorListener();
34
+ algoliaSearch(pjax);
35
+ initFireworks();
36
+ lazyLoad();
37
+ window.addEventListener('scroll', scrollHandle);
38
+ window.addEventListener('resize', resizeHandle);
39
+ window.addEventListener('pjax:send', pjaxReload);
40
+ window.addEventListener('pjax:success', siteRefresh); // 默认会传入一个event参数
41
+ window.addEventListener('beforeunload', () => {
42
+ pagePosition();
43
+ });
44
+ // clickMenu() TODO 暂时禁用
45
+ siteRefresh(1);
46
+ };
47
+ cloudflareInit();
48
+ window.addEventListener('DOMContentLoaded', siteInit, {
49
+ passive: true
50
+ });
51
+ console.log('%c Theme.ShokaX v' + CONFIG.version + ' %c https://github.com/theme-shoka-x/hexo-theme-shokaX ', 'color: white; background: #e9546b; padding:5px 0;', 'padding:4px;border:1px solid #e9546b;');