hexo-theme-shokax 0.4.0-alpha.1 → 0.4.0-alpha.2

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.
Files changed (72) hide show
  1. package/_config.yml +5 -4
  2. package/layout/_partials/footer.pug +1 -1
  3. package/layout/_partials/head/head.pug +7 -1
  4. package/layout/_partials/header.pug +1 -1
  5. package/layout/_partials/layout.pug +0 -10
  6. package/layout/_partials/post/footer.pug +1 -2
  7. package/package.json +7 -2
  8. package/scripts/generaters/archive.js +1 -1
  9. package/scripts/generaters/script.js +44 -38
  10. package/scripts/helpers/asset.js +1 -1
  11. package/scripts/helpers/list_categories.js +0 -4
  12. package/scripts/plugin/lib/injects.js +1 -1
  13. package/source/js/_app/components/comments.ts +33 -0
  14. package/source/js/_app/components/sidebar.ts +7 -5
  15. package/source/js/_app/globals/globalVars.ts +1 -0
  16. package/source/js/_app/globals/handles.ts +6 -5
  17. package/source/js/_app/globals/themeColor.ts +1 -1
  18. package/source/js/_app/globals/thirdparty.ts +1 -1
  19. package/source/js/_app/globals/tools.ts +3 -2
  20. package/source/js/_app/library/anime.ts +6 -5
  21. package/source/js/_app/library/declare.d.ts +18 -9
  22. package/source/js/_app/library/loadFile.ts +3 -1
  23. package/source/js/_app/library/proto.ts +75 -77
  24. package/source/js/_app/library/vue.ts +38 -48
  25. package/source/js/_app/page/fancybox.ts +2 -1
  26. package/source/js/_app/page/post.ts +4 -3
  27. package/source/js/_app/page/search.ts +17 -11
  28. package/source/js/_app/page/tab.ts +3 -2
  29. package/source/js/_app/pjax/domInit.ts +5 -4
  30. package/source/js/_app/pjax/refresh.ts +5 -2
  31. package/source/js/_app/pjax/siteInit.ts +12 -7
  32. package/source/js/_app/player.ts +16 -15
  33. package/scripts/filters/locals.d.ts +0 -1
  34. package/scripts/filters/locals.ts +0 -59
  35. package/scripts/filters/post.d.ts +0 -0
  36. package/scripts/filters/post.ts +0 -6
  37. package/scripts/generaters/archive.d.ts +0 -1
  38. package/scripts/generaters/archive.ts +0 -144
  39. package/scripts/generaters/config.d.ts +0 -1
  40. package/scripts/generaters/config.ts +0 -52
  41. package/scripts/generaters/images.d.ts +0 -1
  42. package/scripts/generaters/images.ts +0 -26
  43. package/scripts/generaters/index.d.ts +0 -1
  44. package/scripts/generaters/index.ts +0 -110
  45. package/scripts/generaters/pages.d.ts +0 -0
  46. package/scripts/generaters/pages.ts +0 -16
  47. package/scripts/generaters/script.d.ts +0 -1
  48. package/scripts/generaters/script.ts +0 -110
  49. package/scripts/helpers/asset.d.ts +0 -1
  50. package/scripts/helpers/asset.ts +0 -158
  51. package/scripts/helpers/engine.d.ts +0 -1
  52. package/scripts/helpers/engine.ts +0 -171
  53. package/scripts/helpers/list_categories.d.ts +0 -1
  54. package/scripts/helpers/list_categories.ts +0 -104
  55. package/scripts/helpers/summary_ai.d.ts +0 -1
  56. package/scripts/helpers/summary_ai.ts +0 -100
  57. package/scripts/helpers/symbols_count_time.d.ts +0 -1
  58. package/scripts/helpers/symbols_count_time.ts +0 -76
  59. package/scripts/plugin/check.d.ts +0 -1
  60. package/scripts/plugin/check.ts +0 -35
  61. package/scripts/plugin/index.d.ts +0 -6
  62. package/scripts/plugin/index.ts +0 -52
  63. package/scripts/plugin/lib/injects-point.d.ts +0 -5
  64. package/scripts/plugin/lib/injects-point.ts +0 -20
  65. package/scripts/plugin/lib/injects.d.ts +0 -2
  66. package/scripts/plugin/lib/injects.ts +0 -101
  67. package/scripts/tags/links.d.ts +0 -1
  68. package/scripts/tags/links.ts +0 -75
  69. package/scripts/tags/media.d.ts +0 -1
  70. package/scripts/tags/media.ts +0 -19
  71. package/source/assets/beian.webp +0 -0
  72. package/source/js/_app/library/libtype.d.ts +0 -4
