From c13e06b0bfb78af9fcee9833d3d3553a5da892c3 Mon Sep 17 00:00:00 2001
From: qsh <>
Date: Tue, 27 May 2025 10:33:50 +0800
Subject: [PATCH 1/4] sc
---
src/views/Home/index.vue | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/views/Home/index.vue b/src/views/Home/index.vue
index 6fbc6de..413322b 100644
--- a/src/views/Home/index.vue
+++ b/src/views/Home/index.vue
@@ -10,12 +10,17 @@
@click="handleAppClick(item)"
>
-
+ >
+
+
{{ item.clientName }}
From 748709783d217261f2062219c8b5ba2a76ed5e7c Mon Sep 17 00:00:00 2001
From: qsh <>
Date: Tue, 27 May 2025 10:51:12 +0800
Subject: [PATCH 2/4] sc
---
src/permission.js | 81 +++++++++++++++++++++--------------------------
1 file changed, 36 insertions(+), 45 deletions(-)
diff --git a/src/permission.js b/src/permission.js
index 228bf79..44e9b66 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -20,55 +20,46 @@ const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/regis
router.beforeEach(async (to, from, next) => {
start()
loadStart()
- if (getAppId() && to.query?.appId && getAppId() != to.query?.appId) {
- removeToken()
- cache?.local?.delete('appInfo')
- cache?.local?.delete('roleRouters')
- cache?.local?.delete('user')
- cache?.local?.delete('App_ID')
- next(`/login`)
- } else {
- if (getAccessToken()) {
- if (to.path === '/login') {
- next({ path: '/' })
- } else {
- // 获取所有字典
- const dictStore = useDictStoreWithOut()
- const userStore = useUserStoreWithOut()
- const permissionStore = usePermissionStoreWithOut()
- if (!dictStore.getIsSetDict) {
- await dictStore.setDictMap()
- }
- if (!userStore.getIsSetUser) {
- isRelogin.show = true
- await userStore.setUserInfoAction()
- isRelogin.show = false
- // 后端过滤菜单
- await permissionStore.generateRoutes()
- permissionStore.getAddRouters.forEach((route) => {
- router.addRoute(route) // 动态添加可访问路由表
- })
- const redirectPath = from.query.redirect || to.path
- const redirect = decodeURIComponent(redirectPath)
- const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
- next(nextData)
- } else {
- next()
- }
- }
+ if (getAccessToken()) {
+ if (to.path === '/login') {
+ next({ path: '/' })
} else {
- if (whiteList.indexOf(to.path) !== -1) {
- next()
+ // 获取所有字典
+ const dictStore = useDictStoreWithOut()
+ const userStore = useUserStoreWithOut()
+ const permissionStore = usePermissionStoreWithOut()
+ if (!dictStore.getIsSetDict) {
+ await dictStore.setDictMap()
+ }
+ if (!userStore.getIsSetUser) {
+ isRelogin.show = true
+ await userStore.setUserInfoAction()
+ isRelogin.show = false
+ // 后端过滤菜单
+ await permissionStore.generateRoutes()
+ permissionStore.getAddRouters.forEach((route) => {
+ router.addRoute(route) // 动态添加可访问路由表
+ })
+ const redirectPath = from.query.redirect || to.path
+ const redirect = decodeURIComponent(redirectPath)
+ const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
+ next(nextData)
} else {
- // const tenantId = getTenantId()
- // const appId = getAppId()
- // if (tenantId && appId) {
- // next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
- // } else {
- next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
- // }
+ next()
}
}
+ } else {
+ if (whiteList.indexOf(to.path) !== -1) {
+ next()
+ } else {
+ // const tenantId = getTenantId()
+ // const appId = getAppId()
+ // if (tenantId && appId) {
+ // next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
+ // } else {
+ next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
+ // }
+ }
}
})
From 5f196eebaec3e1896f60dfa7dd3a76437843c331 Mon Sep 17 00:00:00 2001
From: qsh <>
Date: Tue, 27 May 2025 10:51:29 +0800
Subject: [PATCH 3/4] sc
---
src/permission.js | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/permission.js b/src/permission.js
index 44e9b66..22c5153 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -1,14 +1,12 @@
import router from './router'
import { isRelogin } from '@/config/axios/service'
-import { getAccessToken, removeToken } from '@/utils/auth'
+import { getAccessToken } from '@/utils/auth'
import { useTitle } from '@/hooks/web/useTitle'
import { useNProgress } from '@/hooks/web/useNProgress'
import { usePageLoading } from '@/hooks/web/usePageLoading'
import { useDictStoreWithOut } from '@/store/modules/dict'
import { useUserStoreWithOut } from '@/store/modules/user'
import { usePermissionStoreWithOut } from '@/store/modules/permission'
-import { getAppId } from '@/utils/auth'
-import cache from '@/plugins/cache'
const { start, done } = useNProgress()
From 6db7edfc2f0a0c4e52f13bb207919f732bcd3860 Mon Sep 17 00:00:00 2001
From: qsh <>
Date: Tue, 27 May 2025 11:38:18 +0800
Subject: [PATCH 4/4] sc
---
src/config/axios/service.ts | 4 ++--
src/permission.js | 6 +++++-
src/store/modules/user.ts | 6 +++---
src/views/Login/components/LoginForm.vue | 2 --
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/config/axios/service.ts b/src/config/axios/service.ts
index 99a1087..68ff30f 100644
--- a/src/config/axios/service.ts
+++ b/src/config/axios/service.ts
@@ -218,7 +218,7 @@ service.interceptors.response.use(
resetRouter() // 重置静态路由表
cache.local.clear()
removeToken()
- window.location.href = `/login`
+ window.location.href = `/ss/login`
})
}
}
@@ -266,7 +266,7 @@ const handleAuthorized = () => {
isRelogin.show = false
// 干掉token后再走一次路由让它过router.beforeEach的校验
// window.location.href = window.location.href
- window.location.href = `/login`
+ window.location.href = `/ss/login`
})
}
return Promise.reject(t('sys.api.timeoutMessage'))
diff --git a/src/permission.js b/src/permission.js
index 22c5153..9343943 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -18,13 +18,17 @@ const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/regis
router.beforeEach(async (to, from, next) => {
start()
loadStart()
+ const userStore = useUserStoreWithOut()
+ if (to.path == '/login') {
+ userStore.resetState() // 重置用户信息状态
+ }
+
if (getAccessToken()) {
if (to.path === '/login') {
next({ path: '/' })
} else {
// 获取所有字典
const dictStore = useDictStoreWithOut()
- const userStore = useUserStoreWithOut()
const permissionStore = usePermissionStoreWithOut()
if (!dictStore.getIsSetDict) {
await dictStore.setDictMap()
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 30ceee9..0110c0f 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia'
import { getAccessToken, removeToken } from '@/utils/auth'
import { CACHE_KEY } from '@/hooks/web/useCache'
import { loginOut } from '@/api/login'
-import { getUser as getUserInfo } from '@/api/system/user'
+import { getUserProfile as getUserInfo } from '@/api/system/user/profile'
import cache from '@/plugins/cache'
@@ -55,9 +55,8 @@ export const useUserStore = defineStore('admin-user', {
// userInfo = await getInfo({})
// }
if (!userInfo?.user) {
- const userId = localStorage.getItem('userId')
userInfo = {
- user: await getUserInfo(Number(userId))
+ user: await getUserInfo()
}
}
// this.permissions = userInfo.permissions
@@ -82,6 +81,7 @@ export const useUserStore = defineStore('admin-user', {
avatar: '',
nickname: ''
}
+ cache.local.delete(CACHE_KEY.USER)
},
refresh() {
cache.local.delete(CACHE_KEY.USER)
diff --git a/src/views/Login/components/LoginForm.vue b/src/views/Login/components/LoginForm.vue
index 32dca8d..d616811 100644
--- a/src/views/Login/components/LoginForm.vue
+++ b/src/views/Login/components/LoginForm.vue
@@ -200,8 +200,6 @@ const handleLogin = async (params) => {
if (res?.tenantId) {
authUtil.setTenantId(res.tenantId)
}
- // 设置userId
- localStorage.setItem('userId', res.userId)
ElLoading.service({
lock: true,