diff --git a/package.json b/package.json
index c79d7eb..7010ae8 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "在生万有货场ERP后台",
+ "name": "在生万有抖音后台",
"version": "1.0.0",
"private": true,
"type": "module",
diff --git a/src/api/auth.ts b/src/api/auth.ts
index 1828ef3..7c53ac5 100644
--- a/src/api/auth.ts
+++ b/src/api/auth.ts
@@ -17,7 +17,7 @@ class AuthAPI {
/** 注销 接口*/
static logout() {
return request({
- url: `/api/user/logOut`,
+ url: `/api/admin/logOut`,
method: "POST",
});
}
diff --git a/src/layout/components/NavBar/components/NavbarAction.vue b/src/layout/components/NavBar/components/NavbarAction.vue
index 0e25572..66601dc 100644
--- a/src/layout/components/NavBar/components/NavbarAction.vue
+++ b/src/layout/components/NavBar/components/NavbarAction.vue
@@ -71,8 +71,8 @@
:src="userStore.user.avatar + '?imageView2/1/w/80/h/80'"
class="rounded-full mr-10px w24px w24px"
/> -->
-
- admin
+
+ {{ userStore.user.userInfo.name }}
diff --git a/src/plugins/permission.ts b/src/plugins/permission.ts
index f2c4242..d188d82 100644
--- a/src/plugins/permission.ts
+++ b/src/plugins/permission.ts
@@ -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();
+ }
}
});
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 1deafb6..69d635b 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -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;
+ });
}
});
}