hexo-theme-shokax 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/_config.yml +26 -5
  2. package/package.json +8 -7
  3. package/scripts/filters/locals.js +6 -0
  4. package/scripts/filters/post.js +2 -0
  5. package/scripts/generaters/archive.js +13 -1
  6. package/scripts/generaters/config.js +4 -1
  7. package/scripts/generaters/images.js +2 -0
  8. package/scripts/generaters/index.js +2 -0
  9. package/scripts/generaters/pages.js +0 -2
  10. package/scripts/generaters/script.js +34 -9
  11. package/scripts/helpers/asset.js +16 -7
  12. package/scripts/helpers/engine.js +24 -1
  13. package/scripts/helpers/list_categories.js +4 -0
  14. package/scripts/helpers/summary_ai.js +4 -0
  15. package/scripts/helpers/symbols_count_time.js +14 -8
  16. package/scripts/plugin/check.js +5 -3
  17. package/scripts/plugin/index.js +36 -9
  18. package/scripts/plugin/lib/injects.js +15 -0
  19. package/scripts/tags/media.js +1 -0
  20. package/source/js/_app/components/sidebar.js +54 -56
  21. package/source/js/_app/fireworks.js +6 -137
  22. package/source/js/_app/globals/globalVars.js +80 -96
  23. package/source/js/_app/globals/handles.js +81 -60
  24. package/source/js/_app/globals/themeColor.js +30 -26
  25. package/source/js/_app/globals/thirdparty.js +25 -24
  26. package/source/js/_app/globals/tools.js +36 -30
  27. package/source/js/_app/library/anime.js +30 -15
  28. package/source/js/_app/library/dom.js +12 -5
  29. package/source/js/_app/library/loadFile.js +7 -9
  30. package/source/js/_app/library/proto.js +59 -7
  31. package/source/js/_app/library/scriptPjax.js +14 -9
  32. package/source/js/_app/library/storage.js +2 -4
  33. package/source/js/_app/library/vue.js +16 -19
  34. package/source/js/_app/page/comment.js +10 -11
  35. package/source/js/_app/page/common.js +8 -12
  36. package/source/js/_app/page/fancybox.js +13 -14
  37. package/source/js/_app/page/post.js +43 -45
  38. package/source/js/_app/page/search.js +20 -20
  39. package/source/js/_app/page/tab.js +7 -10
  40. package/source/js/_app/pjax/domInit.js +29 -29
  41. package/source/js/_app/pjax/refresh.js +45 -50
  42. package/source/js/_app/pjax/siteInit.js +27 -31
  43. package/source/js/_app/player.js +44 -27
  44. package/test/dom.test.js +0 -86
@@ -4,25 +4,52 @@
4
4
  under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
5
5
  https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
6
6
  */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
7
30
  var __importDefault = (this && this.__importDefault) || function (mod) {
8
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
32
  };
10
33
  Object.defineProperty(exports, "__esModule", { value: true });
11
34
  const injects_1 = __importDefault(require("./lib/injects"));
