Skip to content

Commit

Permalink
feat: 加上请求成功提示
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Sep 22, 2022
1 parent fe8c558 commit 683c69a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ service.interceptors.response.use(
);

type RequestOptions<R, P extends unknown[]> = {
needAll?: boolean; // 需要所有的
needAll?: boolean; // 需要所有的格式,而不仅仅是data
noLoading?: boolean; // 不需要加载特效
noError?: boolean; // 不需要错误提示
success?: boolean; //成功后提示
} & Options<R, P>;

setGlobalOptions({
Expand Down Expand Up @@ -89,7 +90,9 @@ function request<R, P extends unknown[] = [], T = true>(
if (res.code !== '200') {
throw Error(res.msg);
}

if (options?.success) {
ElMessage.success({ message: res.msg });
}
!options?.noLoading && closeLoading();
return options?.needAll ? res : res.data;
} catch (e) {
Expand Down

0 comments on commit 683c69a

Please sign in to comment.