Compare commits
10 Commits
1a1fc0fbf9
...
dev-cl
| Author | SHA1 | Date | |
|---|---|---|---|
| fa2a0818da | |||
|
|
6db7edfc2f | ||
|
|
5f196eebae | ||
|
|
748709783d | ||
|
|
c13e06b0bf | ||
| 1039122a2b | |||
|
|
893f827643 | ||
|
|
a4af107652 | ||
|
|
d60fd3eb4c | ||
|
|
95e923841d |
@@ -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'))
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -20,54 +18,49 @@ 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()
|
||||
}
|
||||
}
|
||||
const userStore = useUserStoreWithOut()
|
||||
if (to.path == '/login') {
|
||||
userStore.resetState() // 重置用户信息状态
|
||||
}
|
||||
|
||||
if (getAccessToken()) {
|
||||
if (to.path === '/login') {
|
||||
next({ path: '/' })
|
||||
} 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}`) // 否则全部重定向到登录页
|
||||
// }
|
||||
// 获取所有字典
|
||||
const dictStore = useDictStoreWithOut()
|
||||
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 {
|
||||
// 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}`) // 否则全部重定向到登录页
|
||||
// }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -75,7 +75,7 @@ export const useDictStore = defineStore('dict', {
|
||||
},
|
||||
async resetDict() {
|
||||
cache.session.delete(CACHE_KEY.DICT_CACHE)
|
||||
const res = await listSimpleDictData()
|
||||
const res = (await listSimpleDictData()) || []
|
||||
// 设置数据
|
||||
const dictDataMap = new Map<string, any>()
|
||||
res.forEach((dictData: DictDataVO) => {
|
||||
|
||||
@@ -2,7 +2,8 @@ import { store } from '../index'
|
||||
import { defineStore } from 'pinia'
|
||||
import { getAccessToken, removeToken } from '@/utils/auth'
|
||||
import { CACHE_KEY } from '@/hooks/web/useCache'
|
||||
import { getInfo, loginOut } from '@/api/login'
|
||||
import { loginOut } from '@/api/login'
|
||||
import { getUserProfile as getUserInfo } from '@/api/system/user/profile'
|
||||
|
||||
import cache from '@/plugins/cache'
|
||||
|
||||
@@ -50,11 +51,16 @@ export const useUserStore = defineStore('admin-user', {
|
||||
return null
|
||||
}
|
||||
let userInfo = cache.local.get(CACHE_KEY.USER)
|
||||
if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
|
||||
userInfo = await getInfo({})
|
||||
// if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
|
||||
// userInfo = await getInfo({})
|
||||
// }
|
||||
if (!userInfo?.user) {
|
||||
userInfo = {
|
||||
user: await getUserInfo()
|
||||
}
|
||||
}
|
||||
this.permissions = userInfo.permissions
|
||||
this.roles = userInfo.roles
|
||||
// this.permissions = userInfo.permissions
|
||||
// this.roles = userInfo.roles
|
||||
this.user = userInfo.user
|
||||
this.isSetUser = true
|
||||
cache.local.set(CACHE_KEY.USER, userInfo)
|
||||
@@ -63,7 +69,7 @@ export const useUserStore = defineStore('admin-user', {
|
||||
async loginOut() {
|
||||
await loginOut()
|
||||
removeToken()
|
||||
cache.local.clear()
|
||||
// cache.local.clear()
|
||||
this.resetState()
|
||||
},
|
||||
resetState() {
|
||||
@@ -75,6 +81,7 @@ export const useUserStore = defineStore('admin-user', {
|
||||
avatar: '',
|
||||
nickname: ''
|
||||
}
|
||||
cache.local.delete(CACHE_KEY.USER)
|
||||
},
|
||||
refresh() {
|
||||
cache.local.delete(CACHE_KEY.USER)
|
||||
|
||||
@@ -9,26 +9,34 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
|
||||
// 获取token
|
||||
export const getAccessToken = () => {
|
||||
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
||||
return cache.local.get(AccessTokenKey)
|
||||
? cache.local.get(AccessTokenKey)
|
||||
: cache.local.get('ACCESS_TOKEN')
|
||||
return localStorage.getItem(AccessTokenKey)
|
||||
? localStorage.getItem(AccessTokenKey)
|
||||
: localStorage.getItem('ACCESS_TOKEN')
|
||||
// return cache.local.get(AccessTokenKey)
|
||||
// ? cache.local.get(AccessTokenKey)
|
||||
// : cache.local.get('ACCESS_TOKEN')
|
||||
}
|
||||
|
||||
// 刷新token
|
||||
export const getRefreshToken = () => {
|
||||
return cache.local.get(RefreshTokenKey)
|
||||
return localStorage.getItem(RefreshTokenKey)
|
||||
// return cache.local.get(RefreshTokenKey)
|
||||
}
|
||||
|
||||
// 设置token
|
||||
export const setToken = (token: TokenType) => {
|
||||
cache.local.set(RefreshTokenKey, token.refreshToken)
|
||||
cache.local.set(AccessTokenKey, token.accessToken)
|
||||
localStorage.setItem(AccessTokenKey, token.accessToken)
|
||||
localStorage.setItem(RefreshTokenKey, token.refreshToken)
|
||||
// cache.local.set(RefreshTokenKey, token.refreshToken)
|
||||
// cache.local.set(AccessTokenKey, token.accessToken)
|
||||
}
|
||||
|
||||
// 删除token
|
||||
export const removeToken = () => {
|
||||
cache.local.delete(AccessTokenKey)
|
||||
cache.local.delete(RefreshTokenKey)
|
||||
localStorage.removeItem(AccessTokenKey)
|
||||
localStorage.removeItem(RefreshTokenKey)
|
||||
// cache.local.delete(AccessTokenKey)
|
||||
// cache.local.delete(RefreshTokenKey)
|
||||
}
|
||||
|
||||
/** 格式化token(jwt格式) */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Error type="403" @error-click="push('/Home/index')" />
|
||||
<Error type="403" @error-click="push('/index')" />
|
||||
</template>
|
||||
<script lang="ts" name="Error403" setup>
|
||||
const { push } = useRouter()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Error @error-click="push('/Home/index')" />
|
||||
<Error @error-click="push('/index')" />
|
||||
</template>
|
||||
<script lang="ts" name="Error404" setup>
|
||||
const { push } = useRouter()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Error type="500" @error-click="push('/Home/index')" />
|
||||
<Error type="500" @error-click="push('/index')" />
|
||||
</template>
|
||||
<script lang="ts" name="Error500" setup>
|
||||
const { push } = useRouter()
|
||||
|
||||
@@ -6,11 +6,21 @@
|
||||
v-for="item in appList"
|
||||
:key="item.id"
|
||||
shadow="hover"
|
||||
class="width-200px"
|
||||
class="app-card"
|
||||
@click="handleAppClick(item)"
|
||||
>
|
||||
<!-- card body -->
|
||||
<el-image :src="item.clientLogo" fit="fill" :lazy="true" style="width: 180px" />
|
||||
<div
|
||||
class="inline-flex align-center justify-center"
|
||||
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>
|
||||
|
||||
<template #footer v-if="item.clientDescription">
|
||||
@@ -42,10 +52,14 @@ function handleAppClick(item) {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep(.app-card) {
|
||||
cursor: pointer;
|
||||
}
|
||||
::v-deep(.el-card__body) {
|
||||
background-color: #001529;
|
||||
background-color: #000;
|
||||
padding: 5px;
|
||||
text-align: center;
|
||||
min-width: 260px;
|
||||
}
|
||||
|
||||
.cutout-text {
|
||||
@@ -53,7 +67,7 @@ function handleAppClick(item) {
|
||||
font-size: 40px;
|
||||
font-weight: bold;
|
||||
-webkit-text-stroke: 1px #9a9acc;
|
||||
color: #001529;
|
||||
color: #000;
|
||||
&::before {
|
||||
content: ' ';
|
||||
width: 100%;
|
||||
@@ -72,7 +86,7 @@ function handleAppClick(item) {
|
||||
width: 200%;
|
||||
height: 100%;
|
||||
background: radial-gradient(circle, #fff, #000 50%);
|
||||
background-size: 25% 30%;
|
||||
background-size: 25% 1%;
|
||||
mix-blend-mode: color-dodge;
|
||||
animation: mix 4s linear infinite;
|
||||
background-repeat: repeat;
|
||||
|
||||
Reference in New Issue
Block a user