|
@@ -7,19 +7,24 @@ type Params = {
|
|
|
code: number;
|
|
|
message: string;
|
|
|
handler: () => void;
|
|
|
+ errorHandler?: () => void;
|
|
|
};
|
|
|
|
|
|
export function useResponseHandle() {
|
|
|
const { logout } = useNav();
|
|
|
|
|
|
- function responseHandle({ code, message, handler }: Params) {
|
|
|
+ function responseHandle({ code, message, handler, errorHandler }: Params) {
|
|
|
const c = Number(code);
|
|
|
if (c === 0) {
|
|
|
handler();
|
|
|
} else if (c >= 100 && c <= 140) {
|
|
|
logout();
|
|
|
} else {
|
|
|
- ElMessage.error(message);
|
|
|
+ if (errorHandler) {
|
|
|
+ errorHandler();
|
|
|
+ } else {
|
|
|
+ ElMessage.error(message);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|