diff --git a/build/config/index.ts b/build/config/index.ts index 9bcd86890..8a9621a68 100644 --- a/build/config/index.ts +++ b/build/config/index.ts @@ -1 +1,2 @@ export * from './proxy'; +export * from './time'; diff --git a/build/config/time.ts b/build/config/time.ts new file mode 100644 index 000000000..3b5714605 --- /dev/null +++ b/build/config/time.ts @@ -0,0 +1,12 @@ +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; + +export function getBuildTime() { + dayjs.extend(utc); + dayjs.extend(timezone); + + const buildTime = dayjs.tz(Date.now(), 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss'); + + return buildTime; +} diff --git a/vite.config.ts b/vite.config.ts index c3ea6d064..218d28c91 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,14 +1,13 @@ import process from 'node:process'; import { URL, fileURLToPath } from 'node:url'; import { defineConfig, loadEnv } from 'vite'; -import dayjs from 'dayjs'; import { setupVitePlugins } from './build/plugins'; -import { createViteProxy } from './build/config'; +import { createViteProxy, getBuildTime } from './build/config'; export default defineConfig(configEnv => { const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta; - const buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss'); + const buildTime = getBuildTime(); return { base: viteEnv.VITE_BASE_URL,