Skip to content

Commit 4a93b5d

Browse files
committed
fix(example): clean up Nuxt example & fix type-checking
1 parent 5b4de3a commit 4a93b5d

File tree

5 files changed

+48
-53
lines changed

5 files changed

+48
-53
lines changed

apps/nuxt3/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

apps/nuxt3/app.vue

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
<template>
2-
<div>
3-
<NuxtWelcome />
4-
<vue-particles
5-
id="tsparticles"
6-
:options="options"
7-
:particles-init="particlesInit"
8-
/>
9-
</div>
2+
<div>
3+
<NuxtWelcome />
4+
<vue-particles
5+
id="tsparticles"
6+
:options="options"
7+
:particles-init="particlesInit"
8+
@particles-loaded="particlesLoaded"
9+
/>
10+
</div>
1011
</template>
11-
<script>
12+
<script setup lang="ts">
1213
import { loadFull } from "tsparticles";
14+
import type { IOptions } from "tsparticles-engine";
15+
import {Container} from "tsparticles-engine";
1316
14-
export default {
15-
name: "NuxtTutorial",
16-
data() {
17-
return {
18-
options: {
19-
background: {
20-
color: "#fff"
21-
},
22-
fullScreen: {
23-
enable: true,
24-
zIndex: -1
25-
},
26-
particles: {
27-
color: {
28-
value: "#000"
29-
},
30-
links: {
31-
color: "#000",
32-
enable: true
33-
},
34-
move: {
35-
enable: true
36-
},
37-
number: {
38-
value: 100
39-
}
40-
}
41-
}
42-
};
17+
const options = {
18+
background: {
19+
color: "#fff"
20+
},
21+
fullScreen: {
22+
enable: true,
23+
zIndex: -1
24+
},
25+
particles: {
26+
color: {
27+
value: "#000"
4328
},
44-
methods: {
45-
particlesInit: async (engine) => {
46-
await loadFull(engine);
47-
}
29+
links: {
30+
color: "#000",
31+
enable: true
32+
},
33+
move: {
34+
enable: true
35+
},
36+
number: {
37+
value: 100
4838
}
49-
};
39+
}
40+
} as IOptions
41+
42+
const particlesInit = async (engine) => {
43+
await loadFull(engine)
44+
console.log(engine)
45+
}
46+
47+
const particlesLoaded = (container: Container) => {
48+
console.log(toRaw(container))
49+
}
50+
5051
</script>
5152
<style>
5253
.bg-white {
53-
background: none !important;
54+
background: none !important;
5455
}
5556
</style>

apps/nuxt3/nuxt.config.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
import { defineNuxtConfig } from 'nuxt/config'
22

33
// https://v3.nuxtjs.org/api/configuration/nuxt.config
4-
export default defineNuxtConfig({
5-
plugins: [
6-
{
7-
src: '~/plugins/vue3-particles.ts',
8-
mode: 'client',
9-
},
10-
],
11-
})
4+
export default defineNuxtConfig({})

apps/nuxt3/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"nuxt": "^3.6.5",
3636
"prettier": "^3.0.1",
3737
"tsparticles": "^2.12.0",
38+
"tsparticles-engine": "^2.12.0",
3839
"typescript": "^5.1.6",
3940
"vue": "^3.3.4",
4041
"vue3-particles": "workspace:^",

apps/nuxt3/shim-vue3-particles.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)