From 042c1e54ed4f8e0d03e8cd7996adfec125ab152e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=8C=E7=B3=96=E5=8C=85=E5=AD=90?= Date: Tue, 28 Apr 2026 16:49:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAVITE=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 4 ++-- src/utils/http.ts | 2 +- src/views/api/Music.vue | 2 +- src/views/api/PhotoWall.vue | 2 +- src/views/api/SourceImage.vue | 2 +- src/vite-env.d.ts | 4 ++-- vite.config.ts | 8 +++----- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.env b/.env index 976c659..85f71b3 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -VUE_APP_PROXY_TARGET=https://www.colorfulsweet.site -VUE_APP_API_BASE=/api/v2 +VITE_APP_PROXY_TARGET=https://www.colorfulsweet.site +VITE_APP_API_BASE=/api/v2 diff --git a/src/utils/http.ts b/src/utils/http.ts index 90f6f5e..448b1f0 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -4,7 +4,7 @@ import store from '@/store' import { router } from '@/router' const http = axios.create({ - baseURL: import.meta.env.VUE_APP_API_BASE, + baseURL: import.meta.env.VITE_APP_API_BASE, timeout: 10000, paramsSerializer: { indexes: null diff --git a/src/views/api/Music.vue b/src/views/api/Music.vue index 661d615..4e2b211 100644 --- a/src/views/api/Music.vue +++ b/src/views/api/Music.vue @@ -210,7 +210,7 @@ class MusicPage extends Page { } const store = useStore() -const apiBase = import.meta.env.VUE_APP_API_BASE +const apiBase = import.meta.env.VITE_APP_API_BASE const { loading, modalLoading, total, search, setLoadData, loadDataBase, reset, pageChange, pageSizeChange } = useBaseList(new MusicPage()) const currentRow = ref(null) const libIdSelected = ref(null) diff --git a/src/views/api/PhotoWall.vue b/src/views/api/PhotoWall.vue index 45329d8..d523d5c 100644 --- a/src/views/api/PhotoWall.vue +++ b/src/views/api/PhotoWall.vue @@ -105,7 +105,7 @@ class PhotoWallPage extends Page { } const store = useStore() -const apiBase = import.meta.env.VUE_APP_API_BASE +const apiBase = import.meta.env.VITE_APP_API_BASE const { loading, total, search, setLoadData, loadDataBase, reset, pageChange, pageSizeChange } = useBaseList(new PhotoWallPage()) const allowUploadExt = ['jpg', 'jpeg', 'png'] diff --git a/src/views/api/SourceImage.vue b/src/views/api/SourceImage.vue index 9a24a9d..bd21135 100644 --- a/src/views/api/SourceImage.vue +++ b/src/views/api/SourceImage.vue @@ -87,7 +87,7 @@ import { SourceImageModel } from '@/model/api/source-image' import http from '@/utils/http' const store = useStore() -const apiBase = import.meta.env.VUE_APP_API_BASE +const apiBase = import.meta.env.VITE_APP_API_BASE const { loading, total, search, setLoadData, pageChange, pageSizeChange, datetimeFormat } = useBaseList(new Page()) const allowUploadExt = ['jpg', 'jpeg', 'png', 'svg', 'ico'] diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 70e58e5..3a40914 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1,8 +1,8 @@ /// interface ImportMetaEnv { - readonly VUE_APP_API_BASE: string - readonly VUE_APP_PROXY_TARGET?: string + readonly VITE_APP_API_BASE: string + readonly VITE_APP_PROXY_TARGET?: string } interface ImportMeta { diff --git a/vite.config.ts b/vite.config.ts index b828301..d7ec4f6 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -18,11 +18,9 @@ function resolveCommitInfo() { export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') - const proxyTarget = env.VUE_APP_PROXY_TARGET || env.VITE_APP_PROXY_TARGET return { base: './', - envPrefix: ['VITE_', 'VUE_APP_'], plugins: [ vue(), AutoImport({ @@ -44,12 +42,12 @@ export default defineConfig(({ mode }) => { }, server: { port: 8080, - proxy: proxyTarget ? { + proxy: { '/api': { - target: proxyTarget, + target: env.VITE_APP_PROXY_TARGET, changeOrigin: true } - } : undefined + } }, build: { sourcemap: false,