配置开发/生产环境

This commit is contained in:
wzy-warehouse
2026-04-07 21:22:31 +08:00
parent af7e1f3340
commit 78a477be3c
4 changed files with 65 additions and 0 deletions
+3
View File
@@ -1,2 +1,5 @@
NEW_FILE_CODE NEW_FILE_CODE
VITE_BACKEND_BASE_URL=http://localhost:8081 VITE_BACKEND_BASE_URL=http://localhost:8081
START_PORT=80
+2
View File
@@ -1,2 +1,4 @@
NEW_FILE_CODE NEW_FILE_CODE
VITE_BACKEND_BASE_URL=http://localhost:8080 VITE_BACKEND_BASE_URL=http://localhost:8080
START_PORT=81
Vendored
+59
View File
@@ -0,0 +1,59 @@
NEW_FILE_CODE
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
// 声明环境变量类型
interface ImportMetaEnv {
readonly VITE_BACKEND_BASE_URL: string
readonly START_PORT: number
readonly MODE: string
readonly DEV: boolean
readonly PROD: boolean
readonly SSR: boolean
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
// 声明 CSS 模块类型
declare module '*.css' {
const content: Record<string, string>
export default content
}
// 声明静态资源类型
declare module '*.svg' {
const content: string
export default content
}
declare module '*.png' {
const content: string
export default content
}
declare module '*.jpg' {
const content: string
export default content
}
declare module '*.jpeg' {
const content: string
export default content
}
declare module '*.gif' {
const content: string
export default content
}
declare module '*.webp' {
const content: string
export default content
}
+1
View File
@@ -31,6 +31,7 @@ export default defineConfig(({ mode }) => {
}, },
}, },
server: { server: {
port: Number(env.START_PORT),
proxy: { proxy: {
'/api': { '/api': {
target: backendBaseUrl, target: backendBaseUrl,