12
- const node_https_1 = __importDefault(require("node:https"));
13
- const package_json_1 = require("../../package.json");
14
- const node_fs_1 = __importDefault(require("node:fs"));
35
+ const node_https_1 = require("node:https");
36
+ // @ts-ignore
37
+ // import { version } from '../../package.json'
38
+ const fs = __importStar(require("node:fs"));
39
+ const version = '0.3.10';
15
40
  hexo.on('generateBefore', () => {
41
+ // 加载`theme_injects`过滤器
16
42
  (0, injects_1.default)(hexo);
17
- if (node_fs_1.default.existsSync('request.lock')) {
18
- node_fs_1.default.unlinkSync('request.lock');
43
+ if (fs.existsSync('request.lock')) {
44
+ fs.unlinkSync('request.lock');
19
45
  }
20
- if (node_fs_1.default.existsSync('requested.lock')) {
21
- node_fs_1.default.unlinkSync('requested.lock');
46
+ if (fs.existsSync('requested.lock')) {
47
+ fs.unlinkSync('requested.lock');
22
48
  }
23
49
  });
24
50
  hexo.on('generateAfter', () => {
25
- node_https_1.default.get('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest', {
51
+ // 检查版本更新
52
+ (0, node_https_1.get)('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest', {
26
53
  headers: {
27
54
  'User-Agent': 'Theme ShokaX Client'
28
55
  }
@@ -34,7 +61,7 @@ hexo.on('generateAfter', () => {
34
61
  res.on('end', () => {
35
62
  try {
36
63
  const latest = JSON.parse(result).tag_name.replace('v', '').split('.');
37
- const current = package_json_1.version.split('.');
64
+ const current = version.split('.');
38
65
  let isOutdated = false;
39
66
  for (let i = 0; i < Math.max(latest.length, current.length); i++) {
40
67
  if (!current[i] || latest[i] > current[i]) {
@@ -3,6 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /*!
7
+ inject.js in next-theme/hexo-theme-next by next-theme
8
+ under GNU AFFERO GENERAL PUBLIC LICENSE v3.0 OR LATER
9
+ https://github.com/next-theme/hexo-theme-next/blob/master/LICENSE.md
10
+ */
6
11
  const node_fs_1 = __importDefault(require("node:fs"));
7
12
  const node_path_1 = __importDefault(require("node:path"));
8
13
  const injects_point_1 = __importDefault(require("./injects-point"));
@@ -18,6 +23,7 @@ class StylusInject {
18
23
  this.files.push(node_path_1.default.resolve(this.base_dir, file));
19
24
  }
20
25
  }
26
+ // Defining view types
21
27
  class ViewInject {
22
28
  base_dir;
23
29
  raws;
@@ -26,18 +32,22 @@ class ViewInject {
26
32
  this.raws = [];
27
33
  }
28
34
  raw(name, raw, ...args) {
35
+ // Set default extname
29
36
  if (node_path_1.default.extname(name) === '') {
30
37
  name += defaultExtname;
31
38
  }
32
39
  this.raws.push({ name, raw, args });
33
40
  }
34
41
  file(name, file, ...args) {
42
+ // Set default extname from file's extname
35
43
  if (node_path_1.default.extname(name) === '') {
36
44
  name += node_path_1.default.extname(file);
37
45
  }
46
+ // Get absolute path base on hexo dir
38
47
  this.raw(name, node_fs_1.default.readFileSync(node_path_1.default.resolve(this.base_dir, file), 'utf8'), ...args);
39
48
  }
40
49
  }
50
+ // Init injects
41
51
  function initInject(base_dir) {
42
52
  const injects = {};
43
53
  injects_point_1.default.styles.forEach(item => {
@@ -49,15 +59,19 @@ function initInject(base_dir) {
49
59
  return injects;
50
60
  }
51
61
  exports.default = (hexo) => {
62
+ // Exec theme_inject filter
52
63
  const injects = initInject(hexo.base_dir);
53
64
  hexo.execFilterSync('theme_inject', injects);
54
65
  hexo.theme.config.injects = {};
66
+ // Inject stylus
55
67
  injects_point_1.default.styles.forEach(type => {
56
68
  hexo.theme.config.injects[type] = injects[type].files;
57
69
  });
70
+ // Inject views
58
71
  injects_point_1.default.views.forEach(type => {
59
72
  const configs = Object.create(null);
60
73
  hexo.theme.config.injects[type] = [];
74
+ // Add or override view.
61
75
  injects[type].raws.forEach((injectObj, index) => {
62
76
  const name = `inject/${type}/${injectObj.name}`;
63
77
  hexo.theme.setView(name, injectObj.raw);
@@ -68,6 +82,7 @@ exports.default = (hexo) => {
68
82
  order: injectObj.args[2] || index
69
83
  };
70
84
  });
85
+ // Views sort.
71
86
  hexo.theme.config.injects[type] = Object.values(configs)
72
87
  .sort((x, y) => x.order - y.order);
73
88
  });
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* global hexo */
6
7
  const js_yaml_1 = __importDefault(require("js-yaml"));
7
8
  function postMedia(args, content) {
8
9
  if (!args[0] || !content) {
@@ -1,52 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.menuActive = exports.goToCommentHandle = exports.goToBottomHandle = exports.backToTopHandle = exports.sidebarTOC = exports.sideBarTab = exports.sideBarToggleHandle = void 0;
4
- const globalVars_1 = require("../globals/globalVars");
5
- const tools_1 = require("../globals/tools");
6
- const anime_1 = require("../library/anime");
7
- const dom_1 = require("../library/dom");
8
- const sideBarToggleHandle = (event, force) => {
9
- if (globalVars_1.sideBar.hasClass('on')) {
10
- globalVars_1.sideBar.removeClass('on');
11
- globalVars_1.menuToggle.removeClass('close');
1
+ /* 边栏分区 */
2
+ import { Container, diffY, menuToggle, showContents, sideBar } from '../globals/globalVars';
3
+ import { clipBoard } from '../globals/tools';
4
+ import { pageScroll, transition } from '../library/anime';
5
+ import { $dom } from '../library/dom';
6
+ export const sideBarToggleHandle = (event, force) => {
7
+ if (sideBar.hasClass('on')) {
8
+ sideBar.removeClass('on');
9
+ menuToggle.removeClass('close');
12
10
  if (force) {
13
- globalVars_1.sideBar.style = '';
11
+ // @ts-ignore
12
+ // noinspection JSConstantReassignment
13
+ sideBar.style = '';
14
14
  }
15
15
  else {
16
- (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightOut');
16
+ transition(sideBar, 'slideRightOut');
17
17
  }
18
18
  }
19
19
  else {
20
20
  if (force) {
21
- globalVars_1.sideBar.style = '';
21
+ // @ts-ignore
22
+ // noinspection JSConstantReassignment
23
+ sideBar.style = '';
22
24
  }
23
25
  else {
24
- (0, anime_1.transition)(globalVars_1.sideBar, 'slideRightIn', () => {
25
- globalVars_1.sideBar.addClass('on');
26
- globalVars_1.menuToggle.addClass('close');
26
+ transition(sideBar, 'slideRightIn', () => {
27
+ sideBar.addClass('on');
28
+ menuToggle.addClass('close');
27
29
  });
28
30
  }
29
31
  }
30
32
  };
31
- exports.sideBarToggleHandle = sideBarToggleHandle;
32
- const sideBarTab = () => {
33
- const sideBarInner = globalVars_1.sideBar.child('.inner');
34
- if (globalVars_1.sideBar.child('.tab')) {
35
- sideBarInner.removeChild(globalVars_1.sideBar.child('.tab'));
33
+ export const sideBarTab = () => {
34
+ const sideBarInner = sideBar.child('.inner');
35
+ if (sideBar.child('.tab')) {
36
+ sideBarInner.removeChild(sideBar.child('.tab'));
36
37
  }
37
38
  const list = document.createElement('ul');
38
39
  let active = 'active';
39
40
  list.className = 'tab';
40
41
  ['contents', 'related', 'overview'].forEach((item) => {
41
- const element = globalVars_1.sideBar.child('.panel.' + item);
42
+ const element = sideBar.child('.panel.' + item);
42
43
  if (element.innerHTML.trim().length < 1) {
43
44
  if (item === 'contents') {
44
- globalVars_1.showContents.display('none');
45
+ showContents.display('none');
45
46
  }
46
47
  return;
47
48
  }
48
49
  if (item === 'contents') {
49
- globalVars_1.showContents.display('');
50
+ showContents.display('');
50
51
  }
51
52
  const tab = document.createElement('li');
52
53
  const span = document.createElement('span');
@@ -65,13 +66,13 @@ const sideBarTab = () => {
65
66
  const target = event.currentTarget;
66
67
  if (target.hasClass('active'))
67
68
  return;
68
- globalVars_1.sideBar.find('.tab .item').forEach((element) => {
69
+ sideBar.find('.tab .item').forEach((element) => {
69
70
  element.removeClass('active');
70
71
  });
71
- globalVars_1.sideBar.find('.panel').forEach((element) => {
72
+ sideBar.find('.panel').forEach((element) => {
72
73
  element.removeClass('active');
73
74
  });
74
- globalVars_1.sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
75
+ sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
75
76
  target.addClass('active');
76
77
  });
77
78
  list.appendChild(tab);
@@ -79,14 +80,13 @@ const sideBarTab = () => {
79
80
  });
80
81
  if (list.childNodes.length > 1) {
81
82
  sideBarInner.insertBefore(list, sideBarInner.childNodes[0]);
82
- globalVars_1.sideBar.child('.panels').style.paddingTop = '';
83
+ sideBar.child('.panels').style.paddingTop = '';
83
84
  }
84
85
  else {
85
- globalVars_1.sideBar.child('.panels').style.paddingTop = '.625rem';
86
+ sideBar.child('.panels').style.paddingTop = '.625rem';
86
87
  }
87
88
  };
88
- exports.sideBarTab = sideBarTab;
89
- const sidebarTOC = () => {
89
+ export const sidebarTOC = () => {
90
90
  const activateNavByIndex = (index) => {
91
91
  const target = navItems[index];
92
92
  if (!target)
@@ -94,7 +94,7 @@ const sidebarTOC = () => {
94
94
  if (target.hasClass('current')) {
95
95
  return;
96
96
  }
97
- dom_1.$dom.each('.toc .active', (element) => {
97
+ $dom.each('.toc .active', (element) => {
98
98
  element && element.removeClass('active current');
99
99
  });
100
100
  sections.forEach((element) => {
@@ -106,46 +106,49 @@ const sidebarTOC = () => {
106
106
  while (!parent.matches('.contents')) {
107
107
  if (parent.matches('li')) {
108
108
  parent.addClass('active');
109
- const t = (0, dom_1.$dom)(parent.child('a.toc-link').attr('href'));
109
+ const t = $dom(parent.child('a.toc-link').attr('href'));
110
110
  if (t) {
111
111
  t.addClass('active');
112
112
  }
113
113
  }
114
114
  parent = parent.parentNode;
115
115
  }
116
- if (getComputedStyle(globalVars_1.sideBar).display !== 'none' && tocElement.hasClass('active')) {
117
- (0, anime_1.pageScroll)(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
116
+ // Scrolling to center active TOC element if TOC content is taller than viewport.
117
+ if (getComputedStyle(sideBar).display !== 'none' && tocElement.hasClass('active')) {
118
+ pageScroll(tocElement, target.offsetTop - (tocElement.offsetHeight / 4));
118
119
  }
119
120
  };
120
- const navItems = dom_1.$dom.all('.contents li');
121
+ const navItems = $dom.all('.contents li');
121
122
  if (navItems.length < 1) {
122
123
  return;
123
124
  }
125
+ // @ts-ignore
124
126
  let sections = [...navItems];
125
127
  let activeLock = null;
126
128
  sections = sections.map((element, index) => {
127
129
  const link = element.child('a.toc-link');
128
- const anchor = (0, dom_1.$dom)(decodeURI(link.attr('href')));
130
+ const anchor = $dom(decodeURI(link.attr('href')));
129
131
  if (!anchor)
130
132
  return null;
131
133
  const alink = anchor.child('a.anchor');
132
134
  const anchorScroll = (event) => {
133
135
  event.preventDefault();
134
- const target = (0, dom_1.$dom)(decodeURI(event.currentTarget.attr('href')));
136
+ const target = $dom(decodeURI(event.currentTarget.attr('href')));
135
137
  activeLock = index;
136
- (0, anime_1.pageScroll)(target, null, () => {
138
+ pageScroll(target, null, () => {
137
139
  activateNavByIndex(index);
138
140
  activeLock = null;
139
141
  });
140
142
  };
143
+ // TOC item animation navigate.
141
144
  link.addEventListener('click', anchorScroll);
142
145
  alink && alink.addEventListener('click', (event) => {
143
146
  anchorScroll(event);
144
- (0, tools_1.clipBoard)(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
147
+ clipBoard(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
145
148
  });
146
149
  return anchor;
147
150
  });
148
- const tocElement = globalVars_1.sideBar.child('.contents.panel');
151
+ const tocElement = sideBar.child('.contents.panel');
149
152
  const findIndex = (entries) => {
150
153
  let index = 0;
151
154
  let entry = entries[index];
@@ -165,7 +168,7 @@ const sidebarTOC = () => {
165
168
  };
166
169
  const createIntersectionObserver = () => {
167
170
  const observer = new IntersectionObserver((entries) => {
168
- const index = findIndex(entries) + (globalVars_1.diffY < 0 ? 1 : 0);
171
+ const index = findIndex(entries) + (diffY < 0 ? 1 : 0);
169
172
  if (activeLock === null) {
170
173
  activateNavByIndex(index);
171
174
  }
@@ -178,21 +181,17 @@ const sidebarTOC = () => {
178
181
  };
179
182
  createIntersectionObserver();
180
183
  };
181
- exports.sidebarTOC = sidebarTOC;
182
- const backToTopHandle = () => {
183
- (0, anime_1.pageScroll)(0);
184
+ export const backToTopHandle = () => {
185
+ pageScroll(0);
184
186
  };
185
- exports.backToTopHandle = backToTopHandle;
186
- const goToBottomHandle = () => {
187
- (0, anime_1.pageScroll)(parseInt(String(globalVars_1.Container.changeOrGetHeight())));
187
+ export const goToBottomHandle = () => {
188
+ pageScroll(parseInt(String(Container.changeOrGetHeight())));
188
189
  };
189
- exports.goToBottomHandle = goToBottomHandle;
190
- const goToCommentHandle = () => {
191
- (0, anime_1.pageScroll)((0, dom_1.$dom)('#comments'));
190
+ export const goToCommentHandle = () => {
191
+ pageScroll($dom('#comments'));
192
192
  };
193
- exports.goToCommentHandle = goToCommentHandle;
194
- const menuActive = () => {
195
- dom_1.$dom.each('.menu .item:not(.title)', (element) => {
193
+ export const menuActive = () => {
194
+ $dom.each('.menu .item:not(.title)', (element) => {
196
195
  const target = element.child('a[href]');
197
196
  const parentItem = element.parentNode.parentNode;
198
197
  if (!target)
@@ -209,4 +208,3 @@ const menuActive = () => {
209
208
  }
210
209
  });
211
210
  };
212
- exports.menuActive = menuActive;
@@ -1,141 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initFireworks = void 0;
7
- const theme_shokax_anime_1 = __importDefault(require("theme-shokax-anime"));
8
- const canvasEl = document.createElement('canvas');
9
- canvasEl.style.cssText = 'position:fixed;top:0;left:0;pointer-events:none;z-index:9999999';
10
- document.body.appendChild(canvasEl);
11
- const ctx = canvasEl.getContext('2d');
12
- const numberOfParticles = 30;
13
- let pointerX = 0;
14
- let pointerY = 0;
15
- const tap = 'click';
16
- const colors = CONFIG.fireworks;
17
- function setCanvasSize() {
18
- canvasEl.width = window.innerWidth * 2;
19
- canvasEl.height = window.innerHeight * 2;
20
- canvasEl.style.width = window.innerWidth + 'px';
21
- canvasEl.style.height = window.innerHeight + 'px';
22
- canvasEl.getContext('2d').scale(2, 2);
23
- }
24
- function updateCoords(e) {
25
- pointerX = e.clientX || (e.touches && e.touches[0].clientX);
26
- pointerY = e.clientY || (e.touches && e.touches[0].clientY);
27
- }
28
- function setParticleDirection(p) {
29
- const angle = theme_shokax_anime_1.default.random(0, 360) * Math.PI / 180;
30
- const value = theme_shokax_anime_1.default.random(50, 180);
31
- const radius = [-1, 1][theme_shokax_anime_1.default.random(0, 1)] * value;
32
- return {
33
- x: p.x + radius * Math.cos(angle),
34
- y: p.y + radius * Math.sin(angle)
35
- };
36
- }
37
- function createParticle(x, y) {
38
- const p = {
39
- x,
40
- y,
41
- color: undefined,
42
- radius: undefined,
43
- endPos: undefined,
44
- draw() {
45
- ctx.beginPath();
46
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
47
- ctx.fillStyle = p.color;
48
- ctx.fill();
49
- }
50
- };
51
- p.color = colors[theme_shokax_anime_1.default.random(0, colors.length - 1)];
52
- p.radius = theme_shokax_anime_1.default.random(16, 32);
53
- p.endPos = setParticleDirection(p);
54
- return p;
55
- }
56
- function createCircle(x, y) {
57
- const p = {
58
- x,
59
- y,
60
- color: '#FFF',
61
- radius: 0.1,
62
- endPos: undefined,
63
- alpha: 0.5,
64
- lineWidth: 6,
65
- draw() {
66
- ctx.globalAlpha = p.alpha;
67
- ctx.beginPath();
68
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
69
- ctx.lineWidth = p.lineWidth;
70
- ctx.strokeStyle = p.color;
71
- ctx.stroke();
72
- ctx.globalAlpha = 1;
73
- }
74
- };
75
- return p;
76
- }
77
- function renderParticle(targets) {
78
- for (const target of targets) {
79
- target.draw();
80
- }
81
- }
82
- function animateParticles(x, y) {
83
- const circle = createCircle(x, y);
84
- const particles = [];
85
- for (let i = 0; i < numberOfParticles; i++) {
86
- particles.push(createParticle(x, y));
87
- }
88
- (0, theme_shokax_anime_1.default)().timeline().add({
89
- targets: particles,
90
- duration: theme_shokax_anime_1.default.random(1200, 1800),
91
- easing: 'easeOutExpo',
92
- update: renderParticle,
93
- x: p => p.endPos.x,
94
- y: p => p.endPos.y,
95
- radius: 0.1
96
- }).add({
97
- targets: circle,
98
- duration: theme_shokax_anime_1.default.random(1200, 1800),
99
- easing: 'easeOutExpo',
100
- update: renderParticle,
101
- radius: theme_shokax_anime_1.default.random(80, 160),
102
- lineWidth: 0,
103
- alpha: {
104
- value: 0,
105
- easing: 'linear',
106
- duration: theme_shokax_anime_1.default.random(600, 800)
107
- }
108
- }).play();
109
- }
110
- const render = (0, theme_shokax_anime_1.default)({
111
- duration: Infinity,
112
- update() {
113
- ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
114
- }
115
- });
116
- const hasAncestor = (node, name) => {
117
- name = name.toUpperCase();
118
- do {
119
- if (node === null || node === undefined)
120
- break;
121
- if (node.nodeName === name)
122
- return true;
123
- } while ((node = node.parentNode) !== null);
124
- return false;
125
- };
126
- function initFireworks() {
1
+ import firework from 'mouse-firework';
2
+ /*
3
+ * 烟花分区
4
+ */
5
+ export function initFireworks() {
127
6
  if (typeof CONFIG.fireworks === 'undefined') {
128
7
  return;
129
8
  }
130
- document.addEventListener(tap, (e) => {
131
- if (hasAncestor(e.target, 'a')) {
132
- return;
133
- }
134
- render.play();
135
- updateCoords(e);
136
- animateParticles(pointerX, pointerY);
137
- }, false);
138
- setCanvasSize();
139
- window.addEventListener('resize', setCanvasSize, false);
9
+ firework(CONFIG.fireworks);
140
10
  }
141
- exports.initFireworks = initFireworks;