From 1765adacdad295101e3d0479841affcca8a9ec7e Mon Sep 17 00:00:00 2001 From: kunish Date: Sun, 3 Sep 2023 18:16:09 +0800 Subject: [PATCH] feat: display current version --- package.json | 2 +- src/components/Header.tsx | 4 ++-- src/pages/Config.tsx | 2 ++ src/{types.d.ts => types/index.d.ts} | 0 src/vite-env.d.ts | 7 +++++++ tsconfig.json | 1 + vite.config.ts | 4 ++++ 7 files changed, 17 insertions(+), 3 deletions(-) rename src/{types.d.ts => types/index.d.ts} (100%) create mode 100644 src/vite-env.d.ts diff --git a/package.json b/package.json index d82e5ad..d1bf605 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "metacubexd", "version": "1.58.0", - "description": "Clash-Meta Dashboard", + "description": "Clash.Meta Dashboard, The Official One, XD", "license": "MIT", "type": "module", "scripts": { diff --git a/src/components/Header.tsx b/src/components/Header.tsx index febbafc..e74d379 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -156,11 +156,11 @@ export const Header = () => { - metacubexd + metacube, xd diff --git a/src/pages/Config.tsx b/src/pages/Config.tsx index 83b21de..1a9fd83 100644 --- a/src/pages/Config.tsx +++ b/src/pages/Config.tsx @@ -340,6 +340,8 @@ export default () => { + + {import.meta.env.version} ) } diff --git a/src/types.d.ts b/src/types/index.d.ts similarity index 100% rename from src/types.d.ts rename to src/types/index.d.ts diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..2dc7d14 --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1,7 @@ +interface ImportMetaEnv { + readonly version: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} diff --git a/tsconfig.json b/tsconfig.json index 609895e..317af43 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "node", + "resolveJsonModule": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "jsx": "preserve", diff --git a/vite.config.ts b/vite.config.ts index e1d5711..adfcdf9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,11 +1,15 @@ import { defineConfig, splitVendorChunkPlugin } from 'vite' import { VitePWA } from 'vite-plugin-pwa' import solidPlugin from 'vite-plugin-solid' +import pkgJSON from './package.json' export default defineConfig({ base: './', build: { chunkSizeWarningLimit: 1000 }, resolve: { alias: { '~': '/src' } }, + define: { + 'import.meta.env.version': JSON.stringify(pkgJSON.version), + }, plugins: [ solidPlugin(), splitVendorChunkPlugin(),