valaxy-theme-yun 0.14.49 → 0.14.51

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.
@@ -5,21 +5,21 @@ import { defineAsyncComponent } from 'vue'
5
5
  const runtimeConfig = useRuntimeConfig()
6
6
 
7
7
  // not import from 'valaxy-addon-waline' to judge
8
- const YunWaline = runtimeConfig.value.addons['valaxy-addon-waline']
9
- ? defineAsyncComponent(() => import('./YunWaline.vue'))
8
+ const AsyncYunWaline = runtimeConfig.value.addons['valaxy-addon-waline']
9
+ ? defineAsyncComponent(() => import('./third/YunWaline.vue'))
10
10
  : () => null
11
11
 
12
12
  // todo: refactor
13
- const YunTwikoo = runtimeConfig.value.addons['valaxy-addon-twikoo']
14
- ? defineAsyncComponent(() => import('./YunTwikoo.vue'))
13
+ const AsyncYunTwikoo = runtimeConfig.value.addons['valaxy-addon-twikoo']
14
+ ? defineAsyncComponent(() => import('./third/YunTwikoo.vue'))
15
15
  : () => null
16
16
  </script>
17
17
 
18
18
  <template>
19
19
  <YunCard w="full" p="4" class="comment sm:p-6 lg:px-12 xl:px-16">
20
20
  <ClientOnly>
21
- <YunWaline />
22
- <YunTwikoo />
21
+ <AsyncYunWaline />
22
+ <AsyncYunTwikoo />
23
23
  </ClientOnly>
24
24
  </YunCard>
25
25
  </template>
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { useThemeConfig } from 'valaxy'
3
3
  import { onMounted } from 'vue'
4
- import { createFireworks } from '../features/fireworks'
4
+ import { createFireworks } from '@explosions/fireworks'
5
5
 
6
6
  const themeConfig = useThemeConfig()
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
- "version": "0.14.49",
3
+ "version": "0.14.51",
4
4
  "author": {
5
5
  "email": "me@yunyoujun.cn",
6
6
  "name": "YunYouJun",
@@ -17,6 +17,7 @@
17
17
  "main": "node/index.ts",
18
18
  "types": "types/index.d.ts",
19
19
  "dependencies": {
20
+ "@explosions/fireworks": "^0.0.2",
20
21
  "@iconify-json/ant-design": "^1.1.8",
21
22
  "@iconify-json/simple-icons": "^1.1.66",
22
23
  "animejs": "^3.2.1",
@@ -24,6 +25,6 @@
24
25
  },
25
26
  "devDependencies": {
26
27
  "@types/animejs": "^3.1.7",
27
- "valaxy": "0.14.49"
28
+ "valaxy": "0.14.51"
28
29
  }
29
30
  }
