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() // 重置静态路由表
|
resetRouter() // 重置静态路由表
|
||||||
cache.local.clear()
|
cache.local.clear()
|
||||||
removeToken()
|
removeToken()
|
||||||
window.location.href = `/login`
|
window.location.href = `/ss/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 = `/login`
|
window.location.href = `/ss/login`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Promise.reject(t('sys.api.timeoutMessage'))
|
return Promise.reject(t('sys.api.timeoutMessage'))
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import router from './router'
|
import router from './router'
|
||||||
import { isRelogin } from '@/config/axios/service'
|
import { isRelogin } from '@/config/axios/service'
|
||||||
import { getAccessToken, removeToken } from '@/utils/auth'
|
import { getAccessToken } 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()
|
||||||
|
|
||||||
@@ -20,54 +18,49 @@ 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()
|
||||||
if (getAppId() && to.query?.appId && getAppId() != to.query?.appId) {
|
const userStore = useUserStoreWithOut()
|
||||||
removeToken()
|
if (to.path == '/login') {
|
||||||
cache?.local?.delete('appInfo')
|
userStore.resetState() // 重置用户信息状态
|
||||||
cache?.local?.delete('roleRouters')
|
}
|
||||||
cache?.local?.delete('user')
|
|
||||||
cache?.local?.delete('App_ID')
|
if (getAccessToken()) {
|
||||||
next(`/login`)
|
if (to.path === '/login') {
|
||||||
} else {
|
next({ path: '/' })
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (whiteList.indexOf(to.path) !== -1) {
|
// 获取所有字典
|
||||||
next()
|
const dictStore = useDictStoreWithOut()
|
||||||
} else {
|
const permissionStore = usePermissionStoreWithOut()
|
||||||
// const tenantId = getTenantId()
|
if (!dictStore.getIsSetDict) {
|
||||||
// const appId = getAppId()
|
await dictStore.setDictMap()
|
||||||
// if (tenantId && appId) {
|
|
||||||
// next(`/oa/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
||||||
// } else {
|
|
||||||
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
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() {
|
async resetDict() {
|
||||||
cache.session.delete(CACHE_KEY.DICT_CACHE)
|
cache.session.delete(CACHE_KEY.DICT_CACHE)
|
||||||
const res = await listSimpleDictData()
|
const res = (await listSimpleDictData()) || []
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const dictDataMap = new Map<string, any>()
|
const dictDataMap = new Map<string, any>()
|
||||||
res.forEach((dictData: DictDataVO) => {
|
res.forEach((dictData: DictDataVO) => {
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { store } from '../index'
|
|||||||
import { defineStore } from 'pinia'
|
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 { getInfo, loginOut } from '@/api/login'
|
import { loginOut } from '@/api/login'
|
||||||
|
import { getUserProfile as getUserInfo } from '@/api/system/user/profile'
|
||||||
|
|
||||||
import cache from '@/plugins/cache'
|
import cache from '@/plugins/cache'
|
||||||
|
|
||||||
@@ -50,11 +51,16 @@ export const useUserStore = defineStore('admin-user', {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
let userInfo = cache.local.get(CACHE_KEY.USER)
|
let userInfo = cache.local.get(CACHE_KEY.USER)
|
||||||
if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
|
// if (!userInfo || !userInfo?.menus || userInfo.menus.length == 0) {
|
||||||
userInfo = await getInfo({})
|
// userInfo = await getInfo({})
|
||||||
|
// }
|
||||||
|
if (!userInfo?.user) {
|
||||||
|
userInfo = {
|
||||||
|
user: await getUserInfo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.permissions = userInfo.permissions
|
// this.permissions = userInfo.permissions
|
||||||
this.roles = userInfo.roles
|
// this.roles = userInfo.roles
|
||||||
this.user = userInfo.user
|
this.user = userInfo.user
|
||||||
this.isSetUser = true
|
this.isSetUser = true
|
||||||
cache.local.set(CACHE_KEY.USER, userInfo)
|
cache.local.set(CACHE_KEY.USER, userInfo)
|
||||||
@@ -63,7 +69,7 @@ export const useUserStore = defineStore('admin-user', {
|
|||||||
async loginOut() {
|
async loginOut() {
|
||||||
await loginOut()
|
await loginOut()
|
||||||
removeToken()
|
removeToken()
|
||||||
cache.local.clear()
|
// cache.local.clear()
|
||||||
this.resetState()
|
this.resetState()
|
||||||
},
|
},
|
||||||
resetState() {
|
resetState() {
|
||||||
@@ -75,6 +81,7 @@ 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)
|
||||||
|
|||||||
@@ -9,26 +9,34 @@ const RefreshTokenKey = 'REFRESH_TOKEN'
|
|||||||
// 获取token
|
// 获取token
|
||||||
export const getAccessToken = () => {
|
export const getAccessToken = () => {
|
||||||
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
// 此处与TokenKey相同,此写法解决初始化时Cookies中不存在TokenKey报错
|
||||||
return cache.local.get(AccessTokenKey)
|
return localStorage.getItem(AccessTokenKey)
|
||||||
? cache.local.get(AccessTokenKey)
|
? localStorage.getItem(AccessTokenKey)
|
||||||
: cache.local.get('ACCESS_TOKEN')
|
: localStorage.getItem('ACCESS_TOKEN')
|
||||||
|
// return cache.local.get(AccessTokenKey)
|
||||||
|
// ? cache.local.get(AccessTokenKey)
|
||||||
|
// : cache.local.get('ACCESS_TOKEN')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新token
|
// 刷新token
|
||||||
export const getRefreshToken = () => {
|
export const getRefreshToken = () => {
|
||||||
return cache.local.get(RefreshTokenKey)
|
return localStorage.getItem(RefreshTokenKey)
|
||||||
|
// return cache.local.get(RefreshTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置token
|
// 设置token
|
||||||
export const setToken = (token: TokenType) => {
|
export const setToken = (token: TokenType) => {
|
||||||
cache.local.set(RefreshTokenKey, token.refreshToken)
|
localStorage.setItem(AccessTokenKey, token.accessToken)
|
||||||
cache.local.set(AccessTokenKey, token.accessToken)
|
localStorage.setItem(RefreshTokenKey, token.refreshToken)
|
||||||
|
// cache.local.set(RefreshTokenKey, token.refreshToken)
|
||||||
|
// cache.local.set(AccessTokenKey, token.accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除token
|
// 删除token
|
||||||
export const removeToken = () => {
|
export const removeToken = () => {
|
||||||
cache.local.delete(AccessTokenKey)
|
localStorage.removeItem(AccessTokenKey)
|
||||||
cache.local.delete(RefreshTokenKey)
|
localStorage.removeItem(RefreshTokenKey)
|
||||||
|
// cache.local.delete(AccessTokenKey)
|
||||||
|
// cache.local.delete(RefreshTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 格式化token(jwt格式) */
|
/** 格式化token(jwt格式) */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Error type="403" @error-click="push('/Home/index')" />
|
<Error type="403" @error-click="push('/index')" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="Error403" setup>
|
<script lang="ts" name="Error403" setup>
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Error @error-click="push('/Home/index')" />
|
<Error @error-click="push('/index')" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="Error404" setup>
|
<script lang="ts" name="Error404" setup>
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<Error type="500" @error-click="push('/Home/index')" />
|
<Error type="500" @error-click="push('/index')" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" name="Error500" setup>
|
<script lang="ts" name="Error500" setup>
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
|
|||||||
@@ -6,11 +6,21 @@
|
|||||||
v-for="item in appList"
|
v-for="item in appList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
shadow="hover"
|
shadow="hover"
|
||||||
class="width-200px"
|
class="app-card"
|
||||||
@click="handleAppClick(item)"
|
@click="handleAppClick(item)"
|
||||||
>
|
>
|
||||||
<!-- card body -->
|
<!-- 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>
|
<div class="cutout-text">{{ item.clientName }}</div>
|
||||||
|
|
||||||
<template #footer v-if="item.clientDescription">
|
<template #footer v-if="item.clientDescription">
|
||||||
@@ -42,10 +52,14 @@ function handleAppClick(item) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
::v-deep(.app-card) {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
::v-deep(.el-card__body) {
|
::v-deep(.el-card__body) {
|
||||||
background-color: #001529;
|
background-color: #000;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
min-width: 260px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cutout-text {
|
.cutout-text {
|
||||||
@@ -53,7 +67,7 @@ function handleAppClick(item) {
|
|||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
-webkit-text-stroke: 1px #9a9acc;
|
-webkit-text-stroke: 1px #9a9acc;
|
||||||
color: #001529;
|
color: #000;
|
||||||
&::before {
|
&::before {
|
||||||
content: ' ';
|
content: ' ';
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -72,7 +86,7 @@ function handleAppClick(item) {
|
|||||||
width: 200%;
|
width: 200%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: radial-gradient(circle, #fff, #000 50%);
|
background: radial-gradient(circle, #fff, #000 50%);
|
||||||
background-size: 25% 30%;
|
background-size: 25% 1%;
|
||||||
mix-blend-mode: color-dodge;
|
mix-blend-mode: color-dodge;
|
||||||
animation: mix 4s linear infinite;
|
animation: mix 4s linear infinite;
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
|
|||||||
Reference in New Issue
Block a user