diff --git a/frontend/src/stores/user.ts b/frontend/src/stores/user.ts index 5f1fb433..356a8619 100644 --- a/frontend/src/stores/user.ts +++ b/frontend/src/stores/user.ts @@ -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, isPlatform } from '@/utils/utils' +import { getCurrentRouter, getQueryString, getSQLBotAddr, isPlatform } from '@/utils/utils' const { wsCache } = useCache() @@ -103,7 +103,7 @@ export const UserStore = defineStore('user', { isPlatform() ) { const currentPath = getCurrentRouter() - let logout_url = location.origin + location.pathname + '#/login' + let logout_url = getSQLBotAddr() + '#/login' if (currentPath) { logout_url += `?redirect=${currentPath}` } diff --git a/frontend/src/views/login/xpack/Handler.vue b/frontend/src/views/login/xpack/Handler.vue index 976b27d1..046cffd5 100644 --- a/frontend/src/views/login/xpack/Handler.vue +++ b/frontend/src/views/login/xpack/Handler.vue @@ -64,7 +64,7 @@ import { useCache } from '@/utils/useCache' import router from '@/router' import { useUserStore } from '@/stores/user.ts' -import { getQueryString, getUrlParams, isPlatformClient } from '@/utils/utils' +import { getQueryString, getSQLBotAddr, getUrlParams, isPlatformClient } from '@/utils/utils' import { loadClient, type LoginCategory } from './PlatformClient' // import MfaStep from './MfaStep.vue' // import { logoutHandler } from '@/utils/logout' @@ -344,8 +344,7 @@ const casLogin = () => { // logoutHandler(true, true) platformLoginMsg.value = e?.message || e setTimeout(() => { - window.location.href = - window.location.origin + window.location.pathname + window.location.hash + window.location.href = getSQLBotAddr() + window.location.hash }, 2000) }, 1500) }) @@ -377,8 +376,7 @@ const oauth2Login = () => { // logoutHandler(true, true) platformLoginMsg.value = e?.message || e setTimeout(() => { - window.location.href = - window.location.origin + window.location.pathname + window.location.hash + window.location.href = getSQLBotAddr() + window.location.hash }, 2000) }, 1500) }) @@ -410,8 +408,7 @@ const oidcLogin = () => { // logoutHandler(true, true) platformLoginMsg.value = e?.message || e setTimeout(() => { - window.location.href = - window.location.origin + window.location.pathname + window.location.hash + window.location.href = getSQLBotAddr() + window.location.hash }, 2000) }, 1500) }) @@ -443,15 +440,14 @@ const wecomLogin = () => { // logoutHandler(true, true) platformLoginMsg.value = e?.message || e setTimeout(() => { - window.location.href = - window.location.origin + window.location.pathname + window.location.hash + window.location.href = getSQLBotAddr() + window.location.hash }, 2000) }, 1500) }) } const larkLogin = () => { const urlParams = getUrlParams() - urlParams['redirect_uri'] = encodeURIComponent(window.location.origin + window.location.pathname) + urlParams['redirect_uri'] = encodeURIComponent(getSQLBotAddr()) request .post('/system/platform/sso/8', urlParams) .then((res: any) => { @@ -477,8 +473,7 @@ const larkLogin = () => { // logoutHandler(true, true) platformLoginMsg.value = e?.message || e setTimeout(() => { - window.location.href = - window.location.origin + window.location.pathname + window.location.hash + window.location.href = getSQLBotAddr() + window.location.hash }, 2000) }, 1500) }) @@ -510,8 +505,7 @@ const dingtalkLogin = () => { // logoutHandler(true, true) platformLoginMsg.value = e?.message || e setTimeout(() => { - window.location.href = - window.location.origin + window.location.pathname + window.location.hash + window.location.href = getSQLBotAddr() + window.location.hash }, 2000) }, 1500) }) @@ -536,7 +530,7 @@ const dingtalkLogin = () => { userStore.setTime(Date.now()) if (origin === 10 || isLarkPlatform()) { window.location.href = - window.location.origin + window.location.pathname + window.location.hash + getSQLBotAddr() + window.location.hash } else { const queryRedirectPath = getCurLocation() router.push({ path: queryRedirectPath }) @@ -547,7 +541,7 @@ const dingtalkLogin = () => { if (isLarkPlatform()) { setTimeout(() => { window.location.href = - window.location.origin + window.location.pathname + window.location.hash + getSQLBotAddr() + window.location.hash }, 2000) } else { setTimeout(() => { @@ -613,7 +607,7 @@ const oauth2Token = (cb) => { .catch(() => { setTimeout(() => { window.location.href = - window.location.origin + window.location.pathname + window.location.hash + getSQLBotAddr() + window.location.hash }, 2000) }) } diff --git a/frontend/src/views/login/xpack/PlatformClient.ts b/frontend/src/views/login/xpack/PlatformClient.ts index 4a7100a3..c0d51c6b 100644 --- a/frontend/src/views/login/xpack/PlatformClient.ts +++ b/frontend/src/views/login/xpack/PlatformClient.ts @@ -1,5 +1,5 @@ import { loadScript } from '@/utils/RemoteJs' -import { getQueryString } from '@/utils/utils' +import { getCurrentRouter, getQueryString } from '@/utils/utils' import { ElMessage, ElMessageBox } from 'element-plus-secondary' // import { useI18n } from 'vue-i18n' @@ -35,7 +35,7 @@ export const loadClient = (category: LoginCategory) => { const type = getQueryString('client') const corpid = getQueryString('corpid') if (type && !category[type as keyof LoginCategory]) { - ElMessageBox.confirm(t('login.platform_disable', [t(`threshold.${type}`)]), { + ElMessageBox.confirm(t('login.platform_disable', [t(`user.${type}`)]), { confirmButtonType: 'danger', type: 'warning', showCancelButton: false, @@ -173,5 +173,7 @@ const larksuiteClientRequest = async () => { const toUrl = (url: string) => { const { origin, pathname } = window.location - window.location.href = origin + pathname + url + const redirect = getCurrentRouter() + window.location.href = + origin + pathname + url + (redirect?.includes('chatPreview') ? `#${redirect}` : '') } diff --git a/frontend/src/views/system/authentication/SAML2Editor.vue b/frontend/src/views/system/authentication/SAML2Editor.vue index b4f72ac0..dc20da4f 100644 --- a/frontend/src/views/system/authentication/SAML2Editor.vue +++ b/frontend/src/views/system/authentication/SAML2Editor.vue @@ -4,6 +4,7 @@ import { ElMessage, ElLoading } from 'element-plus-secondary' import { useI18n } from 'vue-i18n' import type { FormInstance, FormRules } from 'element-plus-secondary' import { request } from '@/utils/request' +import { getSQLBotAddr } from '@/utils/utils' const { t } = useI18n() const dialogVisible = ref(false) const loadingInstance = ref | null>(null) @@ -28,7 +29,7 @@ const state = reactive({ }) /* const spMetaDataUrl = ref('') -spMetaDataUrl.value = location.origin + location.pathname + 'saml/metadata' */ +spMetaDataUrl.value = getSQLBotAddr() + 'saml/metadata' */ const rule = reactive({ /* idpUri: [ @@ -72,8 +73,8 @@ const submitForm = async (formEl: FormInstance | undefined) => { await formEl.validate((valid) => { if (valid) { const param = { ...state.form } as any - param['spEntityId'] = location.origin + location.pathname + 'saml/metadata' - param['spAcs'] = location.origin + location.pathname + 'saml/sso' + param['spEntityId'] = getSQLBotAddr() + 'saml/metadata' + param['spAcs'] = getSQLBotAddr() + 'saml/sso' const method = request.post('/setting/authentication/save/saml', param) showLoading() method @@ -114,8 +115,8 @@ const closeLoading = () => { const validate = () => { const url = '/setting/authentication/validate/saml2' const data = { ...state.form } as any - data['spEntityId'] = location.origin + location.pathname + 'saml/metadata' - data['spAcs'] = location.origin + location.pathname + 'saml/sso' + data['spEntityId'] = getSQLBotAddr() + 'saml/metadata' + data['spAcs'] = getSQLBotAddr() + 'saml/sso' showLoading() request .post(url, data)