hexo-theme-shokax 0.5.0-dev-815e373 → 0.5.0-dev-31f9f21
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/_config.yml +1 -1
- package/_images.yml +0 -7
- package/layout/_partials/head/head.pug +5 -0
- package/layout/_partials/head/pwa.pug +1 -1
- package/layout/_partials/layout.pug +2 -0
- package/layout/_partials/third-party/baidu-analytics.pug +1 -1
- package/layout/_partials/third-party/google-analytics.pug +1 -1
- package/package.json +12 -13
- package/source/js/_app/components/comments.ts +2 -1
- package/source/js/_app/components/tcomments.ts +0 -1
- package/source/js/_app/globals/globalVars.ts +0 -7
- package/source/js/_app/page/fancybox.ts +51 -61
- package/source/js/_app/page/post.ts +9 -9
- package/source/js/_app/page/search.ts +2 -6
- package/source/js/_app/pjax/domInit.ts +7 -7
- package/source/js/_app/pjax/refresh.ts +3 -31
- package/source/js/_app/pjax/siteInit.ts +9 -22
- package/source/js/_app/player.ts +2 -0
- package/source/js/_app/library/loadFile.ts +0 -47
- package/source/js/_app/library/scriptPjax.ts +0 -56
package/README.md
CHANGED
package/_config.yml
CHANGED
@@ -374,7 +374,6 @@ vendors:
|
|
374
374
|
source: cdnjs
|
375
375
|
url: jquery/3.5.1/jquery.min.js
|
376
376
|
sri: "sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"
|
377
|
-
async_js:
|
378
377
|
fancybox:
|
379
378
|
source: cdnjs
|
380
379
|
url: fancybox/3.5.7/jquery.fancybox.min.js
|
@@ -383,6 +382,7 @@ vendors:
|
|
383
382
|
source: cdnjs
|
384
383
|
url: justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
385
384
|
sri: "sha384-TOxsBplaL96/QDWPIUg+ye3v89qSE3s22XNtJMmCeZEep3cVDmXy1zEfZvVv+y2m"
|
385
|
+
async_js:
|
386
386
|
copy_tex:
|
387
387
|
source: cdnjs
|
388
388
|
url: KaTeX/0.16.9/contrib/copy-tex.min.js
|
package/_images.yml
CHANGED
@@ -1,9 +1,2 @@
|
|
1
1
|
# 此images已失效,见https://github.com/theme-shoka-x/hexo-theme-shokaX/issues/6
|
2
|
-
- 6833939bly1giciryrr3rj20zk0m8nhk.jpg
|
3
|
-
- 6833939bly1gicis081o9j20zk0m8dmr.jpg
|
4
|
-
- 6833939bly1gicis3attqj20zk0m8k7l.jpg
|
5
|
-
- 6833939bly1giciszlczyj20zk0m816d.jpg
|
6
|
-
- 6833939bly1gicit31ffoj20zk0m8naf.jpg
|
7
|
-
- 6833939bly1gicit4jrvuj20zk0m8785.jpg
|
8
|
-
- 6833939bly1gicitcxhpij20zk0m8hdt.jpg
|
9
2
|
|
@@ -45,6 +45,11 @@ if fontConfig
|
|
45
45
|
!= preloadjs()
|
46
46
|
!= load_async_css()
|
47
47
|
|
48
|
+
// 临时处理
|
49
|
+
link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css")
|
50
|
+
link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/justifiedGallery/3.8.1/css/justifiedGallery.min.css")
|
51
|
+
//link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/KaTeX/0.16.9/katex.min.css")
|
52
|
+
!= _css('mermaid.css')
|
48
53
|
if theme.experiments.cloudflarePatch
|
49
54
|
!= _js('cf-patch.js')
|
50
55
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
- var timeNow = new Date().getTime()
|
3
3
|
if theme.pwa.enable
|
4
4
|
- var sworker = theme.pwa.serviceworker
|
5
|
-
script(
|
5
|
+
script(async).
|
6
6
|
if ('serviceWorker' in navigator) {
|
7
7
|
navigator.serviceWorker.register("/#{sworker}?time=#{timeNow}").then(async (reg) => {
|
8
8
|
if (window.localStorage.getItem('install') !== 'true') {
|
@@ -134,6 +134,8 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
134
134
|
|
135
135
|
!= vendor_js('pace')
|
136
136
|
!= vendor_js('jquery')
|
137
|
+
!= vendor_js('justifiedGallery')
|
138
|
+
!= vendor_js('fancybox')
|
137
139
|
|
138
140
|
if theme.polyfill.enable
|
139
141
|
script(src=`https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=${theme.polyfill.features}` defer)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- var googleId = theme.visitor.googleAnalytics
|
2
2
|
if googleId
|
3
3
|
script(async, src=`https://www.googletagmanager.com/gtag/js?id=${ googleId }`)
|
4
|
-
script
|
4
|
+
script.
|
5
5
|
window.dataLayer = window.dataLayer || [];
|
6
6
|
function gtag() {
|
7
7
|
dataLayer.push(arguments);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.5.0-dev-
|
3
|
+
"version": "0.5.0-dev-31f9f21",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
@@ -13,23 +13,23 @@
|
|
13
13
|
},
|
14
14
|
"devDependencies": {
|
15
15
|
"@types/fancybox": "^3.5.7",
|
16
|
-
"@types/jquery": "^3.5.
|
16
|
+
"@types/jquery": "^3.5.32",
|
17
17
|
"@types/js-yaml": "^4.0.9",
|
18
18
|
"@types/katex": "^0.16.7",
|
19
|
-
"@types/node": "^22.
|
19
|
+
"@types/node": "^22.8.6",
|
20
20
|
"@types/quicklink": "^2.3.4",
|
21
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
22
|
-
"@typescript-eslint/parser": "^8.
|
23
|
-
"eslint": "^9.
|
21
|
+
"@typescript-eslint/eslint-plugin": "^8.12.2",
|
22
|
+
"@typescript-eslint/parser": "^8.12.2",
|
23
|
+
"eslint": "^9.13.0",
|
24
24
|
"eslint-config-standard": "~17",
|
25
|
-
"eslint-plugin-vue": "^9.
|
25
|
+
"eslint-plugin-vue": "^9.30.0",
|
26
26
|
"glob": "^11.0.0",
|
27
|
-
"typescript": "^5.6.
|
27
|
+
"typescript": "^5.6.3"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@algolia/client-search": "^5.
|
30
|
+
"@algolia/client-search": "^5.12.0",
|
31
31
|
"@waline/client": "^3.3.2",
|
32
|
-
"algoliasearch": "5.
|
32
|
+
"algoliasearch": "5.12.0",
|
33
33
|
"esbuild": "^0.24.0",
|
34
34
|
"hexo": "^7.3.0",
|
35
35
|
"hexo-algoliasearch": "^2.0.1",
|
@@ -38,18 +38,17 @@
|
|
38
38
|
"hexo-pagination": "^4.0.0",
|
39
39
|
"hexo-renderer-pug": "^3.0.0",
|
40
40
|
"hexo-util": "^3.3.0",
|
41
|
-
"instantsearch.js": "^4.
|
41
|
+
"instantsearch.js": "^4.75.3",
|
42
42
|
"js-yaml": "^4.1.0",
|
43
43
|
"katex": "^0.16.11",
|
44
44
|
"mouse-firework": "^0.0.6",
|
45
45
|
"quicklink": "^2.3.0",
|
46
46
|
"theme-shokax-anime": "^0.0.7",
|
47
|
-
"theme-shokax-pjax": "^0.0.3",
|
48
47
|
"twikoo": "^1.6.39",
|
49
48
|
"unlazy": "^0.11.3"
|
50
49
|
},
|
51
50
|
"engines": {
|
52
|
-
"node": ">=
|
51
|
+
"node": ">=20.0.0"
|
53
52
|
},
|
54
53
|
"engineStrict": true,
|
55
54
|
"pnpm": {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { CONFIG } from '../globals/globalVars'
|
2
2
|
import { init, RecentComments } from '@waline/client'
|
3
|
+
// @ts-ignore
|
3
4
|
import { pageviewCount } from '@waline/client/pageview'
|
5
|
+
// @ts-ignore
|
4
6
|
await import('@waline/client/style')
|
5
7
|
|
6
8
|
export const walineComment = function () {
|
@@ -74,7 +76,6 @@ export const walineRecentComments = async function () {
|
|
74
76
|
commentTime.className = 'breadcrumb'
|
75
77
|
commentTime.innerText = `${item.nick} @ ${item.time}`
|
76
78
|
commentLink.href = root + item.href
|
77
|
-
commentLink['data-pjax-state'] = 'data-pjax-state'
|
78
79
|
commentEl.className = 'item'
|
79
80
|
|
80
81
|
commentText.appendChild(document.createElement('br'))
|
@@ -40,7 +40,6 @@ export const twikooRecentComments = async function () {
|
|
40
40
|
commentTime.className = 'breadcrumb'
|
41
41
|
commentTime.innerText = `${item.nick} @ ${item.time}`
|
42
42
|
commentLink.href = root + item.href
|
43
|
-
commentLink['data-pjax-state'] = 'data-pjax-state'
|
44
43
|
commentEl.className = 'item'
|
45
44
|
|
46
45
|
commentText.appendChild(document.createElement('br'))
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { $dom } from '../library/dom'
|
2
|
-
import Pjax from 'theme-shokax-pjax'
|
3
1
|
import initProto from '../library/proto'
|
4
2
|
|
5
3
|
export const CONFIG = shokax_CONFIG
|
@@ -29,7 +27,6 @@ export let oWinHeight = window.innerHeight
|
|
29
27
|
export let oWinWidth = window.innerWidth
|
30
28
|
export let LOCAL_HASH = 0
|
31
29
|
export let LOCAL_URL = window.location.href
|
32
|
-
export let pjax:Pjax
|
33
30
|
|
34
31
|
export function setSiteNavHeight (value:number):void {
|
35
32
|
siteNavHeight = value
|
@@ -66,10 +63,6 @@ export function setLocalUrl (value:string):void {
|
|
66
63
|
LOCAL_URL = value
|
67
64
|
}
|
68
65
|
|
69
|
-
export function setPjax (value:Pjax):void {
|
70
|
-
pjax = value
|
71
|
-
}
|
72
|
-
|
73
66
|
export function setOriginTitle (value:string):void {
|
74
67
|
originTitle = value
|
75
68
|
}
|
@@ -1,76 +1,66 @@
|
|
1
1
|
import { $dom } from '../library/dom'
|
2
|
-
import { vendorCss, vendorJs } from '../library/loadFile'
|
3
2
|
import { insertAfter } from '../library/proto'
|
4
3
|
|
5
4
|
// TODO 使用PhotoSwipe替换Fancybox
|
6
5
|
export const postFancybox = (p:string) => {
|
7
6
|
if (document.querySelector(p + ' .md img')) {
|
8
|
-
|
9
|
-
vendorCss('justifiedGallery')
|
10
|
-
vendorJs('jquery', ()=>{
|
11
|
-
vendorJs('justifiedGallery',()=>{
|
12
|
-
vendorJs('fancybox', () => {
|
13
|
-
const q = jQuery.noConflict()
|
7
|
+
const q = jQuery.noConflict()
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
$dom.each(p + ' p.gallery', (element) => {
|
10
|
+
const box = document.createElement('div')
|
11
|
+
box.className = 'gallery'
|
12
|
+
box.setAttribute('data-height', String(element.getAttribute('data-height') || 220))
|
19
13
|
|
20
|
-
|
14
|
+
box.innerHTML = element.innerHTML.replace(/<br>/g, '')
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
|
27
|
-
const $image = q(element)
|
28
|
-
const imageLink = $image.attr('data-src') || $image.attr('src') // 替换
|
29
|
-
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a')
|
30
|
-
let info; let captionClass = 'image-info'
|
31
|
-
if (!$image.is('a img')) {
|
32
|
-
$image.data('safe-src', imageLink)
|
33
|
-
if (!$image.is('.gallery img')) {
|
34
|
-
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default')
|
35
|
-
} else {
|
36
|
-
captionClass = 'jg-caption'
|
37
|
-
}
|
38
|
-
}
|
39
|
-
if ((info = element.getAttribute('title'))) {
|
40
|
-
$imageWrapLink.attr('data-caption', info)
|
41
|
-
const para = document.createElement('span')
|
42
|
-
const txt = document.createTextNode(info)
|
43
|
-
para.appendChild(txt)
|
44
|
-
para.addClass(captionClass)
|
45
|
-
insertAfter(element, para)
|
46
|
-
}
|
47
|
-
})
|
16
|
+
element.parentNode.insertBefore(box, element)
|
17
|
+
element.remove()
|
18
|
+
})
|
48
19
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
20
|
+
$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
|
21
|
+
const $image = q(element)
|
22
|
+
const imageLink = $image.attr('data-src') || $image.attr('src') // 替换
|
23
|
+
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a')
|
24
|
+
let info; let captionClass = 'image-info'
|
25
|
+
if (!$image.is('a img')) {
|
26
|
+
$image.data('safe-src', imageLink)
|
27
|
+
if (!$image.is('.gallery img')) {
|
28
|
+
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default')
|
29
|
+
} else {
|
30
|
+
captionClass = 'jg-caption'
|
31
|
+
}
|
32
|
+
}
|
33
|
+
if ((info = element.getAttribute('title'))) {
|
34
|
+
$imageWrapLink.attr('data-caption', info)
|
35
|
+
const para = document.createElement('span')
|
36
|
+
const txt = document.createTextNode(info)
|
37
|
+
para.appendChild(txt)
|
38
|
+
para.addClass(captionClass)
|
39
|
+
insertAfter(element, para)
|
40
|
+
}
|
41
|
+
})
|
60
42
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
})
|
71
|
-
// @ts-ignore
|
72
|
-
}, window.jQuery)
|
43
|
+
$dom.each(p + ' div.gallery', (el, i) => {
|
44
|
+
// @ts-ignore
|
45
|
+
q(el).justifiedGallery({
|
46
|
+
rowHeight: q(el).data('height') || 120,
|
47
|
+
rel: 'gallery-' + i
|
48
|
+
}).on('jg.complete', function () {
|
49
|
+
q(this).find('a').each((k, ele) => {
|
50
|
+
ele.setAttribute('data-fancybox', 'gallery-' + i)
|
51
|
+
})
|
73
52
|
})
|
74
53
|
})
|
54
|
+
|
55
|
+
q.fancybox.defaults.hash = false
|
56
|
+
q(p + ' .fancybox').fancybox({
|
57
|
+
loop: true,
|
58
|
+
// @ts-ignore
|
59
|
+
helpers: {
|
60
|
+
overlay: {
|
61
|
+
locked: false
|
62
|
+
}
|
63
|
+
}
|
64
|
+
})
|
75
65
|
}
|
76
66
|
}
|
@@ -231,15 +231,15 @@ export const postBeauty = () => {
|
|
231
231
|
element.className = ['primary', 'success', 'info', 'warning', 'danger'][Math.floor(Math.random() * 5)]
|
232
232
|
})
|
233
233
|
|
234
|
-
if (__shokax_player__) {
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
}
|
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
243
|
|
244
244
|
const angleDown = document.querySelectorAll('.show-btn .i-angle-down')
|
245
245
|
if (angleDown.length) {
|
@@ -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 (
|
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,7 @@ export function algoliaSearch (pjax) {
|
|
105
101
|
}
|
106
102
|
})
|
107
103
|
document.querySelector('.close-btn').addEventListener('click', onPopupClose)
|
108
|
-
window.addEventListener('pjax:success', onPopupClose)
|
104
|
+
// window.addEventListener('pjax:success', onPopupClose)
|
109
105
|
window.addEventListener('keyup', (event) => {
|
110
106
|
if (event.key === 'Escape') {
|
111
107
|
onPopupClose()
|
@@ -45,13 +45,13 @@ export default function domInit () {
|
|
45
45
|
goToComment.addEventListener('click', goToCommentHandle)
|
46
46
|
showContents.addEventListener('click', sideBarToggleHandle)
|
47
47
|
|
48
|
-
if (__shokax_player__) {
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
48
|
+
// if (__shokax_player__) {
|
49
|
+
// mediaPlayer(toolPlayer)
|
50
|
+
//
|
51
|
+
// document.querySelector('main').addEventListener('click', () => {
|
52
|
+
// toolPlayer.player.mini()
|
53
|
+
// })
|
54
|
+
// }
|
55
55
|
|
56
56
|
const createIntersectionObserver = () => {
|
57
57
|
// waves在视口外时停止动画
|
@@ -1,47 +1,23 @@
|
|
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
6
|
toolPlayer
|
14
7
|
} from '../globals/globalVars'
|
15
|
-
import {
|
8
|
+
import { positionInit } from '../globals/tools'
|
16
9
|
import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar'
|
17
10
|
import { Loader, isOutime } from '../globals/thirdparty'
|
18
11
|
import { tabFormat } from '../page/tab'
|
19
12
|
import { lazyLoad } from 'unlazy'
|
20
13
|
|
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
|
-
|
36
14
|
export const siteRefresh = async (reload) => {
|
37
15
|
setLocalHash(0)
|
38
16
|
setLocalUrl(window.location.href)
|
39
17
|
|
40
|
-
|
41
|
-
|
42
|
-
// vendorJs('copy_tex')
|
18
|
+
// @ts-ignore
|
19
|
+
await import('katex/dist/katex.min.css')
|
43
20
|
await import('katex/dist/contrib/copy-tex.mjs')
|
44
|
-
vendorCss('mermaid')
|
45
21
|
|
46
22
|
// 懒加载背景图
|
47
23
|
const lazyBg = new IntersectionObserver(function (entries, observer) {
|
@@ -61,10 +37,6 @@ export const siteRefresh = async (reload) => {
|
|
61
37
|
lazyBg.observe(el)
|
62
38
|
})
|
63
39
|
|
64
|
-
if (reload !== 1) {
|
65
|
-
$dom.each('script[data-pjax]', pjaxScript)
|
66
|
-
}
|
67
|
-
|
68
40
|
setOriginTitle(document.title)
|
69
41
|
|
70
42
|
resizeHandle()
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import domInit from './domInit'
|
2
|
-
import {
|
2
|
+
import { siteRefresh } from './refresh'
|
3
3
|
import { cloudflareInit } from '../components/cloudflare'
|
4
|
-
import { BODY, CONFIG,
|
4
|
+
import { BODY, CONFIG, setSiteSearch, siteSearch } from '../globals/globalVars'
|
5
5
|
import { autoDarkmode, themeColorListener } from '../globals/themeColor'
|
6
6
|
import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles'
|
7
7
|
import { pagePosition } from '../globals/tools'
|
8
|
-
import Pjax from 'theme-shokax-pjax'
|
9
8
|
import { initVue } from '../library/vue'
|
10
9
|
import { $dom } from '../library/dom'
|
11
10
|
import { createChild } from '../library/proto'
|
@@ -15,18 +14,6 @@ const siteInit = async () => {
|
|
15
14
|
initVue()
|
16
15
|
domInit()
|
17
16
|
|
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
17
|
CONFIG.quicklink.ignores = LOCAL.ignores
|
31
18
|
import('quicklink').then(({listen}) => {
|
32
19
|
listen(CONFIG.quicklink)
|
@@ -53,7 +40,7 @@ const siteInit = async () => {
|
|
53
40
|
}
|
54
41
|
|
55
42
|
import('../page/search').then(({algoliaSearch}) => {
|
56
|
-
algoliaSearch(
|
43
|
+
algoliaSearch()
|
57
44
|
})
|
58
45
|
|
59
46
|
// Handle and trigger popup window
|
@@ -83,13 +70,13 @@ const siteInit = async () => {
|
|
83
70
|
passive: true
|
84
71
|
})
|
85
72
|
|
86
|
-
window.addEventListener('pjax:send', pjaxReload, {
|
87
|
-
|
88
|
-
})
|
73
|
+
// window.addEventListener('pjax:send', pjaxReload, {
|
74
|
+
// passive: true
|
75
|
+
// })
|
89
76
|
|
90
|
-
window.addEventListener('pjax:success', siteRefresh, {
|
91
|
-
|
92
|
-
}) // 默认会传入一个event参数
|
77
|
+
// window.addEventListener('pjax:success', siteRefresh, {
|
78
|
+
// passive: true
|
79
|
+
// }) // 默认会传入一个event参数
|
93
80
|
|
94
81
|
window.addEventListener('beforeunload', () => {
|
95
82
|
pagePosition()
|
package/source/js/_app/player.ts
CHANGED
@@ -1,47 +0,0 @@
|
|
1
|
-
import { getScript } from './scriptPjax'
|
2
|
-
import { CONFIG } from '../globals/globalVars'
|
3
|
-
import { createChild } from './proto'
|
4
|
-
|
5
|
-
/**
|
6
|
-
* 用途是根据不同的资源名称和类型生成相应的资源 URL。
|
7
|
-
*/
|
8
|
-
const assetUrl = (asset: string, type: string): string => {
|
9
|
-
const str = CONFIG[asset][type].url as string
|
10
|
-
if (str.startsWith('https')) {
|
11
|
-
return str
|
12
|
-
}
|
13
|
-
if (str.startsWith('http')) {
|
14
|
-
console.warn(`Upgrade vendor ${asset}/${type} to HTTPS, Please use HTTPS url instead of HTTP url.`)
|
15
|
-
return str.replace('http', 'https')
|
16
|
-
}
|
17
|
-
return `/${str}`
|
18
|
-
}
|
19
|
-
|
20
|
-
export const vendorJs = (type: string, callback?: Function, condition?: string) => {
|
21
|
-
if (LOCAL[type]) {
|
22
|
-
getScript(assetUrl('js', type),CONFIG['js'][type].sri, callback || function () {
|
23
|
-
window[type] = true
|
24
|
-
}, condition || window[type])
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
export const vendorCss = (type: string, condition?: string): void => {
|
29
|
-
if (window['css' + type]) {
|
30
|
-
return
|
31
|
-
}
|
32
|
-
|
33
|
-
if (LOCAL[type]) {
|
34
|
-
const attr:any = {
|
35
|
-
rel: 'stylesheet',
|
36
|
-
href: assetUrl('css', type),
|
37
|
-
}
|
38
|
-
const vendor = CONFIG['css'][type] as vendorUrl
|
39
|
-
if (!vendor.local) {
|
40
|
-
attr.integrity = vendor.sri
|
41
|
-
attr.crossOrigin = 'anonymous'
|
42
|
-
}
|
43
|
-
createChild(document.head, 'link', attr)
|
44
|
-
|
45
|
-
window['css' + type] = true
|
46
|
-
}
|
47
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
export const getScript = (url: string,sri: string, callback?: Function, condition?: string): void => {
|
2
|
-
// url: 脚本文件的URL地址
|
3
|
-
// callback: 当脚本加载完成时要执行的回调函数
|
4
|
-
// condition: 可选的条件参数,如果存在,则执行callback
|
5
|
-
if (condition) {
|
6
|
-
// 如果条件存在,则执行回调函数
|
7
|
-
callback()
|
8
|
-
} else {
|
9
|
-
let script = document.createElement('script')
|
10
|
-
|
11
|
-
// @ts-ignore
|
12
|
-
script.onload = function (_, isAbort: boolean) {
|
13
|
-
// _: 事件对象
|
14
|
-
// isAbort: 是否中止
|
15
|
-
// @ts-ignore
|
16
|
-
if (isAbort || !script.readyState) {
|
17
|
-
console.log('abort!')
|
18
|
-
script.onload = null
|
19
|
-
script = undefined
|
20
|
-
if (!isAbort && callback) setTimeout(callback, 0)
|
21
|
-
}
|
22
|
-
}
|
23
|
-
script.src = url
|
24
|
-
script.integrity = sri
|
25
|
-
script.crossOrigin = 'anonymous'
|
26
|
-
document.head.appendChild(script)
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
export const pjaxScript = (element: HTMLScriptElement) => {
|
31
|
-
const { text, parentNode, id, className, type, src, dataset } = element
|
32
|
-
const code = text || element.textContent || element.innerHTML || ''
|
33
|
-
parentNode.removeChild(element)
|
34
|
-
const script = document.createElement('script')
|
35
|
-
if (id) {
|
36
|
-
script.id = id
|
37
|
-
}
|
38
|
-
if (className) {
|
39
|
-
script.className = className
|
40
|
-
}
|
41
|
-
if (type) {
|
42
|
-
script.type = type
|
43
|
-
}
|
44
|
-
if (src) {
|
45
|
-
// Force synchronous loading of peripheral JS.
|
46
|
-
script.src = src
|
47
|
-
script.async = false
|
48
|
-
}
|
49
|
-
if (dataset.pjax !== undefined) {
|
50
|
-
script.dataset.pjax = ''
|
51
|
-
}
|
52
|
-
if (code !== '') {
|
53
|
-
script.appendChild(document.createTextNode(code))
|
54
|
-
}
|
55
|
-
parentNode.appendChild(script)
|
56
|
-
}
|