package/_config.yml CHANGED
@@ -269,7 +269,8 @@ footer:
269
269
  word2: 秋 #第二个字
270
270
  icp: # ICP备案
271
271
  enable: false
272
- icon: "beian.webp" #网安备案图片
272
+ # 请在登录后从 https://beian.mps.gov.cn/web/business/businessHome/website 下载对应图标
273
+ icon: "" #网安备案图片
273
274
  icpnumber: "xxx" # ICP备案号
274
275
  beian: "xxx" # 网安备案号
275
276
  recordcode: "xxx" # 网安备案链接中的recordcode参数
@@ -363,9 +364,9 @@ vendors:
363
364
  # pjax: npm_webcache|theme-shokax-pjax@0.0.3/pjax.shokax.min.js
364
365
  # anime: npm_webcache|theme-shokax-anime@0.0.6/anime.shokax.min.js
365
366
  # lozad: npm_webcache|lozad@1.16.0/dist/lozad.min.js
366
- algolia: bytedance|algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
367
- instantsearch: bytedance|instantsearch.js/4.39.0/instantsearch.production.min.js
368
- quicklink: npm_webcache|quicklink@2.3.0/dist/quicklink.umd.js
367
+ # algolia: bytedance|algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
368
+ # instantsearch: bytedance|instantsearch.js/4.39.0/instantsearch.production.min.js
369
+ # quicklink: npm_webcache|quicklink@2.3.0/dist/quicklink.umd.js
369
370
  # mouse_firework: npm_webcache|mouse-firework@0.0.4/dist/index.umd.js
370
371
  async_js:
371
372
  fancybox: bytedance|??jquery/3.5.1/jquery.min.js,fancybox/3.5.7/jquery.fancybox.min.js,justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
@@ -33,7 +33,7 @@ div(class="status")
33
33
  - var beianN = theme.footer.icp?.beian, RC=theme.footer.icp?.recordcode
34
34
  if beianN && RC
35
35
  br
36
- a(target="_blank" href=`https://www.beian.gov.cn/portal/registerSystemInfo?recordcode=${RC}`)
36
+ a(target="_blank" href=`https://beian.mps.gov.cn/#/query/webSearch?code=${RC}`)
37
37
  img(src=theme.statics + theme.assets + '/' + theme.footer.icp.icon style="max-width: 2em;display:inline;" width="20" height="20")
38
38
  != beianN
39
39
  != shokax_inject('status')
@@ -38,11 +38,17 @@ each prelink in prelinks
38
38
  each dnsLink in dnslinks
39
39
  link(rel="dns-prefetch" href=dnsLink)
40
40
 
41
- - var fontConfig = theme?.font?.loadFromGoogle
41
+ - var fontConfig = theme.font?.loadFromGoogle
42
42
  if fontConfig
43
43
  != _vendor_font()
44
44
  != _css('app.css')
45
45
 
46
+ if theme.polyfill.enable
47
+ script(src=`https://polyfill.io/v3/polyfill.min.js?features=${theme.polyfill.features}` defer)
48
+
49
+ != vendor_js()
50
+ != _js('siteInit.js')
51
+
46
52
  include pwa.pug
47
53
  if tk
48
54
  script(src=theme.twikoo.link )
@@ -11,7 +11,7 @@ nav(id="nav")
11
11
  != alternate || title
12
12
  ul(class="right" id="rightNav")
13
13
  li(class="item theme" @click="changeThemeByBtn")
14
- i(class="ic" :class="{'i-sun': !themeStatus,'i-moon': themeStatus}")
14
+ i(class="ic i-sun")
15
15
  li(class="item search")
16
16
  i(class="ic i-search")
17
17
  != shokax_inject('rightNav')
@@ -115,16 +115,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
115
115
  ]
116
116
  };
117
117
 
