Skip to content

Commit

Permalink
feat: 🚀 升级element-plus到2.25
Browse files Browse the repository at this point in the history
解决按钮样式在qq浏览器或360浏览器样式失效问题
  • Loading branch information
Halsey committed Jun 9, 2022
1 parent 9eedfd6 commit e98c035
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 164 deletions.
216 changes: 59 additions & 157 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"axios": "^0.27.2",
"echarts": "^5.3.0",
"echarts-liquidfill": "^3.1.0",
"element-plus": "^2.2.2",
"element-plus": "^2.2.5",
"js-md5": "^0.7.3",
"nprogress": "^0.2.0",
"pinia": "^2.0.12",
Expand Down
9 changes: 4 additions & 5 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ class RequestHttp {
*/
this.service.interceptors.request.use(
(config: AxiosRequestConfig) => {
console.log(config);
// * 将当前请求添加到 pending 中
axiosCanceler.addPending(config);
// * 如果当前请求不需要显示 loading(在headers中指定 notLoading:true)
config.headers!.notLoading || showFullScreenLoading();
// * 如果当前请求不需要显示 loading,在api服务中通过指定的第三个参数: { headers: { noLoading: true } }来控制不显示loading,参见loginApi
config.headers!.noLoading || showFullScreenLoading();
const token: string = globalStore.token;
return { ...config, headers: { "x-access-token": token } };
},
Expand All @@ -57,7 +56,7 @@ class RequestHttp {
const { data, config } = response;
// * 在请求结束后,移除本次请求
axiosCanceler.removePending(config);
tryHideFullScreenLoading();
config.headers!.noLoading || tryHideFullScreenLoading();
// * 登陆失效(code == 599)
if (data.code == ResultEnum.OVERDUE) {
ElMessage.error(data.msg);
Expand All @@ -77,7 +76,7 @@ class RequestHttp {
},
async (error: AxiosError) => {
const { response } = error;
tryHideFullScreenLoading();
config.headers!.noLoading || tryHideFullScreenLoading();
// 根据响应的错误状态码,做不同的处理
if (response) return checkStatus(response.status);
// 服务器结果都没有返回(可能服务器错误可能客户端断网),断网处理:可以跳转到断网页面
Expand Down
2 changes: 1 addition & 1 deletion src/api/modules/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import http from "@/api";
*/
// * 用户登录接口
export const loginApi = (params: Login.ReqLoginForm) => {
// return http.post<Login.ResLogin>(PORT1 + `/login`, params, { headers: { notLoading: true } });
// return http.post<Login.ResLogin>(PORT1 + `/login`, params, { headers: { noLoading: true } });
return http.post<Login.ResLogin>(PORT1 + `/login`, params);
};

Expand Down

0 comments on commit e98c035

Please sign in to comment.