From 77c962ea91de68299a01680a7941cf7a73c7e4a7 Mon Sep 17 00:00:00 2001 From: kailong321200875 <321200875@qq.com> Date: Thu, 30 Nov 2023 16:08:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EuserStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login/types.ts | 1 - src/axios/config.ts | 11 +-- src/components/UserInfo/src/UserInfo.vue | 36 +++------- src/constants/index.ts | 10 +++ src/permission.ts | 14 ++-- src/router/index.ts | 4 +- src/store/modules/app.ts | 5 -- src/store/modules/permission.ts | 4 +- src/store/modules/tagsView.ts | 9 +-- src/store/modules/user.ts | 85 ++++++++++++++++++++++++ src/views/Login/components/LoginForm.vue | 10 +-- 11 files changed, 125 insertions(+), 64 deletions(-) create mode 100644 src/store/modules/user.ts diff --git a/src/api/login/types.ts b/src/api/login/types.ts index 860808e..31bb526 100644 --- a/src/api/login/types.ts +++ b/src/api/login/types.ts @@ -8,5 +8,4 @@ export interface UserType { password: string role: string roleId: string - permissions: string | string[] } diff --git a/src/axios/config.ts b/src/axios/config.ts index 92def84..d1c0a77 100644 --- a/src/axios/config.ts +++ b/src/axios/config.ts @@ -1,12 +1,8 @@ import { AxiosResponse, AxiosRequestHeaders, InternalAxiosRequestConfig } from './types' import { ElMessage } from 'element-plus' import qs from 'qs' -import router from '@/router' import { SUCCESS_CODE } from '@/constants' - -import { useStorage } from '@/hooks/web/useStorage' - -const { clear } = useStorage() +import { useUserStoreWithOut } from '@/store/modules/user' const defaultRequestInterceptors = (config: InternalAxiosRequestConfig) => { if ( @@ -40,9 +36,8 @@ const defaultResponseInterceptors = (response: AxiosResponse) => { } else { ElMessage.error(response?.data?.message) if (response?.data?.code === 401) { - // token过期 - clear() - router.push('/login') + const userStore = useUserStoreWithOut() + userStore.logout() } } } diff --git a/src/components/UserInfo/src/UserInfo.vue b/src/components/UserInfo/src/UserInfo.vue index 095000e..eba341f 100644 --- a/src/components/UserInfo/src/UserInfo.vue +++ b/src/components/UserInfo/src/UserInfo.vue @@ -1,49 +1,27 @@