hexo-theme-shokax 0.4.14 → 0.4.16

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/_config.yml CHANGED
@@ -27,10 +27,13 @@ experiments:
27
27
  optimizeLongPosts: false # 优化长文章,这能让长文章的FPS提升70%-150%并解决假死问题,但存在一些副作用
28
28
  # 具体见https://docs.kaitaku.xyz/guide/theme.html#%E9%95%BF%E6%96%87%E7%AB%A0%E4%BC%98%E5%8C%96
29
29
  mobileWidth: 820px # 移动版和桌面版导航栏最短切换长度
30
+ # 使用 Cloudflare Rocket 或其他优化功能时需开启下列补丁,否则主题无法渲染
31
+ cloudflarePatch: false
30
32
  coverConfig:
31
33
  enableCover: true # 是否开启头图
32
34
  enablePreload: true #是否开启预加载头图
33
- enableNextGradientCover: true # 使用CSS渐变作为上/下一页封面
35
+ enableNextGradientCover: false # 使用CSS渐变作为上/下一页封面
36
+ copyrightLength: 50 # 自定义复制时显示copyright的长度
34
37
 
35
38
  homeConfig:
36
39
  gradient: false # 使用CSS渐变作为文章封面
@@ -99,13 +102,13 @@ polyfill:
99
102
  # 参阅 https://github.com/D-Sketon/mouse-firework
100
103
  fireworks:
101
104
  enable: true
102
- options:
105
+ options:
103
106
  excludeElements: ["a"]
104
107
  particles:
105
108
  - shape: circle
106
109
  move: ["emit"]
107
110
  easing: easeOutExpo
108
- colors:
111
+ colors:
109
112
  - "rgba(255,182,185,.9)"
110
113
  - "rgba(250,227,217,.9)"
111
114
  - "rgba(187,222,214,.9)"
@@ -225,7 +228,6 @@ summary:
225
228
  remote: "https://api.openai.com"
226
229
  apikey: "key"
227
230
 
228
-
229
231
  # Social Links
230
232
  # Usage: `Key: permalink || icon || color`
231
233
  # Key is the link label showing to end users.
@@ -401,4 +403,4 @@ vendors:
401
403
  justifiedGallery:
402
404
  source: cdnjs
403
405
  url: justifiedGallery/3.8.1/css/justifiedGallery.min.css
404
- sri: "sha384-V/1Ew9pYm8xpy/L9i078ZXT6HSEOrGC6KNFYLbXOdtqb3+c6brpGqVzZtEPSQOiz"
406
+ sri: "sha384-V/1Ew9pYm8xpy/L9i078ZXT6HSEOrGC6KNFYLbXOdtqb3+c6brpGqVzZtEPSQOiz"
@@ -45,6 +45,9 @@ if fontConfig
45
45
  != preloadjs()
46
46
  != load_async_css()
47
47
 
48
+ if theme.experiments.cloudflarePatch
49
+ != _js('cf-patch.js')
50
+
48
51
  include pwa.pug
49
52
 
50
53
  - var qw = theme?.qweather?.enable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
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",
@@ -46,8 +46,7 @@
46
46
  "theme-shokax-anime": "^0.0.7",
47
47
  "theme-shokax-pjax": "^0.0.3",
48
48
  "twikoo": "^1.6.39",
49
- "unlazy": "^0.11.3",
50
- "vue": "^3.5.7"
49
+ "unlazy": "^0.11.3"
51
50
  },
