diff --git a/package.json b/package.json index 4e25379..81bef24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lolosia-web", - "version": "2.0.2", + "version": "0.0.1-alpha", "license": "MIT", "author": "一七年夏", "packageManager": "pnpm@9.0.6", diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 229752b..f73a632 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -60,10 +60,14 @@ import { ElMessage } from 'element-plus' const buildEnv = (() => { const time = import.meta.env.VITE_BUILD_TIMESTAMP - if (!time) return null - const build = import.meta.env.VITE_BUILD_DISPLAY_NAME - const hash = (import.meta.env.VITE_GIT_COMMIT || '').slice(0, 8) - return `构建 ${build} ${hash} ${time}` + const version = import.meta.env.PROJECT_VERSION + if (time) { + const build = import.meta.env.VITE_BUILD_DISPLAY_NAME + const hash = (import.meta.env.VITE_GIT_COMMIT || '').slice(0, 8) + return `当前版本 ${version}-${hash} 构建 ${build} 于 ${time}` + } else { + return `版本 ${version}-dev` + } })() /* listen router change and set the query */ diff --git a/typings/env.d.ts b/typings/env.d.ts index d085419..b39b8a1 100644 --- a/typings/env.d.ts +++ b/typings/env.d.ts @@ -7,6 +7,7 @@ declare global { readonly VITE_BUILD_TIMESTAMP: string readonly VITE_BUILD_DISPLAY_NAME: string readonly VITE_GIT_COMMIT: string + readonly PROJECT_VERSION: string // 更多环境变量... } interface ImportMeta { diff --git a/vite.config.ts b/vite.config.ts index e4f6722..04e2f9b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -14,6 +14,7 @@ import ReactivityTransform from '@vue-macros/reactivity-transform/vite' // const prodMock = setting.openProdMock import vitePluginSetupExtend from './src/plugins/vite-plugin-setup-extend' import vitePluginVueSetupExtend from 'vite-plugin-vue-setup-extend' +import packageJson from './package.json' // import { visualizer } from 'rollup-plugin-visualizer' const pathSrc = resolve(__dirname, 'src') export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => { @@ -23,7 +24,8 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => { define: { //define global var GLOBAL_STRING: JSON.stringify('i am global var from vite.config.js define'), - GLOBAL_VAR: { test: 'i am global var from vite.config.js define' } + GLOBAL_VAR: { test: 'i am global var from vite.config.js define' }, + 'import.meta.env.PROJECT_VERSION': JSON.stringify(packageJson.version) }, clearScreen: false, //设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息 server: {