From 1c8314c6fa5c36eca0acdb3eb717c1bf5233fba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=91=E5=85=88=E6=A3=AE?= Date: Tue, 12 Nov 2024 20:23:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0pinia=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nuxt.config.ts | 13 ++++++++++++- package.json | 2 +- plugins/pinia.ts | 10 ---------- pnpm-lock.yaml | 34 ++++++++++++++++---------------- stores/index.ts | 50 ++++++++++++------------------------------------ tsconfig.json | 7 +++---- utils/index.ts | 12 ------------ 7 files changed, 45 insertions(+), 83 deletions(-) delete mode 100644 plugins/pinia.ts diff --git a/nuxt.config.ts b/nuxt.config.ts index e7e5e29..28c5217 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -14,7 +14,18 @@ export default defineNuxtConfig({ }, css: ["~/assets/css/main.css", "element-plus/theme-chalk/dark/css-vars.css"], - modules: ["@element-plus/nuxt", "@pinia/nuxt", "pinia-plugin-persistedstate/nuxt", "@nuxtjs/tailwindcss"], + modules: [ + "@element-plus/nuxt", + "@pinia/nuxt", + [ + "pinia-plugin-persistedstate/nuxt", + { + key: "__glj_persisted_%id", + storage: "localStorage" + } + ], + "@nuxtjs/tailwindcss" + ], alias: { "@": path.resolve(__dirname, "./") diff --git a/package.json b/package.json index f0d4160..c85cfb9 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "pinia": "^2.2.6", "pinia-plugin-persistedstate": "^4.1.3", "postcss": "^8.4.38", - "typescript": "^5.4.5", + "typescript": "^5.6.3", "vue-clipboard3": "^2.0.0" } } diff --git a/plugins/pinia.ts b/plugins/pinia.ts deleted file mode 100644 index 59fd19e..0000000 --- a/plugins/pinia.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { createPersistedState } from 'pinia-plugin-persistedstate' -import { defineNuxtPlugin } from "nuxt/app"; -export default defineNuxtPlugin((nuxtApp: any) => { - nuxtApp.$pinia.use( - createPersistedState({ - storage: localStorage, - key: id => `__glj_persisted_${id}` - }) - ); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5e8234..62f5335 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,7 +75,7 @@ importers: specifier: ^8.4.38 version: 8.4.49 typescript: - specifier: ^5.4.5 + specifier: ^5.6.3 version: 5.6.3 vue-clipboard3: specifier: ^2.0.0 @@ -2471,8 +2471,8 @@ packages: engines: {node: '>=10'} hasBin: true - mlly@1.7.2: - resolution: {integrity: sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==} + mlly@1.7.3: + resolution: {integrity: sha512-xUsx5n/mN0uQf4V548PKQ+YShA4/IW0KI1dZhrNrPCLG+xizETbHTkOa1f8/xut9JRPp8kQuMnz0oqwkTiLo/A==} mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} @@ -4311,7 +4311,7 @@ snapshots: jiti: 2.4.0 klona: 2.0.6 knitwork: 1.1.0 - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 pkg-types: 1.2.1 scule: 1.3.0 @@ -4393,7 +4393,7 @@ snapshots: jiti: 2.4.0 knitwork: 1.1.0 magic-string: 0.30.12 - mlly: 1.7.2 + mlly: 1.7.3 ohash: 1.1.4 pathe: 1.1.2 perfect-debounce: 1.0.0 @@ -5182,7 +5182,7 @@ snapshots: dotenv: 16.4.5 giget: 1.2.3 jiti: 2.4.0 - mlly: 1.7.2 + mlly: 1.7.3 ohash: 1.1.4 pathe: 1.1.2 perfect-debounce: 1.0.0 @@ -5668,7 +5668,7 @@ snapshots: externality@1.0.2: dependencies: enhanced-resolve: 5.17.1 - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 ufo: 1.5.4 @@ -5932,7 +5932,7 @@ snapshots: impound@0.2.0(rollup@4.25.0): dependencies: '@rollup/pluginutils': 5.1.3(rollup@4.25.0) - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 unenv: 1.10.0 unplugin: 1.15.0 @@ -6178,7 +6178,7 @@ snapshots: h3: 1.13.0 http-shutdown: 1.2.2 jiti: 2.4.0 - mlly: 1.7.2 + mlly: 1.7.3 node-forge: 1.3.1 pathe: 1.1.2 std-env: 3.8.0 @@ -6188,7 +6188,7 @@ snapshots: local-pkg@0.5.0: dependencies: - mlly: 1.7.2 + mlly: 1.7.3 pkg-types: 1.2.1 lodash-es@4.17.21: {} @@ -6313,7 +6313,7 @@ snapshots: mkdirp@1.0.4: {} - mlly@1.7.2: + mlly@1.7.3: dependencies: acorn: 8.14.0 pathe: 1.1.2 @@ -6393,7 +6393,7 @@ snapshots: magic-string: 0.30.12 magicast: 0.3.5 mime: 4.0.4 - mlly: 1.7.2 + mlly: 1.7.3 node-fetch-native: 1.6.4 ofetch: 1.4.1 ohash: 1.1.4 @@ -6521,7 +6521,7 @@ snapshots: klona: 2.0.6 knitwork: 1.1.0 magic-string: 0.30.12 - mlly: 1.7.2 + mlly: 1.7.3 nanotar: 0.1.1 nitropack: 2.10.4(typescript@5.6.3) nuxi: 3.15.0 @@ -6752,7 +6752,7 @@ snapshots: pkg-types@1.2.1: dependencies: confbox: 0.1.8 - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 pluralize@8.0.0: {} @@ -7463,7 +7463,7 @@ snapshots: fast-glob: 3.3.2 local-pkg: 0.5.0 magic-string: 0.30.12 - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 pkg-types: 1.2.1 scule: 1.3.0 @@ -7486,7 +7486,7 @@ snapshots: json5: 2.2.3 local-pkg: 0.5.0 magic-string: 0.30.12 - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 scule: 1.3.0 unplugin: 1.15.0 @@ -7540,7 +7540,7 @@ snapshots: dependencies: knitwork: 1.1.0 magic-string: 0.30.12 - mlly: 1.7.2 + mlly: 1.7.3 pathe: 1.1.2 pkg-types: 1.2.1 unplugin: 1.15.0 diff --git a/stores/index.ts b/stores/index.ts index 2aaf879..e5a24aa 100644 --- a/stores/index.ts +++ b/stores/index.ts @@ -27,51 +27,25 @@ export default defineStore("main", { saveErrorLog: true, // 是否保存错误日志 logLevel: "error", //日志等级 devName: false, //自定义网卡名 - devNameValue: "", //自定义网卡名 + devNameValue: "" //自定义网卡名 }, + cidrEnable: false, + basePeers: ["public.easytier.top:11010"], theme: false, //主题 false light true dark configStartEnable: false, //使用配置文件启动 configPath: "", //配置文件路径 - cidrEnable: false, + winIpBcAutoStart: true, + winipBcPid: 0, winipBcStart: false, - winIpBcAutoStart: true, - basePeers: ["public.easytier.top:11010"], + }; }, persist: { - paths: [ - "basePeers", - "cidrEnable", - "theme", - "configStartEnable", - "configPath", - "winIpBcAutoStart", - "config.proxyNetworks", - "config.serverUrl", - "config.networkName", - "config.protocol", - "config.networkPassword", - "config.disbleP2p", - "config.autoStart", - "config.coonectAfterStart", - "config.disableIpv6", - "config.disbleListenner", - "config.disableEncryption", - "config.multiThread", - "config.enablExitNode", - "config.noTun", - "config.latencyfirst", - "config.useSmoltcp", - "config.disableUdpHolePunching", - "config.relayAllPeerrpc", - "config.hostname", - "config.ipv4", - "config.dhcp", - "config.saveErrorLog", - "config.logLevel", - "config.devName", - "config.devNameValue", - ], - }, + // 除了这些,其他都要存下来 + omit: [ + "winipBcPid", + "winipBcStart" + ] + } }); diff --git a/tsconfig.json b/tsconfig.json index b7a78a9..6b07e80 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -28,17 +28,16 @@ "compilerOptions": { "target": "ESNext", "module": "ESNext", + "moduleResolution": "Node", // "types": ["element-plus/global"] - // "moduleResolution":"Bundler", "resolveJsonModule": true, // 从 Vue 3.4 开始,Vue 不再隐式注册全局 JSX 命名空间。要指示 TypeScript 使用 Vue 的 JSX 类型定义,请确保在你的 tsconfig.json 中包含以下内容 "jsx": "preserve", "jsxImportSource": "vue", - "types": ["@pinia/nuxt", "vite/client", "element-plus/global"], + "types": ["@pinia/nuxt", "vite/client", "element-plus/global", "pinia-plugin-persistedstate"], "allowJs": true, // 允许编译器编译JS,JSX文件 - "checkJs": true, // 允许在JS文件中报错,通常与allowJS一起使用 + "checkJs": false, // 允许在JS文件中报错,通常与allowJS一起使用 "esModuleInterop": true, // 允许export=导出,由import from 导入 - "lib": ["DOM", "ESNext"], "allowSyntheticDefaultImports": true } diff --git a/utils/index.ts b/utils/index.ts index 87a33c7..9171b88 100644 --- a/utils/index.ts +++ b/utils/index.ts @@ -1,17 +1,5 @@ -import { ElMessage } from "element-plus"; -import Clipboard from "vue-clipboard3"; - export const ENV = import.meta.env; -export const clipBoardCopy = async (text: string) => { - const { toClipboard } = Clipboard(); - try { - await toClipboard(text); - ElMessage.success("复制成功"); - } catch (e) { - ElMessage.error("复制失败"); - } -}; //防抖 export const bounce = (time = 3000) => {