chore: 同步完整版代码

This commit is contained in:
xiaoxian521
2022-10-26 11:25:45 +08:00
parent f14077bc6f
commit 936070c9ce
4 changed files with 55 additions and 40 deletions

View File

@@ -270,9 +270,9 @@ function addAsyncRoutes(arrRoutes: Array<RouteRecordRaw>) {
// 父级的redirect属性取值如果子级存在且父级的redirect属性不存在默认取第一个子级的path如果子级存在且父级的redirect属性存在取存在的redirect属性会覆盖默认值
if (v?.children && v.children.length && !v.redirect)
v.redirect = v.children[0].path;
// 父级的name属性取值如果子级存在且父级的name属性不存在默认取第一个子级的name如果子级存在且父级的name属性存在取存在的name属性会覆盖默认值
// 父级的name属性取值如果子级存在且父级的name属性不存在默认取第一个子级的name如果子级存在且父级的name属性存在取存在的name属性会覆盖默认值注意测试中发现父级的name不能和子级name重复如果重复会造成重定向无效跳转404所以这里给父级的name起名的时候后面会自动加上`Parent`,避免重复)
if (v?.children && v.children.length && !v.name)
v.name = v.children[0].name;
v.name = (v.children[0].name as string) + "Parent";
if (v.meta?.frameSrc) {
v.component = IFrame;
} else {

View File

@@ -1,11 +1,15 @@
import Axios, { AxiosInstance, AxiosRequestConfig } from "axios";
import Axios, {
AxiosInstance,
AxiosRequestConfig,
CustomParamsSerializer
} from "axios";
import {
PureHttpError,
RequestMethods,
PureHttpResponse,
PureHttpRequestConfig
} from "./types.d";
import qs from "qs";
import { stringify } from "qs";
import NProgress from "../progress";
// import { loadEnv } from "@build/index";
import { getToken } from "/@/utils/auth";
@@ -20,7 +24,7 @@ const defaultConfig: AxiosRequestConfig = {
// process.env.NODE_ENV === "production"
// ? VITE_PROXY_DOMAIN_REAL
// : VITE_PROXY_DOMAIN,
// 当前使用mock模拟请求将baseURL制空如果你的环境用到了http请求请删除下面的baseURL启用上面的baseURL并将第10行、15行代码注释取消
// 当前使用mock模拟请求将baseURL制空如果你的环境用到了http请求请删除下面的baseURL启用上面的baseURL并将第14行、19行代码注释取消
baseURL: "",
timeout: 10000,
headers: {
@@ -28,8 +32,10 @@ const defaultConfig: AxiosRequestConfig = {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
// 数组格式参数序列化
paramsSerializer: params => qs.stringify(params, { indices: false })
// 数组格式参数序列化https://github.com/axios/axios/issues/5142
paramsSerializer: {
serialize: stringify as unknown as CustomParamsSerializer
}
};
class PureHttp {