From dc7e3d68208df152e3395e70aabd711829408c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B4=9B=E5=B8=8C=E9=9B=85?= Date: Fri, 26 Apr 2024 22:33:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=8A=A0=E4=B8=AAVITE=5F=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login/index.vue | 6 ++--- typings/env.d.ts | 53 +++------------------------------------ vite.config.ts | 5 +--- 3 files changed, 7 insertions(+), 57 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 2071665..838c9a6 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -60,12 +60,12 @@ import { ElMessage } from 'element-plus' import moment from 'moment' const buildEnv = (() => { - let time = import.meta.env.TAG_TIMESTAMP + let time = import.meta.env.VITE_TAG_TIMESTAMP if (!time) return null const date = new Date(Number.parseInt(time)) time = `${moment(date).format('YYYY-mm-dd HH:mm:ss')} GMT+8` - const build = import.meta.env.BUILD_DISPLAY_NAME - const hash = (import.meta.env.GIT_COMMIT || '').slice(0, 8) + const build = import.meta.env.VITE_BUILD_DISPLAY_NAME + const hash = (import.meta.env.VITE_GIT_COMMIT || '').slice(0, 8) return `构建 ${build} ${hash} ${time}` })() diff --git a/typings/env.d.ts b/typings/env.d.ts index 2e500c2..f3c7450 100644 --- a/typings/env.d.ts +++ b/typings/env.d.ts @@ -4,56 +4,9 @@ declare global { readonly VITE_APP_BASE_URL: string readonly VITE_APP_BASE_PORT: number readonly VITE_APP_ENV: 'prod' | 'test' | 'dev' - - // Jenkins 的环境变量 - // readonly BRANCH_NAME: string - // readonly BRANCH_IS_PRIMARY: string - // readonly CHANGE_ID: string - // readonly CHANGE_URL: string - // readonly CHANGE_TITLE: string - // readonly CHANGE_AUTHOR: string// - // readonly CHANGE_AUTHOR_DISPLAY_NAME: string - // readonly CHANGE_AUTHOR_EMAIL: string - // readonly CHANGE_TARGET: string - // readonly CHANGE_BRANCH: string - // readonly CHANGE_FORK: string - // readonly TAG_NAME: string - readonly TAG_TIMESTAMP: string - // readonly TAG_UNIXTIME: string - // readonly TAG_DATE: string - // readonly JOB_DISPLAY_URL: string - // readonly RUN_DISPLAY_URL: string - // readonly RUN_ARTIFACTS_DISPLAY_URL: string - // readonly RUN_CHANGES_DISPLAY_URL: string - // readonly RUN_TESTS_DISPLAY_URL: string - // readonly CI: string; - // readonly BUILD_NUMBER: string - // readonly BUILD_ID: string - readonly BUILD_DISPLAY_NAME: string - // readonly JOB_NAME: string - // readonly JOB_BASE_NAME: string - // readonly BUILD_TAG: string - // readonly EXECUTOR_NUMBER: string - // readonly NODE_NAME: string - // readonly NODE_LABELS: string - // readonly WORKSPACE: string - // readonly WORKSPACE_TMP: string - // readonly JENKINS_HOME: string - // readonly JENKINS_URL: string - // readonly BUILD_URL: string - // readonly JOB_URL: string - readonly GIT_COMMIT: string - // readonly GIT_PREVIOUS_COMMIT: string - // readonly GIT_PREVIOUS_SUCCESSFUL_COMMIT: string - // readonly GIT_BRANCH: string - // readonly GIT_LOCAL_BRANCH: string - // readonly GIT_CHECKOUT_DIR: string - // readonly GIT_URL: string - // readonly GIT_COMMITTER_NAME: string - // readonly GIT_AUTHOR_NAME: string - // readonly GIT_COMMITTER_EMAIL: string - // readonly GIT_AUTHOR_EMAIL: string - + readonly VITE_TAG_TIMESTAMP: string + readonly VITE_BUILD_DISPLAY_NAME: string + readonly VITE_GIT_COMMIT: string // 更多环境变量... } interface ImportMeta { diff --git a/vite.config.ts b/vite.config.ts index 689a2da..e4f6722 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,10 +23,7 @@ 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' }, - 'import.meta.env.TAG_TIMESTAMP': JSON.stringify(process.env.TAG_TIMESTAMP), - 'import.meta.env.BUILD_DISPLAY_NAME': JSON.stringify(process.env.BUILD_DISPLAY_NAME), - 'import.meta.env.GIT_COMMIT': JSON.stringify(process.env.GIT_COMMIT) + GLOBAL_VAR: { test: 'i am global var from vite.config.js define' } }, clearScreen: false, //设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息 server: {