diff --git a/.env.dev b/.env.dev index 33f9ccb..f057532 100644 --- a/.env.dev +++ b/.env.dev @@ -2,5 +2,5 @@ NODE_ENV=development # api -VITE_API_BASIC='http://10.10.1.27:8888' +VITE_API_BASIC="http://10.10.1.27:8888" diff --git a/package.json b/package.json index fae805e..409fb11 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite ", + "dev": "vite --mode dev", "build": "vue-tsc && vite build", "preview": "vite preview" }, diff --git a/src/utils/index.ts b/src/utils/index.ts index 38eeefa..561570a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -2,8 +2,8 @@ import axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios'; // 从环境变量读取基础 URL -const BASE_URL = import.meta.env.MODE === 'development'?'http://10.10.1.27:8888':'http://10.10.1.27:8888'; -console.log('API Basic URL:', BASE_URL); +const BASE_URL = import.meta.env.VITE_API_BASIC +console.log('API Basic URL:',import.meta.env.VITE_API_BASIC); console.log('All env:', import.meta.env); // 创建 axios 实例 const request: AxiosInstance = axios.create({