forked from github/dataease
Merge pull request #9476 from dataease/pr@dev-v2@fix_platform_login
fix: oidc登录之后关闭页面再次访问de报错
This commit is contained in:
commit
eae47f6e3a
@ -7,7 +7,7 @@ import { usePermissionStoreWithOut, pathValid, getFirstAuthMenu } from '@/store/
|
||||
import { usePageLoading } from '@/hooks/web/usePageLoading'
|
||||
import { getRoleRouters } from '@/api/common'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
import { isMobile } from '@/utils/utils'
|
||||
import { isMobile, checkPlatform } from '@/utils/utils'
|
||||
import { interactiveStoreWithOut } from '@/store/modules/interactive'
|
||||
import { useAppearanceStoreWithOut } from '@/store/modules/appearance'
|
||||
import { useEmbedded } from '@/store/modules/embedded'
|
||||
@ -28,6 +28,7 @@ const embeddedRouteWhiteList = ['/dataset-embedded', '/dataset-form', '/dataset-
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
start()
|
||||
loadStart()
|
||||
checkPlatform()
|
||||
if (isMobile()) {
|
||||
done()
|
||||
loadDone()
|
||||
|
@ -27,7 +27,6 @@ export const logoutHandler = (justClean?: boolean) => {
|
||||
return
|
||||
}
|
||||
if (wsCache.get('out_auth_platform') === 'oidc') {
|
||||
localStorage.removeItem('out_auth_platform')
|
||||
window.location.href = '/oidcbi/oidc/logout'
|
||||
return
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { BusiTreeNode } from '@/models/tree/TreeNode'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
export function deepCopy(target) {
|
||||
if (target === null || target === undefined) {
|
||||
return target
|
||||
@ -87,6 +89,24 @@ export const isPlatformClient = () => {
|
||||
return !!getQueryString('client') || getQueryString('state')?.includes('client')
|
||||
}
|
||||
|
||||
export const checkPlatform = () => {
|
||||
const flagArray = ['/casbi', 'oidcbi']
|
||||
const pathname = window.location.pathname
|
||||
if (
|
||||
!flagArray.some(flag => pathname.includes(flag)) &&
|
||||
!isLarkPlatform() &&
|
||||
!isPlatformClient()
|
||||
) {
|
||||
return cleanPlatformFlag()
|
||||
}
|
||||
return true
|
||||
}
|
||||
export const cleanPlatformFlag = () => {
|
||||
const platformKey = 'out_auth_platform'
|
||||
wsCache.delete(platformKey)
|
||||
return false
|
||||
}
|
||||
|
||||
export function isMobile() {
|
||||
return (
|
||||
navigator.userAgent.match(
|
||||
|
@ -16,7 +16,7 @@ import { XpackComponent } from '@/components/plugin'
|
||||
import { logoutHandler } from '@/utils/logout'
|
||||
import DeImage from '@/assets/login-desc-de.png'
|
||||
import elementResizeDetectorMaker from 'element-resize-detector'
|
||||
import { isLarkPlatform, isPlatformClient } from '@/utils/utils'
|
||||
import { checkPlatform, cleanPlatformFlag } from '@/utils/utils'
|
||||
import xss from 'xss'
|
||||
const { wsCache } = useCache()
|
||||
const appStore = useAppStoreWithOut()
|
||||
@ -134,23 +134,6 @@ const showLoginImage = computed<boolean>(() => {
|
||||
return !(loginContainerWidth.value < 889)
|
||||
})
|
||||
|
||||
const checkPlatform = () => {
|
||||
const flagArray = ['/casbi', 'oidcbi']
|
||||
const pathname = window.location.pathname
|
||||
if (
|
||||
!flagArray.some(flag => pathname.includes(flag)) &&
|
||||
!isLarkPlatform() &&
|
||||
!isPlatformClient()
|
||||
) {
|
||||
cleanPlatformFlag()
|
||||
}
|
||||
}
|
||||
const cleanPlatformFlag = () => {
|
||||
const platformKey = 'out_auth_platform'
|
||||
wsCache.delete(platformKey)
|
||||
preheat.value = false
|
||||
}
|
||||
|
||||
const preheat = ref(true)
|
||||
const showLoginErrorMsg = () => {
|
||||
if (!loginErrorMsg.value) {
|
||||
@ -219,7 +202,9 @@ const loadArrearance = () => {
|
||||
}
|
||||
onMounted(() => {
|
||||
loadArrearance()
|
||||
checkPlatform()
|
||||
if (!checkPlatform()) {
|
||||
preheat.value = false
|
||||
}
|
||||
if (localStorage.getItem('DE-GATEWAY-FLAG')) {
|
||||
const msg = localStorage.getItem('DE-GATEWAY-FLAG')
|
||||
loginErrorMsg.value = decodeURIComponent(msg)
|
||||
|
Loading…
Reference in New Issue
Block a user