From bdcad1bddbbbde32b48a8ff25a951a0855e62ce4 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 21 Jan 2026 17:45:39 +0800 Subject: [PATCH] feat(X-Pack): Support Lark embedded --- frontend/src/views/login/xpack/Handler.vue | 36 +++++++++ frontend/src/views/login/xpack/LarkQr.vue | 77 +++++++++++++++++++ .../src/views/login/xpack/PlatformClient.ts | 18 ++--- frontend/src/views/login/xpack/QrTab.vue | 6 +- .../system/platform/common/SettingTemplate.ts | 26 ++----- frontend/src/views/system/platform/index.vue | 2 +- 6 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 frontend/src/views/login/xpack/LarkQr.vue diff --git a/frontend/src/views/login/xpack/Handler.vue b/frontend/src/views/login/xpack/Handler.vue index 1134d3c7..976b27d1 100644 --- a/frontend/src/views/login/xpack/Handler.vue +++ b/frontend/src/views/login/xpack/Handler.vue @@ -449,6 +449,40 @@ const wecomLogin = () => { }, 1500) }) } +const larkLogin = () => { + const urlParams = getUrlParams() + urlParams['redirect_uri'] = encodeURIComponent(window.location.origin + window.location.pathname) + request + .post('/system/platform/sso/8', urlParams) + .then((res: any) => { + const token = res.access_token + // const platform_info = res.platform_info + if (token && isPlatformClient()) { + wsCache.set('sqlbot-platform-client', true) + } + userStore.setToken(token) + userStore.setExp(res.exp) + userStore.setTime(Date.now()) + userStore.setPlatformInfo({ + flag: 'lark', + // data: platform_info ? JSON.stringify(platform_info) : '', + origin: 8, + }) + const queryRedirectPath = getCurLocation() + router.push({ path: queryRedirectPath }) + }) + .catch((e: any) => { + userStore.setToken('') + setTimeout(() => { + // logoutHandler(true, true) + platformLoginMsg.value = e?.message || e + setTimeout(() => { + window.location.href = + window.location.origin + window.location.pathname + window.location.hash + }, 2000) + }, 1500) + }) +} const dingtalkLogin = () => { const urlParams = getUrlParams() request @@ -661,6 +695,8 @@ onMounted(() => { wecomLogin() } else if (state?.includes('dingtalk')) { dingtalkLogin() + } else if (state?.includes('lark')) { + larkLogin() } else { auto2Platform() } diff --git a/frontend/src/views/login/xpack/LarkQr.vue b/frontend/src/views/login/xpack/LarkQr.vue new file mode 100644 index 00000000..c56d9904 --- /dev/null +++ b/frontend/src/views/login/xpack/LarkQr.vue @@ -0,0 +1,77 @@ + + + + diff --git a/frontend/src/views/login/xpack/PlatformClient.ts b/frontend/src/views/login/xpack/PlatformClient.ts index ea2b5f73..4a7100a3 100644 --- a/frontend/src/views/login/xpack/PlatformClient.ts +++ b/frontend/src/views/login/xpack/PlatformClient.ts @@ -101,14 +101,14 @@ const larkClientRequest = async () => { return } const res = await queryClientInfo(8) - if (!res?.appId) { - ElMessage.error('get appId error') + if (!res?.client_id) { + ElMessage.error('get client_id error') return } - const appId = res.data.appId + const clientId = res.client_id const callRequestAuthCode = () => { window['tt'].requestAuthCode({ - appId: appId, + appId: clientId, success: (res: any) => { const { code } = res const state = `fit2cloud-lark-client` @@ -122,7 +122,7 @@ const larkClientRequest = async () => { } if (window['tt'].requestAccess) { window['tt'].requestAccess({ - appID: appId, + appID: clientId, scopeList: [], success: (res: any) => { const { code } = res @@ -149,15 +149,15 @@ const larksuiteClientRequest = async () => { return } const res = await queryClientInfo(9) - if (!res?.data?.appId) { - ElMessage.error('get appId error') + if (!res?.client_id) { + ElMessage.error('get client_id error') return } - const appId = res.data.appId + const clientId = res.client_id window['h5sdk'].ready(() => { window['tt'].requestAuthCode({ - appId: appId, + appId: clientId, success(res: any) { const code = res?.code || res const state = `fit2cloud-larksuite-client` diff --git a/frontend/src/views/login/xpack/QrTab.vue b/frontend/src/views/login/xpack/QrTab.vue index 77e3a9c0..2c3d7d59 100644 --- a/frontend/src/views/login/xpack/QrTab.vue +++ b/frontend/src/views/login/xpack/QrTab.vue @@ -36,7 +36,7 @@ - {{ t('threshold.lark') }} + {{ t('user.lark') }}
@@ -60,8 +60,8 @@ import logo_wechatWork from '@/assets/svg/logo_wechat-work.svg' import logo_dingtalk from '@/assets/svg/logo_dingtalk.svg' import logo_lark from '@/assets/svg/logo_lark.svg' import { ref } from 'vue' -/* import LarkQr from './LarkQr.vue' -import LarksuiteQr from './LarksuiteQr.vue' */ +import LarkQr from './LarkQr.vue' +/* import LarksuiteQr from './LarksuiteQr.vue' */ import DingtalkQr from './DingtalkQr.vue' import WecomQr from './WecomQr.vue' import { propTypes } from '@/utils/propTypes' diff --git a/frontend/src/views/system/platform/common/SettingTemplate.ts b/frontend/src/views/system/platform/common/SettingTemplate.ts index a6487b0b..f0f64b34 100644 --- a/frontend/src/views/system/platform/common/SettingTemplate.ts +++ b/frontend/src/views/system/platform/common/SettingTemplate.ts @@ -70,49 +70,35 @@ export const settingMapping = { }, ], 8: [ - { - realKey: 'corpid', - pkey: 'CorpId', - pval: '', - type: 'text', - sort: 1, - }, { realKey: 'client_id', pkey: 'APP Key', pval: '', type: 'text', - sort: 2, + sort: 1, }, { realKey: 'client_secret', pkey: 'APP Secret', pval: '', type: 'pwd', - sort: 3, + sort: 2, }, ], 9: [ - { - realKey: 'corpid', - pkey: 'CorpId', - pval: '', - type: 'text', - sort: 1, - }, { realKey: 'client_id', pkey: 'APP Key', pval: '', type: 'text', - sort: 2, + sort: 1, }, { realKey: 'client_secret', pkey: 'APP Secret', pval: '', type: 'pwd', - sort: 3, + sort: 2, }, ], } as any @@ -134,13 +120,13 @@ export const cardMapping = { title: 'user.lark', icon: logo_lark, settingList: settingMapping[8], - copyField: ['CorpId', 'APP Secret'], + copyField: ['APP Key', 'APP Secret'], }, 9: { title: 'user.larksuite', icon: logo_lark, settingList: settingMapping[9], - copyField: ['CorpId', 'APP Secret'], + copyField: ['APP Key', 'APP Secret'], }, } as any diff --git a/frontend/src/views/system/platform/index.vue b/frontend/src/views/system/platform/index.vue index fc0aa1bf..f070ba0e 100644 --- a/frontend/src/views/system/platform/index.vue +++ b/frontend/src/views/system/platform/index.vue @@ -29,7 +29,7 @@ const loadData = () => { item.config = JSON.parse(item.config) return item }) - .filter((card: any) => card.type < 8) + .filter((card: any) => card.type < 9) }) } onMounted(() => {