Skip to content

Commit 52cda75

Browse files
committed
参数传递
1 parent 6917d5d commit 52cda75

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/store/modules/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
mutations: {},
88
actions: {
99
async getAllUserApi() {
10-
const [err, result] = await errorCaptured(UserService.getAllUser)();
10+
const [err, result] = await errorCaptured(UserService.getAllUser, true)();
1111
return result;
1212
},
1313
},

src/utils/error-captured.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import { axiosResult } from './axios-result';
44
* 错误捕获的方法
55
* @param func
66
*/
7-
export const errorCaptured = (func: () => void): any => {
7+
export const errorCaptured = (
8+
func: () => void,
9+
isObj: boolean = false,
10+
): any => {
811
return new Proxy(func, {
912
async apply(target, thisBinding, args) {
1013
try {
1114
const res: any = await target.apply(thisBinding, args);
1215
const { code, message, result } = res;
13-
return [null, axiosResult(result, code, message, true)];
16+
return [null, axiosResult(result, code, message, isObj)];
1417
} catch (e) {
1518
return [e, Promise.resolve('')];
1619
}

0 commit comments

Comments
 (0)