hexo-theme-shokax 0.4.25 → 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.
- package/README.md +19 -31
- package/UsageRestrictions.md +2 -2
- package/_config.yml +11 -25
- package/_images.yml +0 -7
- package/eslint.config.mjs +4 -5
- package/layout/_mixin/card.pug +1 -2
- package/layout/_mixin/comment.pug +0 -1
- package/layout/_mixin/segment.pug +1 -1
- package/layout/_partials/footer.pug +1 -4
- package/layout/_partials/head/head.pug +0 -8
- package/layout/_partials/head/pwa.pug +1 -1
- package/layout/_partials/header.pug +0 -1
- package/layout/_partials/layout.pug +4 -14
- package/layout/_partials/post/footer.pug +0 -2
- package/layout/_partials/post/post.pug +1 -2
- package/layout/_partials/post/reward.pug +1 -1
- package/layout/_partials/sidebar/overview.pug +0 -2
- package/layout/_partials/third-party/baidu-analytics.pug +1 -1
- package/layout/_partials/third-party/google-analytics.pug +1 -1
- package/layout/archive.pug +3 -0
- package/layout/category.pug +3 -0
- package/layout/index.pug +3 -0
- package/layout/page.pug +7 -0
- package/layout/post.pug +8 -0
- package/layout/tag.pug +3 -0
- package/package.json +9 -10
- package/scripts/filters/post.js +1 -1
- package/scripts/generaters/config.js +12 -7
- package/scripts/generaters/images.js +9 -8
- package/scripts/generaters/index.js +57 -44
- package/scripts/generaters/script.js +18 -33
- package/scripts/helpers/engine.js +2 -7
- package/scripts/plugin/index.js +32 -69
- package/scripts/tags/media.js +1 -1
- package/source/css/app.styl +0 -13
- package/source/css/page.styl +3 -0
- package/source/css/post.styl +5 -0
- package/source/css/scaffolding.styl +5 -0
- package/source/js/_app/components/comments.ts +2 -3
- package/source/js/_app/components/sidebar.ts +35 -35
- package/source/js/_app/components/tcomments.ts +0 -1
- package/source/js/_app/globals/globalVars.ts +0 -15
- package/source/js/_app/globals/handles.ts +9 -9
- package/source/js/_app/globals/themeColor.ts +5 -6
- package/source/js/_app/globals/thirdparty.ts +2 -2
- package/source/js/_app/globals/tools.ts +4 -6
- package/source/js/_app/library/anime.ts +30 -19
- package/source/js/_app/library/declare.d.ts +0 -5
- package/source/js/_app/library/proto.ts +0 -67
- package/source/js/_app/library/vue.ts +7 -7
- package/source/js/_app/page/common.ts +8 -10
- package/source/js/_app/page/fancybox.ts +6 -8
- package/source/js/_app/page/post.ts +42 -54
- package/source/js/_app/page/search.ts +1 -6
- package/source/js/_app/page/tab.ts +8 -9
- package/source/js/_app/pjax/domInit.ts +19 -14
- package/source/js/_app/pjax/refresh.ts +8 -36
- package/source/js/_app/pjax/siteInit.ts +13 -42
- package/source/js/_app/player.ts +14 -798
- package/toolbox/compiler.mjs +20 -48
- package/toolbox/dev-version.mjs +14 -0
- package/README_en.MD +0 -71
- package/scripts/plugin/lib/injects-point.js +0 -41
- package/scripts/plugin/lib/injects.js +0 -105
- package/source/js/_app/library/dom.ts +0 -28
- package/source/js/_app/library/loadFile.ts +0 -47
- package/source/js/_app/library/scriptPjax.ts +0 -56
- package/source/js/_app/library/storage.ts +0 -12
@@ -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
|
-
|
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.
|
45
|
-
element.
|
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.
|
51
|
-
el.
|
48
|
+
const target = event.currentTarget as HTMLElement
|
49
|
+
box.querySelectorAll('.active').forEach((el) => {
|
50
|
+
el.classList.remove('active')
|
52
51
|
})
|
53
|
-
element.
|
54
|
-
target.
|
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
|
-
|
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:
|
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
|
-
|
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 {
|
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
|
-
|
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 (
|
133
|
-
|
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 {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import
|
9
|
-
import {
|
10
|
-
import {
|
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(
|
37
|
+
algoliaSearch()
|
57
38
|
})
|
58
39
|
|
59
40
|
// Handle and trigger popup window
|
60
|
-
|
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('
|
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()
|