fix: 优化

This commit is contained in:
admin 2024-09-09 14:32:01 +08:00
parent 1e6f8f2b3f
commit 6e9d903a29
5 changed files with 22 additions and 14 deletions

View File

@ -1,5 +1,5 @@
{
"name": "在生万有货场ERP后台",
"name": "在生万有抖音后台",
"version": "1.0.0",
"private": true,
"type": "module",

View File

@ -17,7 +17,7 @@ class AuthAPI {
/** 注销 接口*/
static logout() {
return request({
url: `/api/user/logOut`,
url: `/api/admin/logOut`,
method: "POST",
});
}

View File

@ -71,8 +71,8 @@
:src="userStore.user.avatar + '?imageView2/1/w/80/h/80'"
class="rounded-full mr-10px w24px w24px"
/> -->
<!-- {{ userStore.user.userInfo.name }} -->
<span>admin</span>
<!-- -->
<span>{{ userStore.user.userInfo.name }}</span>
</div>
<template #dropdown>
<el-dropdown-menu>

View File

@ -15,7 +15,7 @@ export function setupPermission() {
router.beforeEach(async (to, from, next) => {
NProgress.start();
const hasToken = localStorage.getItem(TOKEN_KEY);
if (true) {
if (hasToken) {
if (to.path === "/login") {
// 如果已登录,跳转到首页
next({ path: "/" });
@ -51,6 +51,14 @@ export function setupPermission() {
// }
}
} else {
// 未登录
if (whiteList.includes(to.path)) {
next(); // 在白名单,直接进入
} else {
// 不在白名单,重定向到登录页
redirectToLogin(to, next);
NProgress.done();
}
}
});

View File

@ -211,15 +211,15 @@ function handleLoginSubmit() {
if (valid) {
router.push({ path: "/" });
loading.value = true;
// userStore
// .login(loginData.value)
// .then(() => {
// router.push({ path: "/" });
// })
// .catch(() => {})
// .finally(() => {
// loading.value = false;
// });
userStore
.login(loginData.value)
.then(() => {
router.push({ path: "/" });
})
.catch(() => {})
.finally(() => {
loading.value = false;
});
}
});
}