118
- if theme.polyfill.enable
119
- script(src=`https://polyfill.io/v3/polyfill.min.js?features=${theme.polyfill.features}`)
120
-
121
- - debugVue = theme?.experiments?.debug
122
- if debugVue
123
- script(src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.min.js")
124
- else
125
- script(src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.prod.min.js")
126
- != vendor_js()
127
- != _js('app.js')
128
118
  != partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
129
119
  != partial('_partials/third-party/clarity.pug', {}, {cache: true})
130
120
  != partial('_partials/third-party/google-analytics.pug', {}, {cache: true})
@@ -16,10 +16,9 @@ div(class="meta")
16
16
  script(type = "module" data-pjax).
17
17
  import { pageviewCount } from 'https://unpkg.com/@waline/client@2/dist/pageview.mjs';
18
18
 
19
- const path = document.getElementById("twikoo_visitors").getAttribute("data-path");
20
19
  pageviewCount({
21
20
  serverURL: '#{theme.waline.serverURL}',
22
- path: path,
21
+ path: window.location.pathname,
23
22
  });
24
23
 
25
24
  != shokax_inject('postMeta')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.0-alpha.1",
3
+ "version": "0.4.0-alpha.2",
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",
@@ -16,26 +16,31 @@
16
16
  "@types/jquery": "^3.5.29",
17
17
  "@types/js-yaml": "^4.0.9",
18
18
  "@types/node": "^20.11.10",
19
+ "@types/quicklink": "^2.3.4",
19
20
  "@typescript-eslint/eslint-plugin": "^6.20.0",
20
21
  "@typescript-eslint/parser": "^6.20.0",
22
+ "@waline/client": "3.0.0-alpha.11",
21
23
  "eslint": "^8.56.0",
22
24
  "eslint-config-standard": "~17",
23
25
  "eslint-plugin-import": "^2.29.1",
24
26
  "eslint-plugin-n": "^16.6.2",
25
27
  "eslint-plugin-promise": "^6.1.1",
26
28
  "eslint-plugin-vue": "^9.20.1",
27
- "instantsearch.js": "^4.64.1",
28
29
  "typescript": "^5.3.3",
29
30
  "vue": "^3.4.15"
30
31
  },
31
32
  "dependencies": {
33
+ "@algolia/client-search": "^4.22.1",
34
+ "algoliasearch": "4.22.1",
32
35
  "esbuild": "^0.20.0",
33
36
  "hexo": "7.0.0",
34
37
  "hexo-fs": "^4.1.1",
35
38
  "hexo-pagination": "^3.0.0",
36
39
  "hexo-util": "^3.2.0",
40
+ "instantsearch.js": "^4.64.2",
37
41
  "js-yaml": "^4.1.0",
38
42
  "mouse-firework": "^0.0.5",
43
+ "quicklink": "^2.3.0",
39
44
  "theme-shokax-anime": "^0.0.6",
40
45
  "theme-shokax-pjax": "^0.0.3",
41
46
  "unlazy": "^0.10.4"
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  // @ts-ignore
8
8
  const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
9
9
  // @ts-ignore
10
- const fmtNum = num => {
10
+ const fmtNum = (num) => {
11
11
  return num < 10 ? '0' + num : num;
12
12
  };
13
13
  if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
@@ -1,34 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  /* global hexo */
30
7
  const package_json_1 = __importDefault(require("../../package.json"));
31
- const fs = __importStar(require("hexo-fs"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
32
9
  const esbuild_1 = require("esbuild");
33
10
  const utils_1 = require("../utils");
34
11
  hexo.extend.generator.register('script', function (locals) {
@@ -83,19 +60,17 @@ hexo.extend.generator.register('script', function (locals) {
83
60
  if (theme?.audio) {
84
61
  siteConfig.audio = theme.audio;
85
62
  }
86
- let text;
87
63
  let enterPoint;
88
- if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
64
+ if (node_fs_1.default.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
89
65
  enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.ts';
90
66
  }
91
67
  else {
92
68
  enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts';
93
69
  }
94
- text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
95
70
  (0, esbuild_1.buildSync)({
96
71
  entryPoints: [enterPoint],
97
72
  bundle: true,
98
- outfile: 'shokax_temp.js',
73
+ outdir: 'shokaxTemp',
99
74
  tsconfigRaw: {
100
75
  compilerOptions: {
101
76
  target: 'ES2022',
@@ -106,9 +81,12 @@ hexo.extend.generator.register('script', function (locals) {
106
81
  }
107
82
  },
108
83
  platform: 'browser',
109
- format: 'iife',
84
+ format: 'esm',
110
85
  target: ['es2022'],
111
86
  minify: true,
87
+ legalComments: 'linked',
88
+ mainFields: ['module', 'main'],
89
+ splitting: true,
112
90
  define: {
113
91
  __UNLAZY_LOGGING__: 'false',
114
92
  __UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? 'true' : 'false',
@@ -119,16 +97,44 @@ hexo.extend.generator.register('script', function (locals) {
119
97
  __shokax_outime__: theme.outime.enable ? 'true' : 'false',
120
98
  __shokax_tabs__: theme.modules.tabs ? 'true' : 'false',
121
99
  __shokax_quiz__: theme.modules.quiz ? 'true' : 'false',
122
- __shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false'
100
+ __shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false',
101
+ shokax_CONFIG: JSON.stringify(siteConfig)
102
+ },
103
+ alias: {
104
+ 'algoliasearch/lite': 'algoliasearch/dist/algoliasearch-lite.esm.browser.js'
123
105
  }
124
106
  });
125
- text += fs.readFileSync('shokax_temp.js');
126
- const result = hexo.render.renderSync({ text, engine: 'js' });
127
- fs.unlinkSync('shokax_temp.js');
128
- return {
129
- path: theme.js + '/app.js',
130
- data: function () {
131
- return result;
107
+ const res = [];
108
+ node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
109
+ const fileText = node_fs_1.default.readFileSync(`./shokaxTemp/${file}`, { encoding: 'utf-8' });
110
+ if (file.endsWith('js')) {
111
+ const result = hexo.render.renderSync({ text: fileText, engine: 'js' });
112
+ res.push({
113
+ path: theme.js + '/' + file,
114
+ data: function () {
115
+ return result;
116
+ }
117
+ });
132
118
  }
133
- };
119
+ else if (file.endsWith('css')) {
120
+ const result = hexo.render.renderSync({ text: fileText, engine: 'css' });
121
+ res.push({
122
+ path: theme.css + '/' + file,
123
+ data: function () {
124
+ return result;
125
+ }
126
+ });
127
+ }
128
+ else {
129
+ res.push({
130
+ path: theme.js + '/' + file,
131
+ data: function () {
132
+ return fileText;
133
+ }
134
+ });
135
+ }
136
+ node_fs_1.default.unlinkSync(`./shokaxTemp/${file}`);
137
+ });
138
+ node_fs_1.default.rmSync('./shokaxTemp', { force: true, recursive: true });
139
+ return res;
134
140
  });
@@ -126,7 +126,7 @@ hexo.extend.helper.register('_css', function (...urls) {
126
126
  });
127
127
  hexo.extend.helper.register('_js', function (...urls) {
128
128
  const { statics, js } = hexo.theme.config;
129
- return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${package_json_1.default.version}`) }, '')).join('');
129
+ return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${package_json_1.default.version}`), type: 'module', fetchpriority: 'high' }, '')).join('');
130
130
  });
131
131
  hexo.extend.helper.register('vendor_js', function () {
132
132
  const vendors = hexo.theme.config.vendors;
@@ -1,5 +1,3 @@
1
- 'use strict';
2
- /* global hexo */
3
1
  const prepareQuery = (categories, parent) => {
4
2
  const query = {
5
3
  parent: undefined
@@ -13,7 +11,6 @@ const prepareQuery = (categories, parent) => {
13
11
  return categories.find(query).sort('name', 1).filter(cat => cat.length);
14
12
  };
15
13
  hexo.extend.helper.register('_list_categories', function (depth = 0) {
16
- // let hexo = this
17
14
  const categories = this.site.categories;
18
15
  if (!categories || !categories.length)
19
16
  return '';
@@ -48,7 +45,6 @@ hexo.extend.helper.register('_list_categories', function (depth = 0) {
48
45
  return hierarchicalList(0);
49
46
  });
50
47
  hexo.extend.helper.register('_category_prev', function (name) {
51
- // let hexo = this
52
48
  const categories = this.site.categories;
53
49
  if (!categories || !categories.length)
54
50
  return '';
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
@@ -0,0 +1,33 @@
1
+ import { CONFIG } from '../globals/globalVars'
2
+ import { init, pageviewCount } from '@waline/client'
3
+
4
+ // await import('@waline/client/style')
5
+ // fixme 处理样式引入问题
6
+
7
+ export const walineComment = function () {
8
+ init({
9
+ el: '#comments',
10
+ serverURL: CONFIG.waline.serverURL,
11
+ lang: CONFIG.waline.lang,
12
+ locale: CONFIG.waline.locale,
13
+ emoji: CONFIG.waline.emoji,
14
+ meta: CONFIG.waline.meta,
15
+ requiredMeta: CONFIG.waline.requiredMeta,
16
+ wordLimit: CONFIG.waline.wordLimit,
17
+ pageSize: CONFIG.waline.pageSize,
18
+ pageview: CONFIG.waline.pageview,
19
+ path: window.location.pathname,
20
+ dark: 'html[data-theme="dark"]'
21
+ })
22
+ }
23
+
24
+ export const walinePageview = function () {
25
+ pageviewCount({
26
+ serverURL: CONFIG.waline.serverURL,
27
+ path: window.location.pathname
28
+ })
29
+ }
30
+
31
+ export const walineRecentComments = async function () {
32
+
33
+ }
@@ -1,10 +1,12 @@
1
1
  /* 边栏分区 */
2
2
 
3
- import { Container, diffY, menuToggle, showContents, sideBar } from '../globals/globalVars'
3
+ import { CONFIG, Container, diffY, menuToggle, showContents, sideBar } from '../globals/globalVars'
4
4
  import { clipBoard } from '../globals/tools'
5
5
  import { pageScroll, transition } from '../library/anime'
6
6
  import { $dom } from '../library/dom'
7
+ import initProto, { child, getHeight, setDisplay } from '../library/proto'
7
8
 
9
+ initProto()
8
10
  export const sideBarToggleHandle = (event:Event, force?:number) => {
9
11
  if (sideBar.hasClass('on')) {
10
12
  sideBar.removeClass('on')
@@ -31,7 +33,7 @@ export const sideBarToggleHandle = (event:Event, force?:number) => {
31
33
  }
32
34
 
33
35
  export const sideBarTab = () => {
34
- const sideBarInner = sideBar.child('.inner')
36
+ const sideBarInner = child(sideBar, '.inner')
35
37
 
36
38
  if (sideBar.child('.tab')) {
37
39
  sideBarInner.removeChild(sideBar.child('.tab'))
@@ -45,13 +47,13 @@ export const sideBarTab = () => {
45
47
 
46
48
  if (element.innerHTML.trim().length < 1) {
47
49
  if (item === 'contents') {
48
- showContents.display('none')
50
+ setDisplay(showContents, 'none')
49
51
  }
50
52
  return
51
53
  }
52
54
 
53
55
  if (item === 'contents') {
54
- showContents.display('')
56
+ setDisplay(showContents, '')
55
57
  }
56
58
 
57
59
  const tab = document.createElement('li')
@@ -212,7 +214,7 @@ export const backToTopHandle = () => {
212
214
  }
213
215
 
214
216
  export const goToBottomHandle = () => {
215
- pageScroll(parseInt(String(Container.changeOrGetHeight())))
217
+ pageScroll(parseInt(String(getHeight(Container))))
216
218
  }
217
219
 
218
220
  export const goToCommentHandle = () => {
@@ -2,6 +2,7 @@ import { $dom } from '../library/dom'
2
2
  import Pjax from 'theme-shokax-pjax'
3
3
  import initProto from '../library/proto'
4
4
 
5
+ export const CONFIG = shokax_CONFIG
5
6
  initProto()
6
7
  export const statics = CONFIG.statics.indexOf('//') > 0 ? CONFIG.statics : CONFIG.root
7
8
  export const scrollAction: { x: number, y: number } = { x: 0, y: 0 }
@@ -18,18 +18,19 @@ import {
18
18
  setSiteNavHeight,
19
19
  setHeaderHightInner,
20
20
  setHeaderHight,
21
- setOWinHeight, setOWinWidth, setDiffY, setTitleTime
21
+ setOWinHeight, setOWinWidth, setDiffY, setTitleTime, CONFIG
22
22
  } from './globalVars'
23
23
  import { changeMetaTheme } from './themeColor'
24
24
  import { Loader } from './thirdparty'
25
+ import {getHeight, setWidth} from '../library/proto'
25
26
 
26
27
  export const resizeHandle = () => {
27
28
  // 获取 siteNav 的高度
28
- setSiteNavHeight(siteNav.changeOrGetHeight())
29
+ setSiteNavHeight(getHeight(siteNav))
29
30
  // 获取 siteHeader 的高度
30
- setHeaderHightInner(siteHeader.changeOrGetHeight())
31
+ setHeaderHightInner(getHeight(siteHeader))
31
32
  // 获取 #waves 的高度
32
- setHeaderHight(headerHightInner + $dom('#waves').changeOrGetHeight())
33
+ setHeaderHight(headerHightInner + getHeight($dom('#waves')))
33
34
 
34
35
  // 判断窗口宽度是否改变
35
36
  if (oWinWidth !== window.innerWidth) {
@@ -90,7 +91,7 @@ export const scrollHandle = () => {
90
91
  }
91
92
  // 更新百分比进度条的宽度
92
93
  if ($dom('#sidebar').hasClass('affix') || $dom('#sidebar').hasClass('on')) {
93
- $dom('.percent').changeOrGetWidth(scrollPercent)
94
+ setWidth($dom('.percent'), scrollPercent)
94
95
  }
95
96
  }
96
97
 
@@ -1,6 +1,6 @@
1
1
  import { $storage } from '../library/storage'
2
2
  import { $dom } from '../library/dom'
3
- import { HTML } from './globalVars'
3
+ import { CONFIG, HTML } from './globalVars'
4
4
 
5
5
  /**
6
6
  * 更改日夜模式
@@ -1,6 +1,6 @@
1
1
  // 与第三方js的交互或第三方嵌入js
2
2
 
3
- import { loadCat } from './globalVars'
3
+ import { CONFIG, loadCat } from './globalVars'
4
4
  import { transition } from '../library/anime'
5
5
 
6
6
  // 加载动画
@@ -1,7 +1,8 @@
1
1
  import { pageScroll } from '../library/anime'
2
2
  import { $dom } from '../library/dom'
3
3
  import { $storage } from '../library/storage'
4
- import { BODY, LOCAL_HASH, LOCAL_URL, scrollAction, setLocalHash } from './globalVars'
4
+ import { BODY, CONFIG, LOCAL_HASH, LOCAL_URL, scrollAction, setLocalHash } from './globalVars'
5
+ import { createChild } from '../library/proto'
5
6
 
6
7
  // 显示提示(现阶段用于版权及复制结果提示)
7
8
  export const showtip = (msg: string): void | never => {
@@ -9,7 +10,7 @@ export const showtip = (msg: string): void | never => {
9
10
  return
10
11
  }
11
12
 
12
- const tipbox = BODY.createChild('div', {
13
+ const tipbox = createChild(BODY, 'div', {
13
14
  innerHTML: msg,
14
15
  className: 'tip'
15
16
  })
@@ -1,6 +1,7 @@
1
1
  import anime from 'theme-shokax-anime'
2
2
  import { siteNavHeight } from '../globals/globalVars'
3
3
  import type { AnimeOptions } from 'theme-shokax-anime/dist/types'
4
+ import {getTop, setDisplay} from './proto'
4
5
 
5
6
  /**
6
7
  * 参数 动画效果
@@ -26,7 +27,7 @@ export const transition = (target: HTMLElement, type: number|string|Function, co
26
27
  case 'bounceUpIn':
27
28
  animation = {
28
29
  begin (anim) {
29
- target.display('block')
30
+ setDisplay(target, 'block')
30
31
  },
31
32
  translateY: [
32
33
  { value: -60, duration: 200 },
@@ -41,7 +42,7 @@ export const transition = (target: HTMLElement, type: number|string|Function, co
41
42
  case 'shrinkIn':
42
43
  animation = {
43
44
  begin (anim) {
44
- target.display('block')
45
+ setDisplay(target, 'block')
45
46
  },
46
47
  scale: [
47
48
  { value: 1.1, duration: 300 },
@@ -54,7 +55,7 @@ export const transition = (target: HTMLElement, type: number|string|Function, co
54
55
  case 'slideRightIn':
55
56
  animation = {
56
57
  begin (anim) {
57
- target.display('block')
58
+ setDisplay(target, 'block')
58
59
  },
59
60
  translateX: ['100%', '0%'],
60
61
  opacity: [0, 1]
@@ -82,7 +83,7 @@ export const transition = (target: HTMLElement, type: number|string|Function, co
82
83
  begin && begin()
83
84
  },
84
85
  complete () {
85
- target.display(display)
86
+ setDisplay(target, display)
86
87
  complete && complete()
87
88
  }
88
89
  }, animation)).play()
@@ -100,7 +101,7 @@ export const pageScroll = (target: HTMLElement|number, offset?: number, complete
100
101
  // 动画缓动函数
101
102
  easing: 'easeInOutQuad',
102
103
  // 如果 offset 存在,则滚动到 offset,如果 target 是数字,则滚动到 target,如果 target 是 DOM 元素,则滚动到下述表达式
103
- scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
104
+ scrollTop: offset || (typeof target === 'number' ? target : (target ? getTop(target) + document.documentElement.scrollTop - siteNavHeight : 0)),
104
105
  // 完成回调函数
105
106
  complete () {
106
107
  complete && complete()
@@ -27,6 +27,8 @@ declare interface EventTarget {
27
27
  hasClass(className: string): boolean;
28
28
  }
29
29
 
30
+ type walineMeta = 'nick'|'mail'|'link'
31
+
30
32
  declare const LOCAL: {
31
33
  path: string;
32
34
  ignores: Array<(uri:string)=>boolean>;
@@ -53,7 +55,7 @@ declare const LOCAL: {
53
55
  show: string
54
56
  }
55
57
  }
56
- declare const CONFIG: {
58
+ interface configType {
57
59
  hostname: string;
58
60
  fireworks: any;
59
61
  audio: AudioItem[];
@@ -92,20 +94,25 @@ declare const CONFIG: {
92
94
  fancybox: string
93
95
  }
94
96
  search: any,
95
- valine: string
97
+ waline: {
98
+ serverURL: string
99
+ lang: string
100
+ locale: object
101
+ emoji: boolean
102
+ meta: walineMeta[]
103
+ requiredMeta: walineMeta[]
104
+ wordLimit: number
105
+ pageSize: number
106
+ pageview: boolean
107
+ }
108
+ walinePageView: boolean
96
109
  quicklink: {
97
110
  ignores: any
98
111
  timeout: number
99
- priority: string
112
+ priority: boolean
100
113
  }
101
114
  playerAPI: string
102
115
  }
103
- declare const instantsearch: any
104
-
105
- declare function algoliasearch(appID: string, apiKey: string): any;
106
-
107
- declare const quicklink: any
108
-
109
116
  // esbuild 静态常量
110
117
  declare const __shokax_player__:boolean
111
118
  declare const __shokax_fireworks__:boolean
@@ -115,3 +122,5 @@ declare const __shokax_outime__:boolean
115
122
  declare const __shokax_tabs__: boolean
116
123
  declare const __shokax_quiz__: boolean
117
124
  declare const __shokax_fancybox__: boolean
125
+ declare const __shokax_waline__:boolean
126
+ declare const shokax_CONFIG:configType
@@ -1,4 +1,6 @@
1
1
  import { getScript } from './scriptPjax'
2
+ import { CONFIG } from '../globals/globalVars'
3
+ import { createChild } from './proto'
2
4
 
3
5
  /**
4
6
  * 用途是根据不同的资源名称和类型生成相应的资源 URL。
@@ -31,7 +33,7 @@ export const vendorCss = (type: string, condition?: string): void => {
31
33
  }
32
34
 
33
35
  if (LOCAL[type]) {
34
- document.head.createChild('link', {
36
+ createChild(document.head, 'link', {
35
37
  rel: 'stylesheet',
36
38
  href: assetUrl('css', type)
37
39
  })