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", "version": "1.0.0",
"private": true, "private": true,
"type": "module", "type": "module",

View File

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

View File

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

View File

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

View File

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