hexo-theme-shokax 0.4.24 → 0.5.0-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +19 -31
  2. package/UsageRestrictions.md +2 -2
  3. package/_config.yml +11 -25
  4. package/_images.yml +0 -7
  5. package/eslint.config.mjs +4 -5
  6. package/layout/_mixin/card.pug +1 -2
  7. package/layout/_mixin/comment.pug +0 -1
  8. package/layout/_mixin/segment.pug +1 -1
  9. package/layout/_partials/footer.pug +1 -4
  10. package/layout/_partials/head/head.pug +0 -8
  11. package/layout/_partials/head/pwa.pug +1 -1
  12. package/layout/_partials/header.pug +0 -1
  13. package/layout/_partials/layout.pug +4 -14
  14. package/layout/_partials/post/footer.pug +0 -2
  15. package/layout/_partials/post/post.pug +1 -2
  16. package/layout/_partials/post/reward.pug +1 -1
  17. package/layout/_partials/sidebar/overview.pug +0 -2
  18. package/layout/_partials/third-party/baidu-analytics.pug +1 -1
  19. package/layout/_partials/third-party/google-analytics.pug +1 -1
  20. package/layout/archive.pug +3 -0
  21. package/layout/category.pug +3 -0
  22. package/layout/index.pug +3 -0
  23. package/layout/page.pug +7 -0
  24. package/layout/post.pug +8 -0
  25. package/layout/tag.pug +3 -0
  26. package/package.json +9 -10
  27. package/scripts/filters/post.js +1 -1
  28. package/scripts/generaters/config.js +12 -7
  29. package/scripts/generaters/images.js +9 -8
  30. package/scripts/generaters/index.js +57 -44
  31. package/scripts/generaters/script.js +18 -33
  32. package/scripts/generaters/summary_ai.js +6 -7
  33. package/scripts/helpers/engine.js +2 -7
  34. package/scripts/plugin/index.js +32 -69
  35. package/scripts/tags/media.js +1 -1
  36. package/source/css/_common/outline/sidebar/sidebar.styl +1 -0
  37. package/source/css/app.styl +0 -13
  38. package/source/css/page.styl +3 -0
  39. package/source/css/post.styl +5 -0
  40. package/source/css/scaffolding.styl +5 -0
  41. package/source/js/_app/components/comments.ts +2 -3
  42. package/source/js/_app/components/sidebar.ts +35 -35
  43. package/source/js/_app/components/tcomments.ts +0 -1
  44. package/source/js/_app/globals/globalVars.ts +0 -15
  45. package/source/js/_app/globals/handles.ts +9 -9
  46. package/source/js/_app/globals/themeColor.ts +5 -6
  47. package/source/js/_app/globals/thirdparty.ts +2 -2
  48. package/source/js/_app/globals/tools.ts +4 -6
  49. package/source/js/_app/library/anime.ts +30 -19
  50. package/source/js/_app/library/declare.d.ts +0 -5
  51. package/source/js/_app/library/proto.ts +0 -67
  52. package/source/js/_app/library/vue.ts +7 -7
  53. package/source/js/_app/page/common.ts +8 -10
  54. package/source/js/_app/page/fancybox.ts +6 -8
  55. package/source/js/_app/page/post.ts +42 -54
  56. package/source/js/_app/page/search.ts +1 -6
  57. package/source/js/_app/page/tab.ts +8 -9
  58. package/source/js/_app/pjax/domInit.ts +19 -14
  59. package/source/js/_app/pjax/refresh.ts +8 -36
  60. package/source/js/_app/pjax/siteInit.ts +13 -42
  61. package/source/js/_app/player.ts +14 -798
  62. package/toolbox/compiler.mjs +20 -48
  63. package/toolbox/dev-version.mjs +14 -0
  64. package/README_en.MD +0 -71
  65. package/scripts/plugin/lib/injects-point.js +0 -41
  66. package/scripts/plugin/lib/injects.js +0 -105
  67. package/source/js/_app/library/dom.ts +0 -28
  68. package/source/js/_app/library/loadFile.ts +0 -47
  69. package/source/js/_app/library/scriptPjax.ts +0 -56
  70. package/source/js/_app/library/storage.ts +0 -12
