diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue index 9acc406..ef1354e 100644 --- a/src/layout/components/Sidebar/index.vue +++ b/src/layout/components/Sidebar/index.vue @@ -21,6 +21,10 @@ /> + @@ -32,6 +36,21 @@ import useAppStore from '@/store/modules/app' import useSettingsStore from '@/store/modules/settings' import usePermissionStore from '@/store/modules/permission' +const buildTime = __BUILD_TIME__ +const commitId = __COMMIT_ID__ +const formatTime = (time) => { + return new Intl.DateTimeFormat('zh-CN', { + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + hour12: false, + timeZone: 'Asia/Shanghai' + }).format(new Date(time)) +} + + const route = useRoute() const appStore = useAppStore() const settingsStore = useSettingsStore() @@ -101,4 +120,22 @@ const activeMenu = computed(() => { } } } +.sidebar-container { + display: flex; + flex-direction: column; + height: 100%; +} + +.menu-wrapper { + flex: 1; +} + +.sidebar-version { + padding: 10px; + font-size: 12px; + color: #999; + text-align: left; + border-top: 1px solid #eee; +} + diff --git a/vite.config.js b/vite.config.js index 63c2628..81769ba 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,13 +1,27 @@ import path from 'path' import { defineConfig, loadEnv } from 'vite' import createVitePlugins from './vite/plugins' - +import { execSync } from 'node:child_process' const baseUrl = 'http://127.0.0.1:8080' // 后端接口 // https://vitejs.dev/config/ export default defineConfig(({ mode, command }) => { const env = loadEnv(mode, process.cwd()) const { VITE_APP_ENV } = env + + + let commitId = 'unknown' + + try { + commitId = execSync('git rev-parse --short HEAD') + .toString() + .trim() + } catch (e) { + console.log('git commit not found') + } + + const buildTime = new Date().toISOString() + return { // 部署生产环境和开发环境下的URL。 // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上 @@ -75,6 +89,10 @@ export default defineConfig(({ mode, command }) => { } ] } - } + }, + define: { + __BUILD_TIME__: JSON.stringify(buildTime), + __COMMIT_ID__: JSON.stringify(commitId) + }, } })