hexo-theme-shokax 0.2.0-rc3 → 0.2.0-rc5

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
@@ -28,6 +28,8 @@ experiments:
28
28
  debug: false # 使用debug模式启动
29
29
  disableThemeComment: false # 禁用主题评论系统(一般用于关闭评论或让插件接管评论系统)
30
30
  usingRelative: false # _image.yml 使用相对路径
31
+ optimizeLongPosts: false # 优化长文章,这能让长文章的FPS提升70%-150%并解决假死问题,但存在一些副作用
32
+ # 具体见https://docs.kaitaku.xyz/guide/theme.html#%E9%95%BF%E6%96%87%E7%AB%A0%E4%BC%98%E5%8C%96
31
33
 
32
34
  # 优化性能区
33
35
  performance:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.2.0-rc3",
3
+ "version": "0.2.0-rc5",
4
4
  "description": "a hexo theme based on shoka",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/zkz098/hexo-theme-shokaX",
@@ -1,6 +1,5 @@
1
1
  /* global hexo */
2
2
  const fs = require('hexo-fs')
3
- // const url = require('url')
4
3
 
5
4
  hexo.extend.generator.register('script', function (locals) {
6
5
  const log = hexo.log || console.log
@@ -77,6 +76,11 @@ hexo.extend.generator.register('script', function (locals) {
77
76
  }
78
77
  }
79
78
  if (theme.fireworks && theme.fireworks.enable) {
79
+ if (fs.existsSync('themes/shokaX/source/js/_app/fireworks.js')) {
80
+ text += fs.readFileSync('themes/shokaX/source/js/_app/fireworks.js').toString()
81
+ } else {
82
+ text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/fireworks.js').toString()
83
+ }
80
84
  siteConfig.fireworks = theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)']
81
85
  }
82
86
 
@@ -13,21 +13,12 @@
13
13
  img,
14
14
  .tabs,
15
15
  .links {
16
- content-visibility: auto;
17
- contain-intrinsic-size: 979px 1.1em;
18
16
  &:last-child {
19
17
  margin-bottom: 0;
20
18
  }
21
19
  }
22
20
 
23
- span {
24
- content-visibility: auto;
25
- contain-intrinsic-size: 979px 1.1em;
26
- }
27
-
28
21
  ul, dd, ol {
29
- content-visibility: auto;
30
- contain-intrinsic-size: 979px 3.5em;
31
22
  ul, ol {
32
23
  margin-top: 0;
33
24
  }
@@ -8,7 +8,9 @@
8
8
  min-height: 25rem;
9
9
  z-index: -9;
10
10
  background-color: #363636;
11
-
11
+ content-visibility: auto;
12
+ contain-intrinsic-size: 100vw 70vh;
13
+
12
14
  img {
13
15
  width: 100%;
14
16
  height: 100%;
@@ -5,9 +5,12 @@
5
5
  min-height: 3.125rem;
6
6
  max-height: 9.375rem;
7
7
  position:relative;
8
+ content-visibility: auto;
9
+ contain-intrinsic-size: 100vw 15vh;
8
10
 
9
11
  +mobile() {
10
12
  height: 10vh;
13
+ contain-intrinsic-size: 100vw 10vh;
11
14
  }
12
15
  }
13
16
  /* Animation */
@@ -33,4 +33,6 @@ if $custom = hexo-config('style.custom')
33
33
  for $inject_style in hexo-config('injects.style')
34
34
  @import $inject_style;
35
35
 
36
+ if $optimize = hexo-config('experiments.optimizeLongPosts')
37
+ @import "optimize.styl"
36
38
 
@@ -0,0 +1,6 @@
1
+ .md {
2
+ span:not(.katex), p, pre, li, a {
3
+ content-visibility: auto;
4
+ contain-intrinsic-size: auto 1em;
5
+ }
6
+ }
@@ -1,132 +1,3 @@
1
- const canvasEl = document.createElement('canvas');
2
- canvasEl.style.cssText = 'position:fixed;top:0;left:0;pointer-events:none;z-index:9999999';
3
- document.body.appendChild(canvasEl);
4
- const ctx = canvasEl.getContext('2d');
5
- const numberOfParticules = 30;
6
- let pointerX = 0;
7
- let pointerY = 0;
8
- const tap = 'click';
9
- const colors = CONFIG.fireworks;
10
- function setCanvasSize() {
11
- canvasEl.width = window.innerWidth * 2;
12
- canvasEl.height = window.innerHeight * 2;
13
- canvasEl.style.width = window.innerWidth + 'px';
14
- canvasEl.style.height = window.innerHeight + 'px';
15
- canvasEl.getContext('2d').scale(2, 2);
16
- }
17
- function updateCoords(e) {
18
- pointerX = e.clientX || (e.touches && e.touches[0].clientX);
19
- pointerY = e.clientY || (e.touches && e.touches[0].clientY);
20
- }
21
- function setParticuleDirection(p) {
22
- const angle = anime.random(0, 360) * Math.PI / 180;
23
- const value = anime.random(50, 180);
24
- const radius = [-1, 1][anime.random(0, 1)] * value;
25
- return {
26
- x: p.x + radius * Math.cos(angle),
27
- y: p.y + radius * Math.sin(angle)
28
- };
29
- }
30
- function createParticule(x, y) {
31
- const p = {
32
- x: undefined,
33
- y: undefined,
34
- color: undefined,
35
- radius: undefined,
36
- endPos: undefined,
37
- draw: undefined
38
- };
39
- p.x = x;
40
- p.y = y;
41
- p.color = colors[anime.random(0, colors.length - 1)];
42
- p.radius = anime.random(16, 32);
43
- p.endPos = setParticuleDirection(p);
44
- p.draw = function () {
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
- return p;
51
- }
52
- function createCircle(x, y) {
53
- const p = {
54
- x: undefined,
55
- y: undefined,
56
- color: undefined,
57
- radius: undefined,
58
- endPos: undefined,
59
- alpha: undefined,
60
- lineWidth: undefined,
61
- draw: undefined
62
- };
63
- p.x = x;
64
- p.y = y;
65
- p.color = '#FFF';
66
- p.radius = 0.1;
67
- p.alpha = 0.5;
68
- p.lineWidth = 6;
69
- p.draw = function () {
70
- ctx.globalAlpha = p.alpha;
71
- ctx.beginPath();
72
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
73
- ctx.lineWidth = p.lineWidth;
74
- ctx.strokeStyle = p.color;
75
- ctx.stroke();
76
- ctx.globalAlpha = 1;
77
- };
78
- return p;
79
- }
80
- function renderParticule(anim) {
81
- for (let i = 0; i < anim.animatables.length; i++) {
82
- anim.animatables[i].target.draw();
83
- }
84
- }
85
- function animateParticules(x, y) {
86
- const circle = createCircle(x, y);
87
- const particules = [];
88
- for (let i = 0; i < numberOfParticules; i++) {
89
- particules.push(createParticule(x, y));
90
- }
91
- anime.timeline().add({
92
- targets: particules,
93
- x: function (p) {
94
- return p.endPos.x;
95
- },
96
- y: function (p) {
97
- return p.endPos.y;
98
- },
99
- radius: 0.1,
100
- duration: anime.random(1200, 1800),
101
- easing: 'easeOutExpo',
102
- update: renderParticule
103
- }).add({
104
- targets: circle,
105
- radius: anime.random(80, 160),
106
- lineWidth: 0,
107
- alpha: {
108
- value: 0,
109
- easing: 'linear',
110
- duration: anime.random(600, 800)
111
- },
112
- duration: anime.random(1200, 1800),
113
- easing: 'easeOutExpo',
114
- update: renderParticule
115
- }, 0);
116
- }
117
- const render = anime({
118
- duration: Infinity,
119
- update: function () {
120
- ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
121
- }
122
- });
123
- document.addEventListener(tap, function (e) {
124
- render.play();
125
- updateCoords(e);
126
- animateParticules(pointerX, pointerY);
127
- }, false);
128
- setCanvasSize();
129
- window.addEventListener('resize', setCanvasSize, false);
130
1
  const sideBarToggleHandle = function (event, force) {
131
2
  if (sideBar.hasClass('on')) {
132
3
  sideBar.removeClass('on');
@@ -0,0 +1,129 @@
1
+ const canvasEl = document.createElement('canvas');
2
+ canvasEl.style.cssText = 'position:fixed;top:0;left:0;pointer-events:none;z-index:9999999';
3
+ document.body.appendChild(canvasEl);
4
+ const ctx = canvasEl.getContext('2d');
5
+ const numberOfParticules = 30;
6
+ let pointerX = 0;
7
+ let pointerY = 0;
8
+ const tap = 'click';
9
+ const colors = CONFIG.fireworks;
10
+ function setCanvasSize() {
11
+ canvasEl.width = window.innerWidth * 2;
12
+ canvasEl.height = window.innerHeight * 2;
13
+ canvasEl.style.width = window.innerWidth + 'px';
14
+ canvasEl.style.height = window.innerHeight + 'px';
15
+ canvasEl.getContext('2d').scale(2, 2);
16
+ }
17
+ function updateCoords(e) {
18
+ pointerX = e.clientX || (e.touches && e.touches[0].clientX);
19
+ pointerY = e.clientY || (e.touches && e.touches[0].clientY);
20
+ }
21
+ function setParticuleDirection(p) {
22
+ const angle = anime.random(0, 360) * Math.PI / 180;
23
+ const value = anime.random(50, 180);
24
+ const radius = [-1, 1][anime.random(0, 1)] * value;
25
+ return {
26
+ x: p.x + radius * Math.cos(angle),
27
+ y: p.y + radius * Math.sin(angle)
28
+ };
29
+ }
30
+ function createParticule(x, y) {
31
+ const p = {
32
+ x: undefined,
33
+ y: undefined,
34
+ color: undefined,
35
+ radius: undefined,
36
+ endPos: undefined,
37
+ draw: undefined
38
+ };
39
+ p.x = x;
40
+ p.y = y;
41
+ p.color = colors[anime.random(0, colors.length - 1)];
42
+ p.radius = anime.random(16, 32);
43
+ p.endPos = setParticuleDirection(p);
44
+ p.draw = function () {
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
+ return p;
51
+ }
52
+ function createCircle(x, y) {
53
+ const p = {
54
+ x: undefined,
55
+ y: undefined,
56
+ color: undefined,
57
+ radius: undefined,
58
+ endPos: undefined,
59
+ alpha: undefined,
60
+ lineWidth: undefined,
61
+ draw: undefined
62
+ };
63
+ p.x = x;
64
+ p.y = y;
65
+ p.color = '#FFF';
66
+ p.radius = 0.1;
67
+ p.alpha = 0.5;
68
+ p.lineWidth = 6;
69
+ p.draw = function () {
70
+ ctx.globalAlpha = p.alpha;
71
+ ctx.beginPath();
72
+ ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
73
+ ctx.lineWidth = p.lineWidth;
74
+ ctx.strokeStyle = p.color;
75
+ ctx.stroke();
76
+ ctx.globalAlpha = 1;
77
+ };
78
+ return p;
79
+ }
80
+ function renderParticule(anim) {
81
+ for (let i = 0; i < anim.animatables.length; i++) {
82
+ anim.animatables[i].target.draw();
83
+ }
84
+ }
85
+ function animateParticules(x, y) {
86
+ const circle = createCircle(x, y);
87
+ const particules = [];
88
+ for (let i = 0; i < numberOfParticules; i++) {
89
+ particules.push(createParticule(x, y));
90
+ }
91
+ anime.timeline().add({
92
+ targets: particules,
93
+ x: function (p) {
94
+ return p.endPos.x;
95
+ },
96
+ y: function (p) {
97
+ return p.endPos.y;
98
+ },
99
+ radius: 0.1,
100
+ duration: anime.random(1200, 1800),
101
+ easing: 'easeOutExpo',
102
+ update: renderParticule
103
+ }).add({
104
+ targets: circle,
105
+ radius: anime.random(80, 160),
106
+ lineWidth: 0,
107
+ alpha: {
108
+ value: 0,
109
+ easing: 'linear',
110
+ duration: anime.random(600, 800)
111
+ },
112
+ duration: anime.random(1200, 1800),
113
+ easing: 'easeOutExpo',
114
+ update: renderParticule
115
+ }, 0);
116
+ }
117
+ const render = anime({
118
+ duration: Infinity,
119
+ update: function () {
120
+ ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
121
+ }
122
+ });
123
+ document.addEventListener(tap, function (e) {
124
+ render.play();
125
+ updateCoords(e);
126
+ animateParticules(pointerX, pointerY);
127
+ }, false);
128
+ setCanvasSize();
129
+ window.addEventListener('resize', setCanvasSize, false);