@@ -1,9 +1,7 @@
1
- import { $dom } from '../library/dom'
2
1
  import { postFancybox } from './fancybox'
3
2
  import { clipBoard, showtip } from '../globals/tools'
4
3
  import { CONFIG, BODY } from '../globals/globalVars'
5
4
  import { pageScroll, transition } from '../library/anime'
6
- import { mediaPlayer } from '../player'
7
5
  import { getDisplay, setDisplay, wrapObject } from '../library/proto'
8
6
 
9
7
  export const postBeauty = () => {
@@ -43,31 +41,31 @@ export const postBeauty = () => {
43
41
  }
44
42
  }
45
43
 
46
- $dom.each('li ruby', (element) => {
47
- let parent = element.parentNode
44
+ document.querySelectorAll('li ruby').forEach((element) => {
45
+ let parent = element.parentNode as HTMLElement
48
46
  // @ts-ignore
49
47
  if (element.parentNode.tagName !== 'LI') {
50
- parent = element.parentNode.parentNode
48
+ parent = element.parentNode.parentNode as HTMLElement
51
49
  }
52
- parent.addClass('ruby')
50
+ parent.classList.add('ruby')
53
51
  })
54
52
 
55
- $dom.each('ol[start]', (element) => {
53
+ document.querySelectorAll('ol[start]').forEach((element) => {
56
54
  // @ts-ignore
57
55
  element.style.counterReset = 'counter ' + parseInt(element.getAttribute('start') - 1)
58
56
  })
59
57
 
60
- $dom.each('.md table', (element) => {
58
+ document.querySelectorAll<HTMLElement>('.md table').forEach((element) => {
61
59
  wrapObject(element, {
62
60
  className: 'table-container'
63
61
  })
64
62
  })
65
63
 
66
- $dom.each('.highlight > .table-container', (element) => {
64
+ document.querySelectorAll('.highlight > .table-container').forEach((element) => {
67
65
  element.className = 'code-container'
68
66
  })
69
67
 
70
- $dom.each('figure.highlight', (element) => {
68
+ document.querySelectorAll<HTMLElement>('figure.highlight').forEach((element) => {
71
69
  const code_container = element.querySelector('.code-container') as HTMLElement
72
70
  const caption = element.querySelector('figcaption')
73
71
 
@@ -80,7 +78,7 @@ export const postBeauty = () => {
80
78
  copyBtn.addEventListener('click', (event) => {
81
79
  const target = <HTMLElement>event.currentTarget
82
80
  let comma = ''; let code = ''
83
- code_container.find('pre').forEach((line) => {
81
+ code_container.querySelectorAll('pre').forEach((line) => {
84
82
  code += comma + line.innerText
85
83
  comma = '\n'
86
84
  })
@@ -101,61 +99,61 @@ export const postBeauty = () => {
101
99
  const breakBtn = element.querySelector('.breakline-btn')
102
100
  breakBtn.addEventListener('click', (event) => {
103
101
  const target = event.currentTarget as HTMLElement
104
- if (element.hasClass('breakline')) {
105
- element.removeClass('breakline')
102
+ if (element.classList.contains('breakline')) {
103
+ element.classList.remove('breakline')
106
104
  target.querySelector('.ic').className = 'ic i-align-left'
107
105
  } else {
108
- element.addClass('breakline')
106
+ element.classList.add('breakline')
109
107
  target.querySelector('.ic').className = 'ic i-align-justify'
110
108
  }
111
109
  })
112
110
 
113
111
  const fullscreenBtn = element.querySelector('.fullscreen-btn')
114
112
  const removeFullscreen = () => {
115
- element.removeClass('fullscreen')
113
+ element.classList.remove('fullscreen')
116
114
  element.scrollTop = 0
117
- BODY.removeClass('fullscreen')
115
+ BODY.classList.remove('fullscreen')
118
116
  fullscreenBtn.querySelector('.ic').className = 'ic i-expand'
119
117
  }
120
118
  const fullscreenHandle = () => {
121
- if (element.hasClass('fullscreen')) {
119
+ if (element.classList.contains('fullscreen')) {
122
120
  removeFullscreen()
123
- if (code_container && code_container.find('tr').length > 15) {
121
+ if (code_container && code_container.querySelectorAll('tr').length > 15) {
124
122
  const showBtn = code_container.querySelector('.show-btn')
125
123
  code_container.style.maxHeight = '300px'
126
- showBtn.removeClass('open')
124
+ showBtn.classList.remove('open')
127
125
  }
128
126
  pageScroll(element)
129
127
  } else {
130
- element.addClass('fullscreen')
131
- BODY.addClass('fullscreen')
128
+ element.classList.add('fullscreen')
129
+ BODY.classList.add('fullscreen')
132
130
  fullscreenBtn.querySelector('.ic').className = 'ic i-compress'
133
- if (code_container && code_container.find('tr').length > 15) {
131
+ if (code_container && code_container.querySelectorAll('tr').length > 15) {
134
132
  const showBtn = code_container.querySelector('.show-btn')
135
133
  code_container.style.maxHeight = ''
136
- showBtn.addClass('open')
134
+ showBtn.classList.add('open')
137
135
  }
138
136
  }
139
137
  }
140
138
  fullscreenBtn.addEventListener('click', fullscreenHandle)
141
139
  caption && caption.addEventListener('click', fullscreenHandle)
142
140
 
143
- if (code_container && code_container.find('tr').length > 15) {
141
+ if (code_container && code_container.querySelectorAll('tr').length > 15) {
144
142
  code_container.style.maxHeight = '300px'
145
143
  code_container.insertAdjacentHTML('beforeend', '<div class="show-btn"><i class="ic i-angle-down"></i></div>')
146
144
  const showBtn = code_container.querySelector('.show-btn')
147
145
 
148
146
  const hideCode = () => {
149
147
  code_container.style.maxHeight = '300px'
150
- showBtn.removeClass('open')
148
+ showBtn.classList.remove('open')
151
149
  }
152
150
  const showCode = () => {
153
151
  code_container.style.maxHeight = ''
154
- showBtn.addClass('open')
152
+ showBtn.classList.add('open')
155
153
  }
156
154
 
157
155
  showBtn.addEventListener('click', () => {
158
- if (showBtn.hasClass('open')) {
156
+ if (showBtn.classList.contains('open')) {
159
157
  removeFullscreen()
160
158
  hideCode()
161
159
  pageScroll(code_container)
@@ -166,12 +164,12 @@ export const postBeauty = () => {
166
164
  }
167
165
  })
168
166
 
169
- $dom.each('pre.mermaid > svg', (element) => {
167
+ document.querySelectorAll('pre.mermaid > svg').forEach((element) => {
170
168
  const temp = <SVGAElement><unknown>element
171
169
  temp.style.maxWidth = ''
172
170
  })
173
171
 
174
- $dom.each('.reward button', (element) => {
172
+ document.querySelectorAll('.reward button').forEach((element) => {
175
173
  element.addEventListener('click', (event) => {
176
174
  event.preventDefault()
177
175
  const qr = document.getElementById('qr')
@@ -187,60 +185,50 @@ export const postBeauty = () => {
187
185
 
188
186
  // quiz
189
187
  if (__shokax_quiz__) {
190
- $dom.each('.quiz > ul.options li', (element) => {
188
+ document.querySelectorAll('.quiz > ul.options li').forEach((element) => {
191
189
  element.addEventListener('click', () => {
192
- if (element.hasClass('correct')) {
193
- element.toggleClass('right')
194
- element.parentNode.parentNode.addClass('show')
190
+ if (element.classList.contains('correct')) {
191
+ element.classList.toggle('right');
192
+ (element.parentNode.parentNode as HTMLElement).classList.add('show')
195
193
  } else {
196
- element.toggleClass('wrong')
194
+ element.classList.toggle('wrong')
197
195
  }
198
196
  })
199
197
  })
200
198
 
201
- $dom.each('.quiz > p', (element) => {
199
+ document.querySelectorAll('.quiz > p').forEach((element) => {
202
200
  element.addEventListener('click', () => {
203
- element.parentNode.toggleClass('show')
201
+ (element.parentNode as HTMLElement).classList.toggle('show')
204
202
  })
205
203
  })
206
204
 
207
- $dom.each('.quiz > p:first-child', (element) => {
208
- const quiz = element.parentNode
205
+ document.querySelectorAll('.quiz > p:first-child').forEach((element) => {
206
+ const quiz = element.parentNode as HTMLElement
209
207
  let type = 'choice'
210
- if (quiz.hasClass('true') || quiz.hasClass('false')) {
208
+ if (quiz.classList.contains('true') || quiz.classList.contains('false')) {
211
209
  type = 'true_false'
212
210
  }
213
- if (quiz.hasClass('multi')) {
211
+ if (quiz.classList.contains('multi')) {
214
212
  type = 'multiple'
215
213
  }
216
- if (quiz.hasClass('fill')) {
214
+ if (quiz.classList.contains('fill')) {
217
215
  type = 'gap_fill'
218
216
  }
219
- if (quiz.hasClass('essay')) {
217
+ if (quiz.classList.contains('essay')) {
220
218
  type = 'essay'
221
219
  }
222
220
  element.setAttribute('data-type', LOCAL.quiz[type])
223
221
  })
224
222
 
225
- $dom.each('.quiz .mistake', (element) => {
223
+ document.querySelectorAll('.quiz .mistake').forEach((element) => {
226
224
  element.setAttribute('data-type', LOCAL.quiz.mistake)
227
225
  })
228
226
  }
229
227
 
230
- $dom.each('div.tags a', (element) => {
228
+ document.querySelectorAll('div.tags a').forEach((element) => {
231
229
  element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)]
232
230
  })
233
231
 
234
- if (__shokax_player__) {
235
- $dom.each('.md div.player', (element) => {
236
- mediaPlayer(element, {
237
- type: element.getAttribute('data-type'),
238
- mode: 'order',
239
- btns: []
240
- }).player.load(JSON.parse(element.getAttribute('data-src'))).fetch()
241
- })
242
- }
243
-
244
232
  const angleDown = document.querySelectorAll('.show-btn .i-angle-down')
245
233
  if (angleDown.length) {
246
234
  const io = new IntersectionObserver((entries) => {
@@ -5,7 +5,7 @@ import type { HitHighlightResult } from 'instantsearch.js/es/types/results'
5
5
  import instantsearch from 'instantsearch.js'
6
6
  import { liteClient as algoliasearch } from 'algoliasearch/lite'
7
7
 
8
- export function algoliaSearch (pjax) {
8
+ export function algoliaSearch () {
9
9
  const search = instantsearch({
10
10
  indexName: CONFIG.search.indexName,
11
11
  searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
@@ -18,10 +18,6 @@ export function algoliaSearch (pjax) {
18
18
  }
19
19
  })
20
20
 
21
- search.on('render', () => {
22
- pjax.refresh(document.getElementById("search-hits"))
23
- })
24
-
25
21
  // Registering Widgets
26
22
  search.addWidgets([
27
23
  configure({
@@ -105,7 +101,6 @@ export function algoliaSearch (pjax) {
105
101
  }
106
102
  })
107
103
  document.querySelector('.close-btn').addEventListener('click', onPopupClose)
108
- window.addEventListener('pjax:success', onPopupClose)
109
104
  window.addEventListener('keyup', (event) => {
110
105
  if (event.key === 'Escape') {
111
106
  onPopupClose()
@@ -1,11 +1,10 @@
1
1
  import { pageScroll } from '../library/anime'
2
- import { $dom } from '../library/dom'
3
2
  import { createChild } from '../library/proto'
4
3
 
5
4
  export const tabFormat = () => {
6
5
  // tab
7
6
  let first_tab:boolean
8
- $dom.each('div.tab', (element) => {
7
+ document.querySelectorAll('div.tab').forEach((element) => {
9
8
  if (element.getAttribute('data-ready')) { return }
10
9
 
11
10
  const id = element.getAttribute('data-id')
@@ -41,17 +40,17 @@ export const tabFormat = () => {
41
40
  })
42
41
 
43
42
  if (first_tab) {
44
- li.addClass('active')
45
- element.addClass('active')
43
+ li.classList.add('active')
44
+ element.classList.add('active')
46
45
  }
47
46
 
48
47
  li.addEventListener('click', (event) => {
49
- const target = event.currentTarget
50
- box.find('.active').forEach((el) => {
51
- el.removeClass('active')
48
+ const target = event.currentTarget as HTMLElement
49
+ box.querySelectorAll('.active').forEach((el) => {
50
+ el.classList.remove('active')
52
51
  })
53
- element.addClass('active')
54
- target.addClass('active')
52
+ element.classList.add('active')
53
+ target.classList.add('active')
55
54
  })
56
55
 
57
56
  box.appendChild(element)
@@ -5,20 +5,17 @@ import {
5
5
  loadCat,
6
6
  menuToggle,
7
7
  quickBtn, setBackToTop, setGoToComment, setShowContents, setToolBtn,
8
- setToolPlayer,
9
8
  showContents,
10
9
  siteHeader,
11
10
  siteNav,
12
- toolBtn,
13
- toolPlayer
11
+ toolBtn
14
12
  } from '../globals/globalVars'
15
13
  import { Loader } from '../globals/thirdparty'
16
- import { $dom } from '../library/dom'
17
- import { mediaPlayer } from '../player'
18
14
  import { createChild } from '../library/proto'
15
+ import { initAudioPlayer } from '../player'
19
16
 
20
- export default function domInit () {
21
- $dom.each('.overview .menu > .item', (el) => {
17
+ export default async function domInit () {
18
+ document.querySelectorAll('.overview .menu > .item').forEach((el) => {
22
19
  siteNav.querySelector('.menu').appendChild(el.cloneNode(true))
23
20
  })
24
21
 
@@ -32,11 +29,22 @@ export default function domInit () {
32
29
  if (!toolBtn) {
33
30
  setToolBtn(createChild(siteHeader, 'div', {
34
31
  id: 'tool',
35
- 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>'
32
+ innerHTML: `<div class="item player">
33
+ ${__shokax_player__ ? '<div class="play-pause btn" id="playBtn"></div><div class="music btn btn" id="showBtn"></div>' : ''}
34
+ </div>
35
+ <div class="item contents">
36
+ <i class="ic i-list-ol"></i>
37
+ </div>
38
+ <div class="item chat">
39
+ <i class="ic i-comments"></i>
40
+ </div>
41
+ <div class="item back-to-top">
42
+ <i class="ic i-arrow-up"></i>
43
+ <span>0%</span>
44
+ </div>`
36
45
  }))
37
46
  }
38
47
 
39
- setToolPlayer(toolBtn.querySelector('.player'))
40
48
  setBackToTop(toolBtn.querySelector('.back-to-top'))
41
49
  setGoToComment(toolBtn.querySelector('.chat'))
42
50
  setShowContents(toolBtn.querySelector('.contents'))
@@ -46,12 +54,9 @@ export default function domInit () {
46
54
  showContents.addEventListener('click', sideBarToggleHandle)
47
55
 
48
56
  if (__shokax_player__) {
49
- mediaPlayer(toolPlayer)
50
-
51
- document.querySelector('main').addEventListener('click', () => {
52
- toolPlayer.player.mini()
53
- })
57
+ await initAudioPlayer()
54
58
  }
59
+
55
60
 
56
61
  const createIntersectionObserver = () => {
57
62
  // waves在视口外时停止动画
@@ -1,37 +1,13 @@
1
- import { $dom } from '../library/dom'
2
1
  import { cardActive } from '../page/common'
3
- import { pageScroll, transition } from '../library/anime'
4
- import { vendorCss, vendorJs } from '../library/loadFile'
5
- import { pjaxScript } from '../library/scriptPjax'
6
2
  import { resizeHandle } from '../globals/handles'
7
3
  import {
8
4
  CONFIG,
9
- loadCat,
10
- menuToggle,
11
5
  setLocalHash, setLocalUrl, setOriginTitle,
12
- sideBar,
13
- toolPlayer
14
6
  } from '../globals/globalVars'
15
- import { pagePosition, positionInit } from '../globals/tools'
7
+ import { positionInit } from '../globals/tools'
16
8
  import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar'
17
9
  import { Loader, isOutime } from '../globals/thirdparty'
18
10
  import { tabFormat } from '../page/tab'
19
- import { lazyLoad } from 'unlazy'
20
-
21
- export const pjaxReload = () => {
22
- pagePosition()
23
-
24
- if (sideBar.hasClass('on')) {
25
- transition(sideBar, 0, () => {
26
- sideBar.removeClass('on')
27
- menuToggle.removeClass('close')
28
- }) // 'transition.slideRightOut'
29
- }
30
- const mainNode = document.getElementById('main')
31
- mainNode.innerHTML = ''
32
- mainNode.appendChild(loadCat.lastChild.cloneNode(true))
33
- pageScroll(0)
34
- }
35
11
 
36
12
  export const siteRefresh = async (reload) => {
37
13
  if (__shokax_antiFakeWebsite__) {
@@ -45,9 +21,9 @@ export const siteRefresh = async (reload) => {
45
21
  setLocalHash(0)
46
22
  setLocalUrl(window.location.href)
47
23
 
48
- vendorCss('katex');
24
+ // @ts-ignore
25
+ // await import('katex/dist/katex.min.css')
49
26
  await import('katex/dist/contrib/copy-tex.mjs')
50
- vendorCss('mermaid')
51
27
 
52
28
  // 懒加载背景图
53
29
  const lazyBg = new IntersectionObserver(function (entries, observer) {
@@ -67,10 +43,6 @@ export const siteRefresh = async (reload) => {
67
43
  lazyBg.observe(el)
68
44
  })
69
45
 
70
- if (reload !== 1) {
71
- $dom.each('script[data-pjax]', pjaxScript)
72
- }
73
-
74
46
  setOriginTitle(document.title)
75
47
 
76
48
  resizeHandle()
@@ -111,8 +83,6 @@ export const siteRefresh = async (reload) => {
111
83
  comment.observe(cpel)
112
84
  }
113
85
 
114
- lazyLoad()
115
-
116
86
  if (__shokax_waline__) {
117
87
  import('../components/comments').then(async ({walineRecentComments}) => {
118
88
  await walineRecentComments()
@@ -129,10 +99,12 @@ export const siteRefresh = async (reload) => {
129
99
  tabFormat()
130
100
  }
131
101
 
132
- if (__shokax_player__) {
133
- toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {})
102
+ if (sessionStorage.getItem('loaded') === 'true') {
103
+ Loader.hide(30)
104
+ } else {
105
+ sessionStorage.setItem('loaded', 'true')
106
+ Loader.hide(500)
134
107
  }
135
- Loader.hide(100)
136
108
 
137
109
  setTimeout(() => {
138
110
  positionInit()
@@ -1,37 +1,18 @@
1
1
  import domInit from './domInit'
2
- import { pjaxReload, siteRefresh } from './refresh'
3
- import { cloudflareInit } from '../components/cloudflare'
4
- import { BODY, CONFIG, pjax, setPjax, setSiteSearch, siteSearch } from '../globals/globalVars'
5
- import { autoDarkmode, themeColorListener } from '../globals/themeColor'
6
- import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles'
7
- import { pagePosition } from '../globals/tools'
8
- import Pjax from 'theme-shokax-pjax'
9
- import { initVue } from '../library/vue'
10
- import { $dom } from '../library/dom'
11
- import { createChild } from '../library/proto'
12
- import { transition } from '../library/anime'
2
+ import {siteRefresh} from './refresh'
3
+ import {cloudflareInit} from '../components/cloudflare'
4
+ import {BODY, CONFIG, setSiteSearch, siteSearch} from '../globals/globalVars'
5
+ import {autoDarkmode, themeColorListener} from '../globals/themeColor'
6
+ import {resizeHandle, scrollHandle, visibilityListener} from '../globals/handles'
7
+ import {pagePosition} from '../globals/tools'
8
+ import {initVue} from '../library/vue'
9
+ import {createChild} from '../library/proto'
10
+ import {transition} from '../library/anime'
13
11
 
14
12
  const siteInit = async () => {
15
13
  initVue()
16
14
  domInit()
17
15
 
18
- setPjax(new Pjax({
19
- selectors: [
20
- 'head title',
21
- '.languages',
22
- '.twikoo',
23
- '.pjax',
24
- '.leancloud-recent-comment',
25
- 'script[data-config]'
26
- ],
27
- cacheBust: false
28
- }))
29
-
30
- CONFIG.quicklink.ignores = LOCAL.ignores
31
- import('quicklink').then(({listen}) => {
32
- listen(CONFIG.quicklink)
33
- })
34
-
35
16
  autoDarkmode()
36
17
 
37
18
  if (__shokax_VL__) {
@@ -53,19 +34,16 @@ const siteInit = async () => {
53
34
  }
54
35
 
55
36
  import('../page/search').then(({algoliaSearch}) => {
56
- algoliaSearch(pjax)
37
+ algoliaSearch()
57
38
  })
58
39
 
59
40
  // Handle and trigger popup window
60
- // TODO search 只有一个,不需要 each
61
- $dom.each('.search', (element) => {
62
- element.addEventListener('click', () => {
41
+ document.querySelector('.search').addEventListener('click', () => {
63
42
  document.body.style.overflow = 'hidden'
64
43
  transition(siteSearch, 'shrinkIn', () => {
65
44
  (document.querySelector('.search-input') as HTMLInputElement).focus()
66
45
  }) // transition.shrinkIn
67
46
  })
68
- })
69
47
  }, {once: true, capture: true})
70
48
  }
71
49
 
@@ -83,18 +61,11 @@ const siteInit = async () => {
83
61
  passive: true
84
62
  })
85
63
 
86
- window.addEventListener('pjax:send', pjaxReload, {
87
- passive: true
88
- })
89
-
90
- window.addEventListener('pjax:success', siteRefresh, {
91
- passive: true
92
- }) // 默认会传入一个event参数
93
-
94
- window.addEventListener('beforeunload', () => {
64
+ window.addEventListener('visibilitychange', () => {
95
65
  pagePosition()
96
66
  })
97
67
  await siteRefresh(1)
68
+ // TODO 修复内页跳转后重复出现加载动画的问题
98
69
  }
99
70
 
100
71
  cloudflareInit()