From e877dfd259d7a49011023576744737bf00f5960a Mon Sep 17 00:00:00 2001 From: guanyu Date: Mon, 15 Jun 2026 08:18:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(#606):=20guanyu=20(=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=88=E5=85=A5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- healthlink-his-ui/src/store/modules/app.js | 8 ++++---- healthlink-his-ui/src/utils/auth.js | 4 ++-- healthlink-his-ui/src/views/login.vue | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/healthlink-his-ui/src/store/modules/app.js b/healthlink-his-ui/src/store/modules/app.js index 0b5715964..5d5dc4f54 100755 --- a/healthlink-his-ui/src/store/modules/app.js +++ b/healthlink-his-ui/src/store/modules/app.js @@ -20,13 +20,13 @@ const useAppStore = defineStore( this.sidebar.opened = !this.sidebar.opened this.sidebar.withoutAnimation = withoutAnimation if (this.sidebar.opened) { - Cookies.set('sidebarStatus', 1) + Cookies.set('sidebarStatus', 1, { path: '/' }) } else { - Cookies.set('sidebarStatus', 0) + Cookies.set('sidebarStatus', 0, { path: '/' }) } }, closeSideBar({ withoutAnimation }) { - Cookies.set('sidebarStatus', 0) + Cookies.set('sidebarStatus', 0, { path: '/' }) this.sidebar.opened = false this.sidebar.withoutAnimation = withoutAnimation }, @@ -35,7 +35,7 @@ const useAppStore = defineStore( }, setSize(size) { this.size = size; - Cookies.set('size', size) + Cookies.set('size', size, { path: '/' }) }, toggleSideBarHide(status) { this.sidebar.hide = status diff --git a/healthlink-his-ui/src/utils/auth.js b/healthlink-his-ui/src/utils/auth.js index 08a43d6e2..fa8c79973 100755 --- a/healthlink-his-ui/src/utils/auth.js +++ b/healthlink-his-ui/src/utils/auth.js @@ -7,9 +7,9 @@ export function getToken() { } export function setToken(token) { - return Cookies.set(TokenKey, token) + return Cookies.set(TokenKey, token, { path: '/' }) } export function removeToken() { - return Cookies.remove(TokenKey) + return Cookies.remove(TokenKey, { path: '/' }) } diff --git a/healthlink-his-ui/src/views/login.vue b/healthlink-his-ui/src/views/login.vue index b2a0cd12f..e8fe35aa5 100755 --- a/healthlink-his-ui/src/views/login.vue +++ b/healthlink-his-ui/src/views/login.vue @@ -321,16 +321,17 @@ function handleLogin() { loading.value = true; // 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码 if (loginForm.value.rememberMe) { - Cookies.set('username', loginForm.value.username, { expires: 30 }); + Cookies.set('username', loginForm.value.username, { expires: 30, path: '/' }); Cookies.set('password', encrypt(loginForm.value.password), { expires: 30, + path: '/', }); - Cookies.set('rememberMe', loginForm.value.rememberMe, { expires: 30 }); + Cookies.set('rememberMe', loginForm.value.rememberMe, { expires: 30, path: '/' }); } else { // 否则移除 - Cookies.remove('username'); - Cookies.remove('password'); - Cookies.remove('rememberMe'); + Cookies.remove('username', { path: '/' }); + Cookies.remove('password', { path: '/' }); + Cookies.remove('rememberMe', { path: '/' }); } // 调用action的登录方法 userStore