refactor: 代码重构优化(VueUse使用)

Former-commit-id: f33b8d352dd9e9b2a706c94cdd7afa150ac12931
This commit is contained in:
haoxr
2023-03-01 00:47:39 +08:00
parent 1e6e202ce6
commit 599624e944
16 changed files with 164 additions and 194 deletions

View File

@@ -1,5 +1,4 @@
import router from '@/router';
import { getToken } from '@/utils/auth';
import { useUserStoreHook } from '@/store/modules/user';
import { usePermissionStoreHook } from '@/store/modules/permission';
@@ -14,11 +13,10 @@ const whiteList = ['/login'];
router.beforeEach(async (to, from, next) => {
NProgress.start();
const hasToken = getToken();
const hasToken = localStorage.getItem('accessToken');
if (hasToken) {
if (to.path === '/login') {
//
// 登录成功,跳转到首页
next({ path: '/' });
} else {
const userStore = useUserStoreHook();