diff --git a/package.json b/package.json
index 011f50e..4e25379 100644
--- a/package.json
+++ b/package.json
@@ -33,6 +33,7 @@
"hash.js": "^1.1.7",
"js-error-collection": "^1.0.8",
"mitt": "3.0.1",
+ "moment": "^2.30.1",
"moment-mini": "2.29.4",
"mqtt": "^5.5.0",
"nprogress": "0.2.0",
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 7316d19..5e915ef 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -39,6 +39,10 @@
鲁ICP备
1145141919号-810
+
+
+ {{ buildEnv }}
+
© 2024 洛洛希雅Lolosia
@@ -53,6 +57,17 @@ import { getMyRole, login } from '@/api/user'
import type { FormInstance, InputInstance } from 'element-plus'
import { settings as viteSettings } from '@/settings'
import { ElMessage } from 'element-plus'
+import moment from 'moment'
+
+const buildEnv = (() => {
+ let time = import.meta.env.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
+ return `构建 ${build} ${hash} ${time}`
+})()
/* listen router change and set the query */
const { settings } = useBasicStore()
diff --git a/typings/env.d.ts b/typings/env.d.ts
index c4ecbaa..00a3467 100644
--- a/typings/env.d.ts
+++ b/typings/env.d.ts
@@ -4,6 +4,56 @@ 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
+
// 更多环境变量...
}
interface ImportMeta {
diff --git a/vite.config.ts b/vite.config.ts
index 47b7f67..454dc0f 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -11,7 +11,7 @@ import mkcert from 'vite-plugin-mkcert'
import AutoImport from 'unplugin-auto-import/vite'
import setting from './src/settings'
import ReactivityTransform from '@vue-macros/reactivity-transform/vite'
-const prodMock = setting.openProdMock
+// const prodMock = setting.openProdMock
import vitePluginSetupExtend from './src/plugins/vite-plugin-setup-extend'
import vitePluginVueSetupExtend from 'vite-plugin-vue-setup-extend'
// import { visualizer } from 'rollup-plugin-visualizer'
@@ -25,6 +25,8 @@ export default defineConfig(({ command, mode }: ConfigEnv): UserConfig => {
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' }
},
+ // Vite 和 Jenkins 的环境变量
+ envPrefix: ['VITE_', 'TAG_', 'BUILD_', 'BRANCH_', 'CHANGE_', 'JOB_', 'RUN_', 'GIT_'],
clearScreen: false, //设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息
server: {
//hmr: { overlay: false }, //设置 server.hmr.overlay 为 false 可以禁用开发服务器错误的屏蔽。方便错误查看