diff --git a/new-ui/projects/admin/env.d.ts b/new-ui/projects/admin/env.d.ts index 0f8e5fd5..941fc709 100644 --- a/new-ui/projects/admin/env.d.ts +++ b/new-ui/projects/admin/env.d.ts @@ -5,13 +5,5 @@ declare module "*.vue" { const component: DefineComponent<{}, {}, any>; export default component; } -import 'vue-router' -declare module 'vue-router' { - interface RouteMeta { - title?: string - icon?: any - permission?: boolean | string | string[] - } -} -declare const __AUTH_KEY: string; \ No newline at end of file +declare const __AUTH_KEY: string; diff --git a/new-ui/projects/admin/src/http/config.ts b/new-ui/projects/admin/src/http/config.ts index 14ddc588..2437420d 100644 --- a/new-ui/projects/admin/src/http/config.ts +++ b/new-ui/projects/admin/src/http/config.ts @@ -17,10 +17,17 @@ instance.interceptors.request.use((config) => { instance.interceptors.response.use( (response) => { const { data }: { data: BaseResponse } = response - if (data && typeof data === "object" && data.code !== 0) { - if (data.code === 400) { - localStorage.removeItem(__AUTH_KEY); - router.push({ name: "Login" }) + if (data && typeof data === "object" && data.code > 0) { + switch (data.code) { + case 400: { + localStorage.removeItem(__AUTH_KEY); + router.push({ name: "Login" }) + break; + } + case 403: { + router.replace({ name: "403" }) + break; + } } Notification.error(data.message ?? '未知错误') } diff --git a/new-ui/projects/admin/src/router/type.d.ts b/new-ui/projects/admin/src/router/type.d.ts new file mode 100644 index 00000000..e1bf1fc7 --- /dev/null +++ b/new-ui/projects/admin/src/router/type.d.ts @@ -0,0 +1,8 @@ +import 'vue-router' +declare module 'vue-router' { + interface RouteMeta { + title?: string + icon?: any + permission?: boolean | string | string[] + } +} \ No newline at end of file