bill 1 hónapja
szülő
commit
e3bb32d108
4 módosított fájl, 7 hozzáadás és 4 törlés
  1. 1 1
      src/example/fuse/main.ts
  2. 4 2
      src/global.d.ts
  3. 1 1
      src/index.ts
  4. 1 0
      vite.config.ts

+ 1 - 1
src/example/fuse/main.ts

@@ -13,7 +13,7 @@ app.component('Icon', Icon)
 app.use(router)
 app.mount('#app')
 
-console.log('当前版本', window.__VERSION__)
+console.log('当前版本', __VERSION__)
 
 console.log(import.meta.env)
 if (import.meta.env.VITE_ICO) {

+ 4 - 2
src/global.d.ts

@@ -1,7 +1,9 @@
 declare global {  
+  // 声明为全局常量(TypeScript 只用于类型检查,运行时不会自动在 window 上创建)
+  const __VERSION__: string;
+  const __BUILD_TIME__: string;
+
   interface Window {  
-    __VERSION__: string
-    __BUILD_TIME__: string
     platform: any
   }  
 }  

+ 1 - 1
src/index.ts

@@ -13,4 +13,4 @@ for (const key in components) {
 export type { DrawItem, DrawData } from './core/components'
 
 export type { DrawExpose } from './core/hook/use-expose.ts'
-console.log('build time =', window.__BUILD_TIME__)
+console.log('build time =', __BUILD_TIME__)

+ 1 - 0
vite.config.ts

@@ -29,6 +29,7 @@ function getChinaTimeISO() {
 export default ({ mode }: any) => {
   const env = loadEnv(mode, envDir);
   const buildTime = getChinaTimeISO();
+  console.log('current', buildTime)
 
   let proxy: any = {};
   if (env.VITE_MOCK_ENV) {