Compare commits

..

No commits in common. 'fa2a0818da7046964fb6af604428546c12e9e960' and '1039122a2b3523ca75c335873d0b03ae3c234ea6' have entirely different histories.

  1. 4
      src/config/axios/service.ts
  2. 89
      src/permission.js
  3. 6
      src/store/modules/user.ts
  4. 15
      src/views/Home/index.vue
  5. 2
      src/views/Login/components/LoginForm.vue

@ -218,7 +218,7 @@ service.interceptors.response.use(
resetRouter() // 重置静态路由表 resetRouter() // 重置静态路由表
cache.local.clear() cache.local.clear()
removeToken() removeToken()
window.location.href = `/ss/login` window.location.href = `/login`
}) })
} }
} }
@ -266,7 +266,7 @@ const handleAuthorized = () => {
isRelogin.show = false isRelogin.show = false
// 干掉token后再走一次路由让它过router.beforeEach的校验 // 干掉token后再走一次路由让它过router.beforeEach的校验
// window.location.href = window.location.href // window.location.href = window.location.href
window.location.href = `/ss/login` window.location.href = `/login`
}) })
} }
return Promise.reject(t('sys.api.timeoutMessage')) return Promise.reject(t('sys.api.timeoutMessage'))

@ -1,12 +1,14 @@
import router from './router' import router from './router'
import { isRelogin } from '@/config/axios/service' import { isRelogin } from '@/config/axios/service'
import { getAccessToken } from '@/utils/auth' import { getAccessToken, removeToken } from '@/utils/auth'
import { useTitle } from '@/hooks/web/useTitle' import { useTitle } from '@/hooks/web/useTitle'
import { useNProgress } from '@/hooks/web/useNProgress' import { useNProgress } from '@/hooks/web/useNProgress'
import { usePageLoading } from '@/hooks/web/usePageLoading' import { usePageLoading } from '@/hooks/web/usePageLoading'
import { useDictStoreWithOut } from '@/store/modules/dict' import { useDictStoreWithOut } from '@/store/modules/dict'
import { useUserStoreWithOut } from '@/store/modules/user' import { useUserStoreWithOut } from '@/store/modules/user'
import { usePermissionStoreWithOut } from '@/store/modules/permission' import { usePermissionStoreWithOut } from '@/store/modules/permission'
import { getAppId } from '@/utils/auth'
import cache from '@/plugins/cache'
const { start, done } = useNProgress() const { start, done } = useNProgress()
@ -18,49 +20,54 @@ const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/regis
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
start() start()
loadStart() loadStart()
const userStore = useUserStoreWithOut() if (getAppId() && to.query?.appId && getAppId() != to.query?.appId) {
if (to.path == '/login') { removeToken()
userStore.resetState() // 重置用户信息状态 cache?.local?.delete('appInfo')
} cache?.local?.delete('roleRouters')
cache?.local?.delete('user')
if (getAccessToken()) { cache?.local?.delete('App_ID')
if (to.path === '/login') { next(`/login`)
next({ path: '/' }) } else {
} else { if (getAccessToken()) {
// 获取所有字典 if (to.path === '/login') {
const dictStore = useDictStoreWithOut() next({ path: '/' })
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 { } else {
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 {
next()
}
} }
}
} else {
if (whiteList.indexOf(to.path) !== -1) {
next()
} else { } else {
// const tenantId = getTenantId() if (whiteList.indexOf(to.path) !== -1) {
// const appId = getAppId() next()
// if (tenantId && appId) { } else {
// next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页 // const tenantId = getTenantId()
// } else { // const appId = getAppId()
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 // if (tenantId && appId) {
// } // next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
// } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
// }
}
} }
} }
}) })

@ -3,7 +3,7 @@ import { defineStore } from 'pinia'
import { getAccessToken, removeToken } from '@/utils/auth' import { getAccessToken, removeToken } from '@/utils/auth'
import { CACHE_KEY } from '@/hooks/web/useCache' import { CACHE_KEY } from '@/hooks/web/useCache'
import { loginOut } from '@/api/login' import { loginOut } from '@/api/login'
import { getUserProfile as getUserInfo } from '@/api/system/user/profile' import { getUser as getUserInfo } from '@/api/system/user'
import cache from '@/plugins/cache' import cache from '@/plugins/cache'
@ -55,8 +55,9 @@ export const useUserStore = defineStore('admin-user', {
// userInfo = await getInfo({}) // userInfo = await getInfo({})
// } // }
if (!userInfo?.user) { if (!userInfo?.user) {
const userId = localStorage.getItem('userId')
userInfo = { userInfo = {
user: await getUserInfo() user: await getUserInfo(Number(userId))
} }
} }
// this.permissions = userInfo.permissions // this.permissions = userInfo.permissions
@ -81,7 +82,6 @@ export const useUserStore = defineStore('admin-user', {
avatar: '', avatar: '',
nickname: '' nickname: ''
} }
cache.local.delete(CACHE_KEY.USER)
}, },
refresh() { refresh() {
cache.local.delete(CACHE_KEY.USER) cache.local.delete(CACHE_KEY.USER)

@ -10,17 +10,12 @@
@click="handleAppClick(item)" @click="handleAppClick(item)"
> >
<!-- card body --> <!-- card body -->
<div <el-image
class="inline-flex align-center justify-center" :src="item.clientLogo"
fit="fill"
:lazy="true"
style="width: 180px; height: 180px; border-radius: 10px; background-color: #fff" style="width: 180px; height: 180px; border-radius: 10px; background-color: #fff"
> />
<el-image
:src="item.clientLogo"
fit="contain"
:lazy="true"
style="width: 100%; height: auto"
/>
</div>
<div class="cutout-text">{{ item.clientName }}</div> <div class="cutout-text">{{ item.clientName }}</div>
<template #footer v-if="item.clientDescription"> <template #footer v-if="item.clientDescription">

@ -200,6 +200,8 @@ const handleLogin = async (params) => {
if (res?.tenantId) { if (res?.tenantId) {
authUtil.setTenantId(res.tenantId) authUtil.setTenantId(res.tenantId)
} }
// userId
localStorage.setItem('userId', res.userId)
ElLoading.service({ ElLoading.service({
lock: true, lock: true,

Loading…
Cancel
Save