添加一些显示的构建信息

This commit is contained in:
洛洛希雅 2024-04-26 21:55:28 +08:00
parent 291dbff80d
commit 183a174bb1
4 changed files with 69 additions and 1 deletions

View File

@ -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",

View File

@ -39,6 +39,10 @@
<div class="icp">
鲁ICP备
<s>1145141919-810</s>
<template v-if="buildEnv">
<br />
{{ buildEnv }}
</template>
</div>
<div class="copyright">© 2024 洛洛希雅Lolosia</div>
</div>
@ -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()

50
typings/env.d.ts vendored
View File

@ -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 {

View File

@ -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 可以禁用开发服务器错误的屏蔽。方便错误查看