Skip to content

Commit b721e07

Browse files
committed
feat(platform): add fn to handle http response
1 parent ee1d2e6 commit b721e07

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { ToastService } from './toast-service';
2+
3+
export function handleActionResponse(res: any, cb?: { success?: () => void; error?: () => void }) {
4+
if (res.success) {
5+
ToastService.open({
6+
children: '操作成功',
7+
dType: 'success',
8+
});
9+
cb?.success?.();
10+
} else {
11+
ToastService.open({
12+
children: res.message,
13+
dType: 'error',
14+
});
15+
cb?.error?.();
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { base64url } from './base64url';
2+
export { handleActionResponse } from './handleResponse';
23
export { NotificationService } from './notification-service';
34
export { ToastService } from './toast-service';

0 commit comments

Comments
 (0)