mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 09:17:06 +08:00
perf: QR Code Login Stuck / Unable to Log Out
This commit is contained in:
committed by
fit2cloud-chenyw
parent
74e0e3a93d
commit
b27e319b6c
@@ -19,7 +19,9 @@ import { useRouter } from 'vue-router'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { userApi } from '@/api/auth'
|
||||
import { toLoginPage } from '@/utils/utils'
|
||||
import { useCache } from '@/utils/useCache'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
const router = useRouter()
|
||||
const appearanceStore = useAppearanceStoreWithOut()
|
||||
const userStore = useUserStore()
|
||||
@@ -36,6 +38,10 @@ const currentLanguage = computed(() => userStore.getLanguage)
|
||||
const isAdmin = computed(() => userStore.isAdmin)
|
||||
const isLocalUser = computed(() => !userStore.getOrigin)
|
||||
|
||||
const isClient = computed(() => {
|
||||
return !!wsCache.get('sqlbot-platform-client')
|
||||
})
|
||||
|
||||
const platFlag = computed(() => {
|
||||
const platformInfo = userStore.getPlatformInfo
|
||||
return platformInfo?.origin || 0
|
||||
@@ -184,7 +190,7 @@ const logout = async () => {
|
||||
<div class="datasource-name">{{ $t('common.help') }}</div>
|
||||
</div>
|
||||
<div style="height: 4px; width: 100%"></div>
|
||||
<div v-if="platFlag <= 5" class="popover-item mr4" @click="logout">
|
||||
<div v-if="!isClient" class="popover-item mr4" @click="logout">
|
||||
<el-icon size="16">
|
||||
<icon_logout_outlined></icon_logout_outlined>
|
||||
</el-icon>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { AuthApi } from '@/api/login'
|
||||
import { useCache } from '@/utils/useCache'
|
||||
import { i18n } from '@/i18n'
|
||||
import { store } from './index'
|
||||
import { getCurrentRouter, getQueryString } from '@/utils/utils'
|
||||
import { getCurrentRouter, getQueryString, isPlatform } from '@/utils/utils'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
@@ -98,7 +98,10 @@ export const UserStore = defineStore('user', {
|
||||
window.open(res, '_self')
|
||||
return res
|
||||
}
|
||||
if (getQueryString('code') && getQueryString('state')?.includes('oauth2_state')) {
|
||||
if (
|
||||
(getQueryString('code') && getQueryString('state')?.includes('oauth2_state')) ||
|
||||
isPlatform()
|
||||
) {
|
||||
const currentPath = getCurrentRouter()
|
||||
let logout_url = location.origin + location.pathname + '#/login'
|
||||
if (currentPath) {
|
||||
|
||||
@@ -245,11 +245,21 @@ export const isLarkPlatform = () => {
|
||||
return !!getQueryString('state') && !!getQueryString('code')
|
||||
}
|
||||
|
||||
export const isPlatform = () => {
|
||||
const state = getQueryString('state')
|
||||
const platformArray = ['wecom', 'dingtalk', 'lark']
|
||||
return (
|
||||
!!state &&
|
||||
!!getQueryString('code') &&
|
||||
platformArray.some((item: string) => state.includes(item))
|
||||
)
|
||||
}
|
||||
|
||||
export const isPlatformClient = () => {
|
||||
return !!getQueryString('client') || getQueryString('state')?.includes('client')
|
||||
}
|
||||
|
||||
export const checkPlatform = () => {
|
||||
/* export const checkPlatform = () => {
|
||||
const flagArray = ['/casbi', 'oidcbi']
|
||||
const pathname = window.location.pathname
|
||||
if (
|
||||
@@ -265,7 +275,7 @@ export const cleanPlatformFlag = () => {
|
||||
const platformKey = 'out_auth_platform'
|
||||
wsCache.delete(platformKey)
|
||||
return false
|
||||
}
|
||||
} */
|
||||
export function isTablet() {
|
||||
const userAgent = navigator.userAgent
|
||||
const tabletRegex = /iPad|Silk|Galaxy Tab|PlayBook|BlackBerry|(tablet|ipad|playbook)/i
|
||||
|
||||
@@ -325,7 +325,7 @@ const casLogin = () => {
|
||||
.then((res: any) => {
|
||||
const token = res.access_token
|
||||
if (token && isPlatformClient()) {
|
||||
wsCache.set('de-platform-client', true)
|
||||
wsCache.set('sqlbot-platform-client', true)
|
||||
}
|
||||
userStore.setToken(token)
|
||||
userStore.setExp(res.exp)
|
||||
@@ -358,7 +358,7 @@ const oauth2Login = () => {
|
||||
const token = res.access_token
|
||||
const platform_info = res.platform_info
|
||||
if (token && isPlatformClient()) {
|
||||
wsCache.set('de-platform-client', true)
|
||||
wsCache.set('sqlbot-platform-client', true)
|
||||
}
|
||||
userStore.setToken(token)
|
||||
userStore.setExp(res.exp)
|
||||
@@ -391,7 +391,7 @@ const oidcLogin = () => {
|
||||
const token = res.access_token
|
||||
const platform_info = res.platform_info
|
||||
if (token && isPlatformClient()) {
|
||||
wsCache.set('de-platform-client', true)
|
||||
wsCache.set('sqlbot-platform-client', true)
|
||||
}
|
||||
userStore.setToken(token)
|
||||
userStore.setExp(res.exp)
|
||||
@@ -424,7 +424,7 @@ const wecomLogin = () => {
|
||||
const token = res.access_token
|
||||
// const platform_info = res.platform_info
|
||||
if (token && isPlatformClient()) {
|
||||
wsCache.set('de-platform-client', true)
|
||||
wsCache.set('sqlbot-platform-client', true)
|
||||
}
|
||||
userStore.setToken(token)
|
||||
userStore.setExp(res.exp)
|
||||
@@ -457,7 +457,7 @@ const dingtalkLogin = () => {
|
||||
const token = res.access_token
|
||||
// const platform_info = res.platform_info
|
||||
if (token && isPlatformClient()) {
|
||||
wsCache.set('de-platform-client', true)
|
||||
wsCache.set('sqlbot-platform-client', true)
|
||||
}
|
||||
userStore.setToken(token)
|
||||
userStore.setExp(res.exp)
|
||||
@@ -495,7 +495,7 @@ const dingtalkLogin = () => {
|
||||
}
|
||||
const token = res.token
|
||||
if (token && isPlatformClient()) {
|
||||
wsCache.set('de-platform-client', true)
|
||||
wsCache.set('sqlbot-platform-client', true)
|
||||
}
|
||||
userStore.setToken(token)
|
||||
userStore.setExp(res.exp)
|
||||
@@ -647,7 +647,7 @@ onMounted(() => {
|
||||
updateLoading(false, 100)
|
||||
return
|
||||
}
|
||||
wsCache.delete('de-platform-client')
|
||||
wsCache.delete('sqlbot-platform-client')
|
||||
init(async () => {
|
||||
const state = callBackType()
|
||||
if (state?.includes('cas') && getQueryString('ticket')) {
|
||||
|
||||
Reference in New Issue
Block a user