52
51
  "engines": {
53
52
  "node": ">=18.0.0"
@@ -64,6 +64,9 @@ hexo.extend.generator.register("script", function(locals) {
64
64
  priority: theme.quicklink.priority
65
65
  },
66
66
  playerAPI: theme.playerAPI,
67
+ experiments: {
68
+ copyrightLength: theme.experiments.copyrightLength
69
+ },
67
70
  audio: void 0,
68
71
  fireworks: theme.fireworks && theme.fireworks.enable && theme.fireworks.options ? theme.fireworks.options : void 0,
69
72
  waline: {
@@ -93,10 +96,12 @@ hexo.extend.generator.register("script", function(locals) {
93
96
  if (theme?.audio) {
94
97
  siteConfig.audio = theme.audio;
95
98
  }
96
- let enterPoint;
99
+ let enterPoint, patchDir;
97
100
  if (import_node_fs.default.existsSync("themes/shokaX/source/js/_app/pjax/siteInit.ts")) {
101
+ patchDir = "themes/shokaX/source/js/_app/components/cloudflare.ts";
98
102
  enterPoint = "themes/shokaX/source/js/_app/pjax/siteInit.ts";
99
103
  } else {
104
+ patchDir = "node_modules/hexo-theme-shokax/source/js/_app/components/cloudflare.ts";
100
105
  enterPoint = "node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts";
101
106
  }
102
107
  (0, import_esbuild.buildSync)({
@@ -164,5 +169,31 @@ hexo.extend.generator.register("script", function(locals) {
164
169
  });
165
170
  }
166
171
  });
172
+ if (theme.experiments.cloudflarePatch) {
173
+ const result = (0, import_esbuild.buildSync)({
174
+ entryPoints: [patchDir],
175
+ bundle: true,
176
+ platform: "browser",
177
+ format: "iife",
178
+ tsconfigRaw: {
179
+ compilerOptions: {
180
+ target: "ES2022",
181
+ esModuleInterop: true,
182
+ module: "ESNext",
183
+ moduleResolution: "Node",
184
+ skipLibCheck: true
185
+ }
186
+ },
187
+ target: ["es2022"],
188
+ minify: true,
189
+ outfile: "cf-patch.js"
190
+ });
191
+ res.push({
192
+ path: theme.js + "/cf-patch.js",
193
+ data: function() {
194
+ return import_node_fs.default.readFileSync("./cf-patch.js", { encoding: "utf-8" });
195
+ }
196
+ });
197
+ }
167
198
  return res;
168
199
  });
@@ -31,6 +31,9 @@ var fs = __toESM(require("node:fs"));
31
31
  hexo.on("generateBefore", () => {
32
32
  (0, import_injects.default)(hexo);
33
33
  fs.rmSync("./shokaxTemp", { force: true, recursive: true });
34
+ if (fs.existsSync("cf-patch.js")) {
35
+ fs.unlinkSync("cf-patch.js");
36
+ }
34
37
  if (fs.existsSync("request.lock")) {
35
38
  fs.unlinkSync("request.lock");
36
39
  }
@@ -0,0 +1,19 @@
1
+ // rocket-loader & Auto minify(cloudflare) 补丁
2
+ // cloudflare 的上述功能会导致DOMContentLoaded事件无法触发,此补丁会将DOMContentLoaded重定向为load事件
3
+ export function cloudflareInit () {
4
+ let inCloudFlare = true
5
+ window.addEventListener('DOMContentLoaded', function () {
6
+ inCloudFlare = false
7
+ })
8
+
9
+ if (document.readyState === 'loading') {
10
+ window.addEventListener('load', function () {
11
+ if (inCloudFlare) {
12
+ window.dispatchEvent(new Event('DOMContentLoaded'))
13
+ console.log('%c ☁️cloudflare patch ' + '%c running', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00')
14
+ }
15
+ })
16
+ }
17
+ }
18
+
19
+ cloudflareInit()
@@ -115,6 +115,9 @@ interface configType {
115
115
  priority: boolean
116
116
  }
117
117
  playerAPI: string
118
+ experiments: {
119
+ copyrightLength: number;
120
+ }
118
121
  }
119
122
  // esbuild 静态常量
120
123
  declare const __shokax_player__:boolean
@@ -1,21 +1,3 @@
1
- // rocket-loader & Auto minify(cloudflare) 补丁
2
- // cloudflare 的上述功能会导致DOMContentLoaded事件无法触发,此补丁会将DOMContentLoaded重定向为load事件
3
- export function cloudflareInit () {
4
- let inCloudFlare = true
5
- window.addEventListener('DOMContentLoaded', function () {
6
- inCloudFlare = false
7
- })
8
-
9
- if (document.readyState === 'loading') {
10
- window.addEventListener('load', function () {
11
- if (inCloudFlare) {
12
- window.dispatchEvent(new Event('DOMContentLoaded'))
13
- console.log('%c ☁️cloudflare patch ' + '%c running', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00')
14
- }
15
- })
16
- }
17
- }
18
-
19
1
  export const getScript = (url: string,sri: string, callback?: Function, condition?: string): void => {
20
2
  // url: 脚本文件的URL地址
21
3
  // callback: 当脚本加载完成时要执行的回调函数
@@ -1,7 +1,7 @@
1
1
  import { $dom } from '../library/dom'
2
2
  import { postFancybox } from './fancybox'
3
3
  import { clipBoard, showtip } from '../globals/tools'
4
- import { BODY } from '../globals/globalVars'
4
+ import { CONFIG, BODY } from '../globals/globalVars'
5
5
  import { pageScroll, transition } from '../library/anime'
6
6
  import { mediaPlayer } from '../player'
7
7
  import { getDisplay, setDisplay, wrapObject } from '../library/proto'
@@ -22,7 +22,7 @@ export const postBeauty = () => {
22
22
  }
23
23
 
24
24
  const copyright = document.getElementById('copyright')
25
- if (window.getSelection().toString().length > 30 && copyright) {
25
+ if (window.getSelection().toString().length > CONFIG.experiments.copyrightLength && copyright) {
26
26
  event.preventDefault()
27
27
  const author = '# ' + (copyright.querySelector('.author') as HTMLElement).innerText
28
28
  const link = '# ' + (copyright.querySelector('.link') as HTMLElement).innerText
@@ -1,6 +1,6 @@
1
1
  import domInit from './domInit'
2
2
  import { pjaxReload, siteRefresh } from './refresh'
3
- import { cloudflareInit } from '../library/scriptPjax'
3
+ import { cloudflareInit } from '../components/cloudflare'
4
4
  import { BODY, CONFIG, pjax, setPjax, setSiteSearch, siteSearch } from '../globals/globalVars'
5
5
  import { autoDarkmode, themeColorListener } from '../globals/themeColor'
6
6
  import { resizeHandle, scrollHandle, visibilityListener } from '../globals/handles'