hexo-theme-shokax 0.5.0-dev-58aa58e → 0.5.0-dev-4774f82

Sign up to get free protection for your applications and to get access to all the features.
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,10 +382,19 @@ 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
389
389
  sri: "sha384-ww/583aHhxWkz5DEVn6OKtNiIaLi2iBRNZXfJRiY1Ai7tnJ9UXpEsyvOITVpTl4A"
390
+ fancybox:
391
+ source: cdnjs
392
+ url: fancybox/3.5.7/jquery.fancybox.min.js
393
+ sri: "sha384-Zm+UU4tdcfAm29vg+MTbfu//q5B/lInMbMCr4T8c9rQFyOv6PlfQYpB5wItcXWe7"
394
+ justifiedGallery:
395
+ source: cdnjs
396
+ url: justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
397
+ sri: "sha384-TOxsBplaL96/QDWPIUg+ye3v89qSE3s22XNtJMmCeZEep3cVDmXy1zEfZvVv+y2m"
390
398
  css:
391
399
  katex:
392
400
  source: cdnjs
@@ -45,6 +45,12 @@ 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
+ //link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/KaTeX/0.16.9/katex.min.css")
53
+ != _css('mermaid.css')
48
54
  if theme.experiments.cloudflarePatch
49
55
  != _js('cf-patch.js')
50
56
 
@@ -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(data-pjax async).
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') {
@@ -2,10 +2,6 @@ include ../_mixin/breadcrumb.pug
2
2
  include ../_mixin/sidebar.pug
3
3
  include ../_mixin/widgets.pug
4
4
 
5
- - ignores = []
6
- if (theme.quicklink.ignores)
7
- - ignores.push(theme.quicklink.ignores)
8
-
9
5
  - var covers = _cover_index(page, 6)
10
6
  - var enableFixedCover = theme.homeConfig?.fixedCover
11
7
  - var enablePreload = theme.experiments?.coverConfig?.enablePreload
@@ -120,12 +116,7 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
120
116
  essay: `#{__('quiz.essay')}`,
121
117
  gap_fill: `#{__('quiz.gap_fill')}`,
122
118
  mistake: `#{__('quiz.mistake')}`
123
- },
124
- ignores: [
125
- (uri) => uri.includes('#'),
126
- (uri) => new RegExp(LOCAL.path + '$').test(uri),
127
- !{JSON.stringify(ignores)}
128
- ]
119
+ }
129
120
  };
130
121
 
131
122
  != partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
@@ -134,6 +125,8 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
134
125
 
135
126
  != vendor_js('pace')
136
127
  != vendor_js('jquery')
128
+ != vendor_js('justifiedGallery')
129
+ != vendor_js('fancybox')
137
130
 
138
131
  if theme.polyfill.enable
139
132
  script(src=`https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=${theme.polyfill.features}` defer)
@@ -1,6 +1,6 @@
1
1
  - var hmSrc = `https://hm.baidu.com/hm.js?${ theme.visitor.baiduAnalytics }`
2
2
  if theme.visitor.baiduAnalytics
3
- script(data-pjax=true).
3
+ script.
4
4
  var _hmt = _hmt || [];
