Skip to content

Commit 2d8acc7

Browse files
perf: Optimize the embedded Ask-Data module in the client
1 parent 18935b0 commit 2d8acc7

File tree

4 files changed

+24
-27
lines changed

4 files changed

+24
-27
lines changed

frontend/src/stores/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AuthApi } from '@/api/login'
44
import { useCache } from '@/utils/useCache'
55
import { i18n } from '@/i18n'
66
import { store } from './index'
7-
import { getCurrentRouter, getQueryString, isPlatform } from '@/utils/utils'
7+
import { getCurrentRouter, getQueryString, getSQLBotAddr, isPlatform } from '@/utils/utils'
88

99
const { wsCache } = useCache()
1010

@@ -103,7 +103,7 @@ export const UserStore = defineStore('user', {
103103
isPlatform()
104104
) {
105105
const currentPath = getCurrentRouter()
106-
let logout_url = location.origin + location.pathname + '#/login'
106+
let logout_url = getSQLBotAddr() + '#/login'
107107
if (currentPath) {
108108
logout_url += `?redirect=${currentPath}`
109109
}

frontend/src/views/login/xpack/Handler.vue

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { useCache } from '@/utils/useCache'
6464
6565
import router from '@/router'
6666
import { useUserStore } from '@/stores/user.ts'
67-
import { getQueryString, getUrlParams, isPlatformClient } from '@/utils/utils'
67+
import { getQueryString, getSQLBotAddr, getUrlParams, isPlatformClient } from '@/utils/utils'
6868
import { loadClient, type LoginCategory } from './PlatformClient'
6969
// import MfaStep from './MfaStep.vue'
7070
// import { logoutHandler } from '@/utils/logout'
@@ -344,8 +344,7 @@ const casLogin = () => {
344344
// logoutHandler(true, true)
345345
platformLoginMsg.value = e?.message || e
346346
setTimeout(() => {
347-
window.location.href =
348-
window.location.origin + window.location.pathname + window.location.hash
347+
window.location.href = getSQLBotAddr() + window.location.hash
349348
}, 2000)
350349
}, 1500)
351350
})
@@ -377,8 +376,7 @@ const oauth2Login = () => {
377376
// logoutHandler(true, true)
378377
platformLoginMsg.value = e?.message || e
379378
setTimeout(() => {
380-
window.location.href =
381-
window.location.origin + window.location.pathname + window.location.hash
379+
window.location.href = getSQLBotAddr() + window.location.hash
382380
}, 2000)
383381
}, 1500)
384382
})
@@ -410,8 +408,7 @@ const oidcLogin = () => {
410408
// logoutHandler(true, true)
411409
platformLoginMsg.value = e?.message || e
412410
setTimeout(() => {
413-
window.location.href =
414-
window.location.origin + window.location.pathname + window.location.hash
411+
window.location.href = getSQLBotAddr() + window.location.hash
415412
}, 2000)
416413
}, 1500)
417414
})
@@ -443,15 +440,14 @@ const wecomLogin = () => {
443440
// logoutHandler(true, true)
444441
platformLoginMsg.value = e?.message || e
445442
setTimeout(() => {
446-
window.location.href =
447-
window.location.origin + window.location.pathname + window.location.hash
443+
window.location.href = getSQLBotAddr() + window.location.hash
448444
}, 2000)
449445
}, 1500)
450446
})
451447
}
452448
const larkLogin = () => {
453449
const urlParams = getUrlParams()
454-
urlParams['redirect_uri'] = encodeURIComponent(window.location.origin + window.location.pathname)
450+
urlParams['redirect_uri'] = encodeURIComponent(getSQLBotAddr())
455451
request
456452
.post('/system/platform/sso/8', urlParams)
457453
.then((res: any) => {
@@ -477,8 +473,7 @@ const larkLogin = () => {
477473
// logoutHandler(true, true)
478474
platformLoginMsg.value = e?.message || e
479475
setTimeout(() => {
480-
window.location.href =
481-
window.location.origin + window.location.pathname + window.location.hash
476+
window.location.href = getSQLBotAddr() + window.location.hash
482477
}, 2000)
483478
}, 1500)
484479
})
@@ -510,8 +505,7 @@ const dingtalkLogin = () => {
510505
// logoutHandler(true, true)
511506
platformLoginMsg.value = e?.message || e
512507
setTimeout(() => {
513-
window.location.href =
514-
window.location.origin + window.location.pathname + window.location.hash
508+
window.location.href = getSQLBotAddr() + window.location.hash
515509
}, 2000)
516510
}, 1500)
517511
})
@@ -536,7 +530,7 @@ const dingtalkLogin = () => {
536530
userStore.setTime(Date.now())
537531
if (origin === 10 || isLarkPlatform()) {
538532
window.location.href =
539-
window.location.origin + window.location.pathname + window.location.hash
533+
getSQLBotAddr() + window.location.hash
540534
} else {
541535
const queryRedirectPath = getCurLocation()
542536
router.push({ path: queryRedirectPath })
@@ -547,7 +541,7 @@ const dingtalkLogin = () => {
547541
if (isLarkPlatform()) {
548542
setTimeout(() => {
549543
window.location.href =
550-
window.location.origin + window.location.pathname + window.location.hash
544+
getSQLBotAddr() + window.location.hash
551545
}, 2000)
552546
} else {
553547
setTimeout(() => {
@@ -613,7 +607,7 @@ const oauth2Token = (cb) => {
613607
.catch(() => {
614608
setTimeout(() => {
615609
window.location.href =
616-
window.location.origin + window.location.pathname + window.location.hash
610+
getSQLBotAddr() + window.location.hash
617611
}, 2000)
618612
})
619613
}

frontend/src/views/login/xpack/PlatformClient.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { loadScript } from '@/utils/RemoteJs'
2-
import { getQueryString } from '@/utils/utils'
2+
import { getCurrentRouter, getQueryString } from '@/utils/utils'
33
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
44

55
// import { useI18n } from 'vue-i18n'
@@ -35,7 +35,7 @@ export const loadClient = (category: LoginCategory) => {
3535
const type = getQueryString('client')
3636
const corpid = getQueryString('corpid')
3737
if (type && !category[type as keyof LoginCategory]) {
38-
ElMessageBox.confirm(t('login.platform_disable', [t(`threshold.${type}`)]), {
38+
ElMessageBox.confirm(t('login.platform_disable', [t(`user.${type}`)]), {
3939
confirmButtonType: 'danger',
4040
type: 'warning',
4141
showCancelButton: false,
@@ -173,5 +173,7 @@ const larksuiteClientRequest = async () => {
173173

174174
const toUrl = (url: string) => {
175175
const { origin, pathname } = window.location
176-
window.location.href = origin + pathname + url
176+
const redirect = getCurrentRouter()
177+
window.location.href =
178+
origin + pathname + url + (redirect?.includes('chatPreview') ? `#${redirect}` : '')
177179
}

frontend/src/views/system/authentication/SAML2Editor.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ElMessage, ElLoading } from 'element-plus-secondary'
44
import { useI18n } from 'vue-i18n'
55
import type { FormInstance, FormRules } from 'element-plus-secondary'
66
import { request } from '@/utils/request'
7+
import { getSQLBotAddr } from '@/utils/utils'
78
const { t } = useI18n()
89
const dialogVisible = ref(false)
910
const loadingInstance = ref<ReturnType<typeof ElLoading.service> | null>(null)
@@ -28,7 +29,7 @@ const state = reactive({
2829
})
2930
3031
/* const spMetaDataUrl = ref('')
31-
spMetaDataUrl.value = location.origin + location.pathname + 'saml/metadata' */
32+
spMetaDataUrl.value = getSQLBotAddr() + 'saml/metadata' */
3233
3334
const rule = reactive<FormRules>({
3435
/* idpUri: [
@@ -72,8 +73,8 @@ const submitForm = async (formEl: FormInstance | undefined) => {
7273
await formEl.validate((valid) => {
7374
if (valid) {
7475
const param = { ...state.form } as any
75-
param['spEntityId'] = location.origin + location.pathname + 'saml/metadata'
76-
param['spAcs'] = location.origin + location.pathname + 'saml/sso'
76+
param['spEntityId'] = getSQLBotAddr() + 'saml/metadata'
77+
param['spAcs'] = getSQLBotAddr() + 'saml/sso'
7778
const method = request.post('/setting/authentication/save/saml', param)
7879
showLoading()
7980
method
@@ -114,8 +115,8 @@ const closeLoading = () => {
114115
const validate = () => {
115116
const url = '/setting/authentication/validate/saml2'
116117
const data = { ...state.form } as any
117-
data['spEntityId'] = location.origin + location.pathname + 'saml/metadata'
118-
data['spAcs'] = location.origin + location.pathname + 'saml/sso'
118+
data['spEntityId'] = getSQLBotAddr() + 'saml/metadata'
119+
data['spAcs'] = getSQLBotAddr() + 'saml/sso'
119120
showLoading()
120121
request
121122
.post(url, data)

0 commit comments

Comments
 (0)