This commit is contained in:
六如
2024-11-25 00:18:47 +08:00
parent ba384660f1
commit 5e2c3fab46
37 changed files with 939 additions and 86 deletions

View File

@@ -14,6 +14,24 @@ import NProgress from "../progress";
import { getToken, formatToken } from "@/utils/auth";
import { useUserStoreHook } from "@/store/modules/user";
export const baseUrl = (url: string) => {
if (!url) {
throw new Error("url不能为空");
}
if (url.startsWith("/")) {
url = url.substring(1);
}
return `/api/${url}`;
};
export const createUrl = (data: object) => {
const ret = {};
for (const dataKey in data) {
ret[dataKey] = baseUrl(data[dataKey]);
}
return ret;
};
// 相关配置请参考www.axios-js.com/zh-cn/docs/#axios-request-config-1
const defaultConfig: AxiosRequestConfig = {
// 请求超时时间