package/valaxy.config.ts CHANGED
@@ -31,17 +31,6 @@ export default defineValaxyTheme<ThemeConfig>((options) => {
31
31
  return {
32
32
  themeConfig: defaultThemeConfig,
33
33
  vite: {
34
- build: {
35
- rollupOptions: {
36
- // add on demand external
37
- external: [
38
- 'valaxy-addon-algolia',
39
- // adapt for twikoo
40
- 'valaxy-addon-twikoo',
41
- 'valaxy-addon-waline',
42
- ],
43
- },
44
- },
45
34
  plugins: [ThemeVitePlugin(options)],
46
35
  },
47
36
  unocss: {
@@ -1,247 +0,0 @@
1
- /**
2
- * @see https://codepen.io/juliangarnier/pen/gmOwJX
3
- * inherited from hexo-theme-yun
4
- * customized by valaxy-theme-yun
5
- * @author YunYouJun
6
- */
7
-
8
- import anime from 'animejs'
9
- import { TinyColor } from '@ctrl/tinycolor'
10
-
11
- interface MinMax {
12
- min: number
13
- max: number
14
- }
15
-
16
- interface FireworksConfig {
17
- selector: string
18
- colors: string[]
19
- numberOfParticles: number
20
- orbitRadius: MinMax
21
- circleRadius: MinMax
22
- diffuseRadius: MinMax
23
- animeDuration: MinMax
24
- }
25
-
26
- export interface Point {
27
- x: number
28
- y: number
29
- }
30
-
31
- export interface Particle extends Point {
32
- color: string
33
- radius: number
34
- endPos: Point
35
- draw(): void
36
- }
37
-
38
- /**
39
- * 创建烟花
40
- * @param config
41
- */
42
- export function createFireworks(config: Partial<FireworksConfig>) {
43
- const {
44
- selector = 'canvas.fireworks',
45
- // sky blue
46
- numberOfParticles = 20,
47
- circleRadius = {
48
- min: 10,
49
- max: 20,
50
- },
51
- diffuseRadius = {
52
- min: 50,
53
- max: 100,
54
- },
55
- orbitRadius = {
56
- min: 50,
57
- max: 100,
58
- },
59
- animeDuration = {
60
- min: 900,
61
- max: 1500,
62
- },
63
- } = config
64
-
65
- const colors = (config.colors && config.colors.length > 0)
66
- ? config.colors
67
- : ['#66A7DD', '#3E83E1', '#214EC2']
68
-
69
- let pointerX = 0
70
- let pointerY = 0
71
-
72
- const canvasEl = document.querySelector(selector) as HTMLCanvasElement
73
- const ctx = canvasEl.getContext('2d')
74
-
75
- if (!ctx)
76
- return
77
-
78
- /**
79
- * 设置画布尺寸
80
- */
81
- function setCanvasSize(canvasEl: HTMLCanvasElement) {
82
- canvasEl.width = window.innerWidth
83
- canvasEl.height = window.innerHeight
84
- canvasEl.style.width = `${window.innerWidth}px`
85
- canvasEl.style.height = `${window.innerHeight}px`
86
- }
87
-
88
- /**
89
- * update pointer
90
- * @param e
91
- */
92
- function updateCoords(e: MouseEvent | TouchEvent) {
93
- pointerX
94
- = 'clientX' in e
95
- ? e.clientX
96
- : (e.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX)
97
- pointerY
98
- = 'clientY' in e
99
- ? e.clientY
100
- : (e.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY)
101
- }
102
-
103
- function setParticleDirection(p: Point) {
104
- const angle = (anime.random(0, 360) * Math.PI) / 180
105
- const value = anime.random(
106
- diffuseRadius.min,
107
- diffuseRadius.max,
108
- )
109
- const radius = [-1, 1][anime.random(0, 1)] * value
110
- return {
111
- x: p.x + radius * Math.cos(angle),
112
- y: p.y + radius * Math.sin(angle),
113
- }
114
- }
115
-
116
- /**
117
- * 在指定位置创建粒子
118
- * @param {number} x
119
- * @param {number} y
120
- * @returns
121
- */
122
- function createParticle(x: number, y: number) {
123
- const tinyColor = new TinyColor(colors[anime.random(0, colors.length - 1)])
124
- tinyColor.setAlpha(anime.random(0.2, 0.8))
125
-
126
- const p: Particle = {
127
- x,
128
- y,
129
- color: tinyColor.toRgbString(),
130
- radius: anime.random(circleRadius.min, circleRadius.max),
131
- endPos: setParticleDirection({ x, y }),
132
- draw: () => {},
133
- }
134
-
135
- p.draw = function () {
136
- if (!ctx)
137
- return
138
-
139
- ctx.beginPath()
140
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true)
141
- ctx.fillStyle = p.color
142
- ctx.fill()
143
- }
144
- return p
145
- }
146
-
147
- function createCircle(x: number, y: number) {
148
- const p = {
149
- x,
150
- y,
151
- color: '#000',
152
- radius: 0.1,
153
- alpha: 0.5,
154
- lineWidth: 6,
155
- draw() {},
156
- }
157
-
158
- p.draw = () => {
159
- if (!ctx)
160
- return
161
-
162
- ctx.globalAlpha = p.alpha
163
- ctx.beginPath()
164
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true)
165
- ctx.lineWidth = p.lineWidth
166
- ctx.strokeStyle = p.color
167
- ctx.stroke()
168
- ctx.globalAlpha = 1
169
- }
170
- return p
171
- }
172
-
173
- function renderParticle(anim: anime.AnimeInstance) {
174
- for (let i = 0; i < anim.animatables.length; i++) {
175
- const target = anim.animatables[i].target as any as Particle
176
- target.draw()
177
- }
178
- }
179
-
180
- function animateParticles(x: number, y: number) {
181
- const circle = createCircle(x, y)
182
- const particles = []
183
- for (let i = 0; i < numberOfParticles; i++)
184
- particles.push(createParticle(x, y))
185
-
186
- anime
187
- .timeline()
188
- .add({
189
- targets: particles,
190
- x(p: Particle) {
191
- return p.endPos.x
192
- },
193
- y(p: Particle) {
194
- return p.endPos.y
195
- },
196
- radius: 0.1,
197
- duration: anime.random(
198
- animeDuration.min,
199
- animeDuration.max,
200
- ),
201
- easing: 'easeOutExpo',
202
- update: renderParticle,
203
- })
204
- .add(
205
- {
206
- targets: circle,
207
- radius: anime.random(orbitRadius.min, orbitRadius.max),
208
- lineWidth: 0,
209
- alpha: {
210
- value: 0,
211
- easing: 'linear',
212
- duration: anime.random(600, 800),
213
- },
214
- duration: anime.random(1200, 1800),
215
- easing: 'easeOutExpo',
216
- update: renderParticle,
217
- },
218
- 0,
219
- )
220
- }
221
-
222
- const render = anime({
223
- duration: Number.POSITIVE_INFINITY,
224
- update: () => {
225
- ctx.clearRect(0, 0, canvasEl.width, canvasEl.height)
226
- },
227
- })
228
-
229
- document.addEventListener(
230
- 'mousedown',
231
- (e) => {
232
- render.play()
233
- updateCoords(e)
234
- animateParticles(pointerX, pointerY)
235
- },
236
- false,
237
- )
238
-
239
- setCanvasSize(canvasEl)
240
- window.addEventListener(
241
- 'resize',
242
- () => {
243
- setCanvasSize(canvasEl)
244
- },
245
- false,
246
- )
247
- }