5
5
  (function () {
6
6
  const hm = document.createElement("script");
@@ -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(data-pjax=true).
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-58aa58e",
3
+ "version": "0.5.0-dev-4774f82",
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.30",
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.5.5",
19
+ "@types/node": "^22.8.6",
20
20
  "@types/quicklink": "^2.3.4",
21
- "@typescript-eslint/eslint-plugin": "^8.6.0",
22
- "@typescript-eslint/parser": "^8.6.0",
23
- "eslint": "^9.11.0",
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.28.0",
25
+ "eslint-plugin-vue": "^9.30.0",
26
26
  "glob": "^11.0.0",
27
- "typescript": "^5.6.2"
27
+ "typescript": "^5.6.3"
28
28
  },
29
29
  "dependencies": {
30
- "@algolia/client-search": "^5.5.3",
30
+ "@algolia/client-search": "^5.12.0",
31
31
  "@waline/client": "^3.3.2",
32
- "algoliasearch": "5.10.2",
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,16 @@
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.74.1",
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
- "quicklink": "^2.3.0",
46
45
  "theme-shokax-anime": "^0.0.7",
47
- "theme-shokax-pjax": "^0.0.3",
48
46
  "twikoo": "^1.6.39",
49
47
  "unlazy": "^0.11.3"
50
48
  },
51
49
  "engines": {
52
- "node": ">=18.0.0"
50
+ "node": ">=20.0.0"
53
51
  },
54
52
  "engineStrict": true,
55
53
  "pnpm": {
@@ -59,10 +59,6 @@ hexo.extend.generator.register("script", function(locals) {
59
59
  enable: theme.outime.enable,
60
60
  days: theme.outime.days
61
61
  },
62
- quicklink: {
63
- timeout: theme.quicklink.timeout,
64
- priority: theme.quicklink.priority
65
- },
66
62
  playerAPI: theme.playerAPI,
67
63
  experiments: {
68
64
  copyrightLength: theme.experiments.copyrightLength
@@ -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 () {
@@ -109,11 +109,6 @@ interface configType {
109
109
  region: string
110
110
  }
111
111
  walinePageView: boolean
112
- quicklink: {
113
- ignores: any
114
- timeout: number
115
- priority: boolean
116
- }
117
112
  playerAPI: string
118
113
  experiments: {
119
114
  copyrightLength: number;
@@ -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
- vendorCss('fancybox')
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
- $dom.each(p + ' p.gallery', (element) => {
16
- const box = document.createElement('div')
17
- box.className = 'gallery'
18
- box.setAttribute('data-height', String(element.getAttribute('data-height') || 220))
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
- box.innerHTML = element.innerHTML.replace(/<br>/g, '')
14
+ box.innerHTML = element.innerHTML.replace(/<br>/g, '')
21
15
 
22
- element.parentNode.insertBefore(box, element)
23
- element.remove()
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
- $dom.each(p + ' div.gallery', (el, i) => {
50
- // @ts-ignore
51
- q(el).justifiedGallery({
52
- rowHeight: q(el).data('height') || 120,
53
- rel: 'gallery-' + i
54
- }).on('jg.complete', function () {
55
- q(this).find('a').each((k, ele) => {
56
- ele.setAttribute('data-fancybox', 'gallery-' + i)
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
- q.fancybox.defaults.hash = false
62
- q(p + ' .fancybox').fancybox({
63
- loop: true,
64
- // @ts-ignore
65
- helpers: {
66
- overlay: {
67
- locked: false
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
  }
@@ -1,46 +1,21 @@
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
2
  import { resizeHandle } from '../globals/handles'
6
3
  import {
7
- CONFIG,
8
- loadCat,
9
- menuToggle,
10
4
  setLocalHash, setLocalUrl, setOriginTitle,
11
- sideBar,
12
- toolPlayer
13
5
  } from '../globals/globalVars'
14
- import { pagePosition, positionInit } from '../globals/tools'
6
+ import { positionInit } from '../globals/tools'
15
7
  import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar'
16
8
  import { Loader, isOutime } from '../globals/thirdparty'
17
9
  import { tabFormat } from '../page/tab'
18
10
  import { lazyLoad } from 'unlazy'
19
11
 
20
- export const pjaxReload = () => {
21
- pagePosition()
22
-
23
- if (sideBar.hasClass('on')) {
24
- transition(sideBar, 0, () => {
25
- sideBar.removeClass('on')
26
- menuToggle.removeClass('close')
27
- }) // 'transition.slideRightOut'
28
- }
29
- const mainNode = document.getElementById('main')
30
- mainNode.innerHTML = ''
31
- mainNode.appendChild(loadCat.lastChild.cloneNode(true))
32
- pageScroll(0)
33
- }
34
-
35
12
  export const siteRefresh = async (reload) => {
36
13
  setLocalHash(0)
37
14
  setLocalUrl(window.location.href)
38
15
 
39
- vendorCss('katex');
16
+ // @ts-ignore
40
17
  // await import('katex/dist/katex.min.css')
41
- // vendorJs('copy_tex')
42
18
  await import('katex/dist/contrib/copy-tex.mjs')
43
- vendorCss('mermaid')
44
19
 
45
20
  // 懒加载背景图
46
21
  const lazyBg = new IntersectionObserver(function (entries, observer) {
@@ -118,10 +93,15 @@ export const siteRefresh = async (reload) => {
118
93
  tabFormat()
119
94
  }
120
95
 
121
- if (__shokax_player__) {
122
- toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {})
96
+ // if (__shokax_player__) {
97
+ // toolPlayer.player.load(LOCAL.audio || CONFIG.audio || {})
98
+ // }
99
+ if (sessionStorage.getItem('loaded') === 'true') {
100
+ Loader.hide(30)
101
+ } else {
102
+ sessionStorage.setItem('loaded', 'true')
103
+ Loader.hide(500)
123
104
  }
124
- Loader.hide(100)
125
105
 
126
106
  setTimeout(() => {
127
107
  positionInit()
@@ -14,11 +14,6 @@ const siteInit = async () => {
14
14
  initVue()
15
15
  domInit()
16
16
 
17
- CONFIG.quicklink.ignores = LOCAL.ignores
18
- import('quicklink').then(({listen}) => {
19
- listen(CONFIG.quicklink)
20
- })
21
-
22
17
  autoDarkmode()
23
18
 
24
19
  if (__shokax_VL__) {
@@ -70,18 +65,11 @@ const siteInit = async () => {
70
65
  passive: true
71
66
  })
72
67
 
73
- // window.addEventListener('pjax:send', pjaxReload, {
74
- // passive: true
75
- // })
76
-
77
- // window.addEventListener('pjax:success', siteRefresh, {
78
- // passive: true
79
- // }) // 默认会传入一个event参数
80
-
81
68
  window.addEventListener('beforeunload', () => {
82
69
  pagePosition()
83
70
  })
84
71
  await siteRefresh(1)
72
+ // TODO 修复内页跳转后重复出现加载动画的问题
85
73
  }
86
74
 
87
75
  cloudflareInit()
@@ -1,44 +0,0 @@
1
- import { CONFIG } from '../globals/globalVars'
2
- import { createChild } from './proto'
3
-
4
- /**
5
- * 用途是根据不同的资源名称和类型生成相应的资源 URL。
6
- */
7
- const assetUrl = (asset: string, type: string): string => {
8
- const str = CONFIG[asset][type].url as string
9
- if (str.startsWith('https')) {
10
- return str
11
- }
12
- if (str.startsWith('http')) {
13
- console.warn(`Upgrade vendor ${asset}/${type} to HTTPS, Please use HTTPS url instead of HTTP url.`)
14
- return str.replace('http', 'https')
15
- }
16
- return `/${str}`
17
- }
18
-
19
- export const vendorJs = (type: string, callback?: Function, condition?: string) => {
20
- if (LOCAL[type]) {
21
- assetUrl('js', type)
22
- }
23
- }
24
-
25
- export const vendorCss = (type: string, condition?: string): void => {
26
- if (window['css' + type]) {
27
- return
28
- }
29
-
30
- if (LOCAL[type]) {
31
- const attr:any = {
32
- rel: 'stylesheet',
33
- href: assetUrl('css', type),
34
- }
35
- const vendor = CONFIG['css'][type] as vendorUrl
36
- if (!vendor.local) {
37
- attr.integrity = vendor.sri
38
- attr.crossOrigin = 'anonymous'
39
- }
40
- createChild(document.head, 'link', attr)
41
-
42
- window['css' + type] = true
43
- }
44
- }