hexo-theme-shokax 0.4.0-alpha.1 → 0.4.0-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +5 -4
- package/languages/README.md +22 -0
- package/languages/ar.yml +153 -0
- package/languages/de.yml +153 -0
- package/languages/es.yml +153 -0
- package/languages/fr.yml +153 -0
- package/languages/hi.yml +153 -0
- package/languages/id.yml +153 -0
- package/languages/it.yml +153 -0
- package/languages/ko.yml +153 -0
- package/languages/nl.yml +153 -0
- package/languages/pl.yml +153 -0
- package/languages/pt.yml +153 -0
- package/languages/ru.yml +153 -0
- package/languages/tr.yml +153 -0
- package/languages/vi.yml +153 -0
- package/layout/_mixin/comment.pug +2 -37
- package/layout/_partials/footer.pug +1 -1
- package/layout/_partials/head/head.pug +7 -3
- package/layout/_partials/header.pug +1 -1
- package/layout/_partials/layout.pug +1 -10
- package/layout/_partials/post/footer.pug +0 -9
- package/package.json +8 -2
- package/scripts/generaters/archive.js +1 -1
- package/scripts/generaters/script.js +63 -39
- package/scripts/helpers/asset.js +3 -72
- package/scripts/helpers/list_categories.js +0 -4
- package/scripts/plugin/lib/injects.js +1 -1
- package/source/js/_app/components/comments.ts +60 -0
- package/source/js/_app/components/sidebar.ts +7 -5
- package/source/js/_app/components/tcomments.ts +41 -0
- package/source/js/_app/globals/globalVars.ts +1 -0
- package/source/js/_app/globals/handles.ts +6 -5
- package/source/js/_app/globals/themeColor.ts +1 -1
- package/source/js/_app/globals/thirdparty.ts +1 -1
- package/source/js/_app/globals/tools.ts +3 -2
- package/source/js/_app/library/anime.ts +6 -5
- package/source/js/_app/library/declare.d.ts +25 -9
- package/source/js/_app/library/loadFile.ts +3 -1
- package/source/js/_app/library/proto.ts +75 -77
- package/source/js/_app/library/vue.ts +38 -48
- package/source/js/_app/page/fancybox.ts +2 -1
- package/source/js/_app/page/post.ts +4 -3
- package/source/js/_app/page/search.ts +17 -11
- package/source/js/_app/page/tab.ts +3 -2
- package/source/js/_app/pjax/domInit.ts +5 -4
- package/source/js/_app/pjax/refresh.ts +20 -2
- package/source/js/_app/pjax/siteInit.ts +12 -7
- package/source/js/_app/player.ts +16 -15
- package/scripts/filters/locals.d.ts +0 -1
- package/scripts/filters/locals.ts +0 -59
- package/scripts/filters/post.d.ts +0 -0
- package/scripts/filters/post.ts +0 -6
- package/scripts/generaters/archive.d.ts +0 -1
- package/scripts/generaters/archive.ts +0 -144
- package/scripts/generaters/config.d.ts +0 -1
- package/scripts/generaters/config.ts +0 -52
- package/scripts/generaters/images.d.ts +0 -1
- package/scripts/generaters/images.ts +0 -26
- package/scripts/generaters/index.d.ts +0 -1
- package/scripts/generaters/index.ts +0 -110
- package/scripts/generaters/pages.d.ts +0 -0
- package/scripts/generaters/pages.ts +0 -16
- package/scripts/generaters/script.d.ts +0 -1
- package/scripts/generaters/script.ts +0 -110
- package/scripts/helpers/asset.d.ts +0 -1
- package/scripts/helpers/asset.ts +0 -158
- package/scripts/helpers/engine.d.ts +0 -1
- package/scripts/helpers/engine.ts +0 -171
- package/scripts/helpers/list_categories.d.ts +0 -1
- package/scripts/helpers/list_categories.ts +0 -104
- package/scripts/helpers/summary_ai.d.ts +0 -1
- package/scripts/helpers/summary_ai.ts +0 -100
- package/scripts/helpers/symbols_count_time.d.ts +0 -1
- package/scripts/helpers/symbols_count_time.ts +0 -76
- package/scripts/plugin/check.d.ts +0 -1
- package/scripts/plugin/check.ts +0 -35
- package/scripts/plugin/index.d.ts +0 -6
- package/scripts/plugin/index.ts +0 -52
- package/scripts/plugin/lib/injects-point.d.ts +0 -5
- package/scripts/plugin/lib/injects-point.ts +0 -20
- package/scripts/plugin/lib/injects.d.ts +0 -2
- package/scripts/plugin/lib/injects.ts +0 -101
- package/scripts/tags/links.d.ts +0 -1
- package/scripts/tags/links.ts +0 -75
- package/scripts/tags/media.d.ts +0 -1
- package/scripts/tags/media.ts +0 -19
- package/source/assets/beian.webp +0 -0
- package/source/js/_app/library/libtype.d.ts +0 -4
@@ -3,58 +3,48 @@ import { transition } from './anime'
|
|
3
3
|
import { $dom } from './dom'
|
4
4
|
import { BODY } from '../globals/globalVars'
|
5
5
|
import { changeTheme } from '../globals/themeColor'
|
6
|
-
|
6
|
+
import { child, createChild, setDisplay } from './proto'
|
7
7
|
export function initVue () {
|
8
|
-
|
9
|
-
{
|
10
|
-
|
11
|
-
return {
|
12
|
-
|
13
|
-
}
|
14
|
-
},
|
15
|
-
methods: {
|
16
|
-
changeThemeByBtn () {
|
17
|
-
let c: { (): void; (): void; (): void }
|
18
|
-
const btn = $dom('.theme').child('.ic')
|
8
|
+
function changeThemeByBtn () {
|
9
|
+
let c: { (): void; (): void; (): void }
|
10
|
+
const btn = child($dom('.theme'), '.ic')
|
19
11
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
const neko = createChild(BODY, 'div', {
|
13
|
+
id: 'neko',
|
14
|
+
innerHTML: '<div class="planet"><div class="sun"></div><div class="moon"></div></div><div class="body"><div class="face"><section class="eyes left"><span class="pupil"></span></section><section class="eyes right"><span class="pupil"></span></section><span class="nose"></span></div></div>'
|
15
|
+
})
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
const hideNeko = () => {
|
18
|
+
transition(neko, {
|
19
|
+
// @ts-ignore
|
20
|
+
delay: 2500,
|
21
|
+
opacity: 0
|
22
|
+
}, () => {
|
23
|
+
BODY.removeChild(neko)
|
24
|
+
})
|
25
|
+
}
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
}
|
51
|
-
transition(neko, 1, () => {
|
52
|
-
setTimeout(c, 210)
|
53
|
-
}, () => {
|
54
|
-
neko.display('block')
|
55
|
-
})
|
56
|
-
}
|
27
|
+
if (btn.hasClass('i-sun')) {
|
28
|
+
c = () => {
|
29
|
+
neko.addClass('dark')
|
30
|
+
changeTheme('dark')
|
31
|
+
$storage.set('theme', 'dark')
|
32
|
+
hideNeko()
|
33
|
+
}
|
34
|
+
} else {
|
35
|
+
neko.addClass('dark')
|
36
|
+
c = () => {
|
37
|
+
neko.removeClass('dark')
|
38
|
+
changeTheme()
|
39
|
+
$storage.set('theme', 'light')
|
40
|
+
hideNeko()
|
57
41
|
}
|
58
42
|
}
|
59
|
-
|
43
|
+
transition(neko, 1, () => {
|
44
|
+
setTimeout(c, 210)
|
45
|
+
}, () => {
|
46
|
+
setDisplay(neko, 'block')
|
47
|
+
})
|
48
|
+
}
|
49
|
+
child($dom('#rightNav'), '.theme .ic').addEventListener('click', changeThemeByBtn)
|
60
50
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { $dom } from '../library/dom'
|
2
2
|
import { vendorCss, vendorJs } from '../library/loadFile'
|
3
|
+
import { insertAfter } from '../library/proto'
|
3
4
|
|
4
5
|
export const postFancybox = (p:string) => {
|
5
6
|
if ($dom(p + ' .md img')) {
|
@@ -38,7 +39,7 @@ export const postFancybox = (p:string) => {
|
|
38
39
|
const txt = document.createTextNode(info)
|
39
40
|
para.appendChild(txt)
|
40
41
|
para.addClass(captionClass)
|
41
|
-
|
42
|
+
insertAfter(element, para)
|
42
43
|
}
|
43
44
|
})
|
44
45
|
|
@@ -4,6 +4,7 @@ import { clipBoard, showtip } from '../globals/tools'
|
|
4
4
|
import { BODY } from '../globals/globalVars'
|
5
5
|
import { pageScroll, transition } from '../library/anime'
|
6
6
|
import { mediaPlayer } from '../player'
|
7
|
+
import { getDisplay, setDisplay, wrapObject } from '../library/proto'
|
7
8
|
|
8
9
|
export const postBeauty = () => {
|
9
10
|
if (!$dom('.md')) { return }
|
@@ -57,7 +58,7 @@ export const postBeauty = () => {
|
|
57
58
|
})
|
58
59
|
|
59
60
|
$dom.each('.md table', (element) => {
|
60
|
-
|
61
|
+
wrapObject(element, {
|
61
62
|
className: 'table-container'
|
62
63
|
})
|
63
64
|
})
|
@@ -174,11 +175,11 @@ export const postBeauty = () => {
|
|
174
175
|
element.addEventListener('click', (event) => {
|
175
176
|
event.preventDefault()
|
176
177
|
const qr = $dom('#qr')
|
177
|
-
if (qr
|
178
|
+
if (getDisplay(qr) === 'inline-flex') {
|
178
179
|
transition(qr, 0)
|
179
180
|
} else {
|
180
181
|
transition(qr, 1, () => {
|
181
|
-
qr
|
182
|
+
setDisplay(qr, 'inline-flex')
|
182
183
|
}) // slideUpBigIn
|
183
184
|
}
|
184
185
|
})
|
@@ -1,12 +1,17 @@
|
|
1
|
-
import { BODY, setSiteSearch, siteSearch } from '../globals/globalVars'
|
1
|
+
import { BODY, CONFIG, setSiteSearch, siteSearch } from '../globals/globalVars'
|
2
2
|
import { transition } from '../library/anime'
|
3
3
|
import { $dom } from '../library/dom'
|
4
|
+
import { searchBox, configure, stats, hits, pagination } from 'instantsearch.js/es/widgets'
|
5
|
+
import type { HitHighlightResult } from 'instantsearch.js/es/types/results'
|
6
|
+
import instantsearch from 'instantsearch.js'
|
7
|
+
import algoliasearch from 'algoliasearch/lite'
|
8
|
+
import {createChild} from "../library/proto";
|
4
9
|
|
5
10
|
export function algoliaSearch (pjax) {
|
6
11
|
if (CONFIG.search === null) { return }
|
7
12
|
|
8
13
|
if (!siteSearch) {
|
9
|
-
setSiteSearch(
|
14
|
+
setSiteSearch(createChild(BODY, 'div', {
|
10
15
|
id: 'search',
|
11
16
|
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
17
|
}))
|
@@ -15,8 +20,9 @@ export function algoliaSearch (pjax) {
|
|
15
20
|
const search = instantsearch({
|
16
21
|
indexName: CONFIG.search.indexName,
|
17
22
|
searchClient: algoliasearch(CONFIG.search.appID, CONFIG.search.apiKey),
|
23
|
+
// TODO 移除弃用函数
|
18
24
|
searchFunction (helper) {
|
19
|
-
const searchInput =
|
25
|
+
const searchInput = $dom('.search-input') as HTMLInputElement
|
20
26
|
if (searchInput.value) {
|
21
27
|
helper.search()
|
22
28
|
}
|
@@ -29,11 +35,11 @@ export function algoliaSearch (pjax) {
|
|
29
35
|
|
30
36
|
// Registering Widgets
|
31
37
|
search.addWidgets([
|
32
|
-
|
38
|
+
configure({
|
33
39
|
hitsPerPage: CONFIG.search.hits.per_page || 10
|
34
40
|
}),
|
35
41
|
|
36
|
-
|
42
|
+
searchBox({
|
37
43
|
container: '.search-input-container',
|
38
44
|
placeholder: LOCAL.search.placeholder,
|
39
45
|
// Hide default icons of algolia search
|
@@ -45,24 +51,24 @@ export function algoliaSearch (pjax) {
|
|
45
51
|
}
|
46
52
|
}),
|
47
53
|
|
48
|
-
|
54
|
+
stats({
|
49
55
|
container: '#search-stats',
|
50
56
|
templates: {
|
51
57
|
text (data) {
|
52
58
|
const stats = LOCAL.search.stats
|
53
|
-
.replace(/\$\{hits}/, data.nbHits)
|
54
|
-
.replace(/\$\{time}/, data.processingTimeMS)
|
59
|
+
.replace(/\$\{hits}/, data.nbHits.toString())
|
60
|
+
.replace(/\$\{time}/, data.processingTimeMS.toString())
|
55
61
|
return stats + '<span class="algolia-powered"></span><hr>'
|
56
62
|
}
|
57
63
|
}
|
58
64
|
}),
|
59
65
|
|
60
|
-
|
66
|
+
hits({
|
61
67
|
container: '#search-hits',
|
62
68
|
templates: {
|
63
69
|
item (data) {
|
64
70
|
const cats = data.categories ? '<span>' + data.categories.join('<i class="ic i-angle-right"></i>') + '</span>' : ''
|
65
|
-
return '<a href="' + CONFIG.root + data.path + '">' + cats + data._highlightResult.title.value + '</a>'
|
71
|
+
return '<a href="' + CONFIG.root + data.path + '">' + cats + (data._highlightResult.title as HitHighlightResult).value + '</a>'
|
66
72
|
},
|
67
73
|
empty (data) {
|
68
74
|
return '<div id="hits-empty">' +
|
@@ -75,7 +81,7 @@ export function algoliaSearch (pjax) {
|
|
75
81
|
}
|
76
82
|
}),
|
77
83
|
|
78
|
-
|
84
|
+
pagination({
|
79
85
|
container: '#search-pagination',
|
80
86
|
scrollTo: false,
|
81
87
|
showFirst: false,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { pageScroll } from '../library/anime'
|
2
2
|
import { $dom } from '../library/dom'
|
3
|
+
import { createChild } from '../library/proto'
|
3
4
|
|
4
5
|
export const tabFormat = () => {
|
5
6
|
// tab
|
@@ -29,13 +30,13 @@ export const tabFormat = () => {
|
|
29
30
|
|
30
31
|
let ul = box.child('.nav ul')
|
31
32
|
if (!ul) {
|
32
|
-
ul =
|
33
|
+
ul = createChild(box, 'div', {
|
33
34
|
className: 'nav',
|
34
35
|
innerHTML: '<ul></ul>'
|
35
36
|
}).child('ul')
|
36
37
|
}
|
37
38
|
|
38
|
-
const li =
|
39
|
+
const li = createChild(ul, 'li', {
|
39
40
|
innerHTML: title
|
40
41
|
})
|
41
42
|
|
@@ -15,21 +15,22 @@ import {
|
|
15
15
|
import { Loader } from '../globals/thirdparty'
|
16
16
|
import { $dom } from '../library/dom'
|
17
17
|
import { mediaPlayer } from '../player'
|
18
|
+
import { child, createChild } from '../library/proto'
|
18
19
|
|
19
20
|
export default function domInit () {
|
20
21
|
$dom.each('.overview .menu > .item', (el) => {
|
21
|
-
|
22
|
+
child(siteNav, '.menu').appendChild(el.cloneNode(true))
|
22
23
|
})
|
23
24
|
|
24
25
|
loadCat.addEventListener('click', Loader.vanish)
|
25
26
|
menuToggle.addEventListener('click', sideBarToggleHandle)
|
26
27
|
$dom('.dimmer').addEventListener('click', sideBarToggleHandle)
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
child(quickBtn, '.down').addEventListener('click', goToBottomHandle)
|
30
|
+
child(quickBtn, '.up').addEventListener('click', backToTopHandle)
|
30
31
|
|
31
32
|
if (!toolBtn) {
|
32
|
-
setToolBtn(
|
33
|
+
setToolBtn(createChild(siteHeader, 'div', {
|
33
34
|
id: 'tool',
|
34
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>'
|
35
36
|
}))
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { $dom } from '../library/dom'
|
2
2
|
import { cardActive } from '../page/common'
|
3
|
-
import { postBeauty } from '../page/post'
|
4
3
|
import { pageScroll, transition } from '../library/anime'
|
5
4
|
import { vendorCss, vendorJs } from '../library/loadFile'
|
6
5
|
import { pjaxScript } from '../library/scriptPjax'
|
7
6
|
import { resizeHandle } from '../globals/handles'
|
8
7
|
import {
|
8
|
+
CONFIG,
|
9
9
|
loadCat,
|
10
10
|
menuToggle,
|
11
11
|
setLocalHash, setLocalUrl, setOriginTitle,
|
@@ -53,7 +53,25 @@ export const siteRefresh = (reload) => {
|
|
53
53
|
sideBarTab()
|
54
54
|
sidebarTOC()
|
55
55
|
|
56
|
-
|
56
|
+
import('../page/post').then(({ postBeauty }) => {
|
57
|
+
postBeauty()
|
58
|
+
})
|
59
|
+
|
60
|
+
if (__shokax_waline__ && LOCAL.ispost) {
|
61
|
+
import('../components/comments').then(async ({ walineComment, walinePageview, walineRecentComments }) => {
|
62
|
+
walineComment()
|
63
|
+
walinePageview()
|
64
|
+
await walineRecentComments()
|
65
|
+
})
|
66
|
+
}
|
67
|
+
|
68
|
+
if (__shokax_twikoo__ && LOCAL.ispost) {
|
69
|
+
import('../components/tcomments').then(async ({ twikooComment, twikooRecentComments }) => {
|
70
|
+
twikooComment()
|
71
|
+
await twikooRecentComments()
|
72
|
+
})
|
73
|
+
}
|
74
|
+
|
57
75
|
if (__shokax_tabs__) {
|
58
76
|
tabFormat()
|
59
77
|
}
|
@@ -1,19 +1,17 @@
|
|
1
1
|
import domInit from './domInit'
|
2
2
|
import { pjaxReload, siteRefresh } from './refresh'
|
3
3
|
import { cloudflareInit } from '../library/scriptPjax'
|
4
|
-
import {
|
5
|
-
import { pjax, setPjax } from '../globals/globalVars'
|
4
|
+
import { CONFIG, pjax, setPjax } from '../globals/globalVars'
|
6
5
|
import { autoDarkmode, themeColorListener } from '../globals/themeColor'
|
7
6
|
import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles'
|
8
7
|
import { pagePosition } from '../globals/tools'
|
9
8
|
import Pjax from 'theme-shokax-pjax'
|
10
9
|
import { initVue } from '../library/vue'
|
11
10
|
import { lazyLoad } from 'unlazy'
|
12
|
-
import firework from 'mouse-firework'
|
13
11
|
|
14
12
|
const siteInit = () => {
|
15
|
-
domInit()
|
16
13
|
initVue()
|
14
|
+
domInit()
|
17
15
|
|
18
16
|
setPjax(new Pjax({
|
19
17
|
selectors: [
|
@@ -28,7 +26,10 @@ const siteInit = () => {
|
|
28
26
|
}))
|
29
27
|
|
30
28
|
CONFIG.quicklink.ignores = LOCAL.ignores
|
31
|
-
quicklink.listen
|
29
|
+
import('quicklink').then(({ listen }) => {
|
30
|
+
listen(CONFIG.quicklink)
|
31
|
+
})
|
32
|
+
|
32
33
|
autoDarkmode()
|
33
34
|
|
34
35
|
if (__shokax_VL__) {
|
@@ -36,11 +37,15 @@ const siteInit = () => {
|
|
36
37
|
}
|
37
38
|
themeColorListener()
|
38
39
|
if (__shokax_search__) {
|
39
|
-
|
40
|
+
import('../page/search').then(({ algoliaSearch }) => {
|
41
|
+
algoliaSearch(pjax)
|
42
|
+
})
|
40
43
|
}
|
41
44
|
|
42
45
|
if (__shokax_fireworks__) {
|
43
|
-
firework(
|
46
|
+
import('mouse-firework').then((firework) => {
|
47
|
+
firework.default(CONFIG.fireworks)
|
48
|
+
})
|
44
49
|
}
|
45
50
|
lazyLoad()
|
46
51
|
|
package/source/js/_app/player.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
import { originTitle } from './globals/globalVars'
|
1
|
+
import { CONFIG, originTitle } from './globals/globalVars'
|
2
2
|
import { showtip } from './globals/tools'
|
3
3
|
import { pageScroll } from './library/anime'
|
4
4
|
import { $dom } from './library/dom'
|
5
5
|
import { $storage } from './library/storage'
|
6
6
|
import { tabFormat } from './page/tab'
|
7
|
+
import { createChild, getLeft, getWidth, setDisplay, setWidth } from './library/proto'
|
7
8
|
|
8
9
|
let NOWPLAYING = null
|
9
10
|
|
@@ -16,7 +17,7 @@ export const mediaPlayer = (t, config?) => {
|
|
16
17
|
t.player.options.btns.forEach((item) => {
|
17
18
|
if (buttons.el[item]) { return }
|
18
19
|
|
19
|
-
buttons.el[item] =
|
20
|
+
buttons.el[item] = createChild(t, 'div', {
|
20
21
|
className: item + ' btn',
|
21
22
|
onclick (event) {
|
22
23
|
t.player.fetch().then(() => {
|
@@ -64,7 +65,7 @@ export const mediaPlayer = (t, config?) => {
|
|
64
65
|
|
65
66
|
opt.className = item + opt.className + ' btn'
|
66
67
|
|
67
|
-
that.btns[item] = that.el
|
68
|
+
that.btns[item] = createChild(that.el, 'div', opt)
|
68
69
|
})
|
69
70
|
|
70
71
|
that.btns.volume.bar = that.btns.volume.child('.bar')
|
@@ -130,10 +131,10 @@ export const mediaPlayer = (t, config?) => {
|
|
130
131
|
},
|
131
132
|
update (percent) {
|
132
133
|
controller.btns.volume.className = 'volume ' + (!source.muted && percent > 0 ? 'on' : 'off') + ' btn'
|
133
|
-
controller.btns.volume.bar
|
134
|
+
setWidth(controller.btns.volume.bar, Math.floor(percent * 100) + '%')
|
134
135
|
},
|
135
136
|
percent (e, el) {
|
136
|
-
let percentage = ((e.clientX || e.changedTouches[0].clientX) - el
|
137
|
+
let percentage = ((e.clientX || e.changedTouches[0].clientX) - getLeft(el)) / getWidth(el)
|
137
138
|
percentage = Math.max(percentage, 0)
|
138
139
|
return Math.min(percentage, 1)
|
139
140
|
}
|
@@ -151,13 +152,13 @@ export const mediaPlayer = (t, config?) => {
|
|
151
152
|
progress.el.remove()
|
152
153
|
}
|
153
154
|
|
154
|
-
progress.el =
|
155
|
+
progress.el = createChild(current, 'div', {
|
155
156
|
className: 'progress'
|
156
157
|
});
|
157
158
|
|
158
159
|
(progress.el as HTMLElement).setAttribute('data-dtime', utils.secondToTime(0))
|
159
160
|
|
160
|
-
progress.bar = progress.el
|
161
|
+
progress.bar = createChild(progress.el, 'div', {
|
161
162
|
className: 'bar'
|
162
163
|
})
|
163
164
|
|
@@ -169,14 +170,14 @@ export const mediaPlayer = (t, config?) => {
|
|
169
170
|
}
|
170
171
|
},
|
171
172
|
update (percent) {
|
172
|
-
progress.bar
|
173
|
+
setWidth(progress.bar, Math.floor(percent * 100) + '%');
|
173
174
|
(progress.el as HTMLElement).setAttribute('data-ptime', utils.secondToTime(percent * source.duration))
|
174
175
|
},
|
175
176
|
seeking (type) {
|
176
177
|
if (type) { progress.el.addClass('seeking') } else { progress.el.removeClass('seeking') }
|
177
178
|
},
|
178
179
|
percent (e, el) {
|
179
|
-
let percentage = ((e.clientX || e.changedTouches[0].clientX) - el
|
180
|
+
let percentage = ((e.clientX || e.changedTouches[0].clientX) - getLeft(el)) / getWidth(el)
|
180
181
|
percentage = Math.max(percentage, 0)
|
181
182
|
return Math.min(percentage, 1)
|
182
183
|
},
|
@@ -258,7 +259,7 @@ export const mediaPlayer = (t, config?) => {
|
|
258
259
|
const id = 'list-' + t.player._id + '-' + item.group
|
259
260
|
let tab = $dom('#' + id)
|
260
261
|
if (!tab) {
|
261
|
-
tab =
|
262
|
+
tab = createChild(el, 'div', {
|
262
263
|
id,
|
263
264
|
className: t.player.group ? 'tab' : '',
|
264
265
|
innerHTML: '<ol></ol>'
|
@@ -269,7 +270,7 @@ export const mediaPlayer = (t, config?) => {
|
|
269
270
|
}
|
270
271
|
}
|
271
272
|
|
272
|
-
item.el = tab.child('ol')
|
273
|
+
item.el = createChild(tab.child('ol'), 'li', {
|
273
274
|
title: item.name + ' - ' + item.artist,
|
274
275
|
innerHTML: '<span class="info"><span>' + item.name + '</span><span>' + item.artist + '</span></span>',
|
275
276
|
onclick (event) {
|
@@ -329,7 +330,7 @@ export const mediaPlayer = (t, config?) => {
|
|
329
330
|
create () {
|
330
331
|
if (this.el) { return }
|
331
332
|
|
332
|
-
this.el =
|
333
|
+
this.el = createChild(t, 'div', {
|
333
334
|
className: 'player-info',
|
334
335
|
innerHTML: (t.player.options.type === 'audio' ? '<div class="preview"></div>' : '') + '<div class="controller"></div><div class="playlist"></div>'
|
335
336
|
}, 'after')
|
@@ -469,7 +470,7 @@ export const mediaPlayer = (t, config?) => {
|
|
469
470
|
this.pause()
|
470
471
|
}
|
471
472
|
for (const el in buttons.el) {
|
472
|
-
buttons.el[el]
|
473
|
+
setDisplay(buttons.el[el], d)
|
473
474
|
}
|
474
475
|
return this
|
475
476
|
},
|
@@ -662,7 +663,7 @@ export const mediaPlayer = (t, config?) => {
|
|
662
663
|
lrc += '<p' + (index === 0 ? ' class="current"' : '') + '>' + line[1] + '</p>'
|
663
664
|
})
|
664
665
|
|
665
|
-
this.el =
|
666
|
+
this.el = createChild(box, 'div', {
|
666
667
|
className: 'inner',
|
667
668
|
innerHTML: lrc
|
668
669
|
}, 'replace')
|
@@ -783,7 +784,7 @@ export const mediaPlayer = (t, config?) => {
|
|
783
784
|
buttons.create()
|
784
785
|
|
785
786
|
// 初始化audio or video
|
786
|
-
source =
|
787
|
+
source = createChild(t, t.player.options.type, events)
|
787
788
|
// 初始化播放列表、预览、控件按钮等
|
788
789
|
info.create()
|
789
790
|
|
@@ -1 +0,0 @@
|
|
1
|
-
declare const fmtNum: (num: any) => any;
|
@@ -1,59 +0,0 @@
|
|
1
|
-
|
2
|
-
// @ts-ignore
|
3
|
-
const fmtNum = (num) => {
|
4
|
-
return num < 10 ? '0' + num : num
|
5
|
-
}
|
6
|
-
|
7
|
-
hexo.extend.filter.register('template_locals', (locals:localsPlus) => {
|
8
|
-
const { config } = hexo
|
9
|
-
const { __, theme } = locals
|
10
|
-
// @ts-ignore
|
11
|
-
const { i18n } = hexo.theme
|
12
|
-
|
13
|
-
const pangu = {
|
14
|
-
spacing: (data) => {
|
15
|
-
return data
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
// Language & Config
|
20
|
-
// 根据主题配置的 Creative Commons 许可证生成链接
|
21
|
-
locals.alternate = theme.alternate
|
22
|
-
locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title)
|
23
|
-
locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle)
|
24
|
-
locals.author = __('author') !== 'author' ? __('author') : config.author
|
25
|
-
locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description)
|
26
|
-
locals.languages = [...i18n.languages]
|
27
|
-
locals.languages.splice(locals.languages.indexOf('default'), 1)
|
28
|
-
locals.page.lang = locals.page.lang || locals.page.language
|
29
|
-
locals.hostname = new URL(config.url).hostname || config.url
|
30
|
-
|
31
|
-
// Creative Commons
|
32
|
-
// 根据主题配置的 Creative Commons 许可证生成链接
|
33
|
-
if (theme.creative_commons.license === 'zero') {
|
34
|
-
locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '')
|
35
|
-
} else {
|
36
|
-
locals.ccURL = 'https://creativecommons.org/' + 'licenses/' + theme.creative_commons.license + '/4.0/' + (theme.creative_commons.language || '')
|
37
|
-
}
|
38
|
-
|
39
|
-
if (locals.page.title) {
|
40
|
-
locals.page.title = pangu.spacing(locals.page.title)
|
41
|
-
}
|
42
|
-
locals.page.lastcat = ''
|
43
|
-
if (locals.page.categories) {
|
44
|
-
locals.page.categories.map((cat) => {
|
45
|
-
if (cat.name) {
|
46
|
-
cat.name = locals.page.lastcat = pangu.spacing(cat.name)
|
47
|
-
}
|
48
|
-
return cat
|
49
|
-
})
|
50
|
-
}
|
51
|
-
|
52
|
-
if (locals.page.category) {
|
53
|
-
locals.page.title = pangu.spacing(locals.page.category)
|
54
|
-
}
|
55
|
-
|
56
|
-
if (locals.page.month) {
|
57
|
-
locals.page.month = fmtNum(locals.page.month)
|
58
|
-
}
|
59
|
-
})
|
File without changes
|
package/scripts/filters/post.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|