feat:更新白板
This commit is contained in:
@@ -11,10 +11,27 @@ import router from '@/router';
|
||||
import { useMeterStore } from '@/stores/modules/meter.js'
|
||||
|
||||
axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
|
||||
|
||||
// 动态获取 baseURL
|
||||
const getBaseURL = () => {
|
||||
// 开发环境使用配置的完整 URL
|
||||
if (import.meta.env.DEV) {
|
||||
return import.meta.env.VITE_APP_BASE_API;
|
||||
}
|
||||
|
||||
// 生产环境使用相对路径
|
||||
// 返回空字符串,让浏览器自动使用当前域名
|
||||
return '';
|
||||
|
||||
// 或者如果后端 API 有固定路径前缀,可以这样设置:
|
||||
// return '/api'; // 这样请求会变成 https://当前域名/api/xxx
|
||||
};
|
||||
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
// baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
baseURL: getBaseURL(),
|
||||
// 超时
|
||||
// timeout: 10000,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user