From d5c2c0d01518e74f845f800e065b434c3dc9192a Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 16 Oct 2026 11:19:13 +0800 Subject: [PATCH] feat: enhance AccessSettingDrawer and EditSCANDrawer with dynamic connection mode handling and callback URL display --- .../access/AccessSettingDrawer.vue | 39 +++++++++++-- .../application-detail/access/platforms.ts | 27 ++++++++- .../authentication/EditSCANDrawer.vue | 21 ++++++- .../authentication/components/SCANLogin.vue | 58 ++++++------------- .../authentication/EditSCANDrawer.vue | 21 ++++++- .../authentication/components/SCANLogin.vue | 7 +-- 6 files changed, 117 insertions(+), 56 deletions(-) diff --git a/ui/src/views/application-detail/access/AccessSettingDrawer.vue b/ui/src/views/application-detail/access/AccessSettingDrawer.vue index 0ebcf9a4559..50600cb8fb7 100644 --- a/ui/src/views/application-detail/access/AccessSettingDrawer.vue +++ b/ui/src/views/application-detail/access/AccessSettingDrawer.vue @@ -20,11 +20,19 @@ const isCertification = ref(false) let savedConfig: ApplicationAccessConfig = {} const isWechat = computed(() => props.platform.key === APPLICATION_ACCESS_PLATFORM.WECHAT) +const modeField = computed(() => props.platform.modeField) +// 表单字段随连接方式切换:长连接(ws)需要 bot_id/secret,URL 回调(callback)需要 token/encoding_aes_key。 +const activeFields = computed(() => { + const mode = form[modeField.value?.key ?? ''] ?? modeField.value?.default + return (modeField.value && mode ? modeField.value.fields?.[mode] : undefined) ?? props.platform.fields +}) +// 智能机器人默认长连接(ws),无需回调地址;切到 URL 回调时才展示回调地址。 +const showCallback = computed(() => !modeField.value || form[modeField.value.key] === 'callback') // 消息回调沿用 Admin API 下的 /chat 路径,不使用独立 Chat 入口的 API base。 const callbackUrl = computed(() => `${window.location.origin}${ADMIN_API_BASE_PATH}/chat/${props.platform.key}/${props.applicationId}`) const rules = computed(() => Object.fromEntries( - props.platform.fields + activeFields.value .filter((field) => field.required !== false) .map((field) => [field.key, [{ required: true, whitespace: true, message: `请输入 ${field.label}`, trigger: 'blur' }]]), ), @@ -36,7 +44,8 @@ function loadPlatformConfig() { return AccessApi.getPlatformConfig(props.applicationId, props.platform.key) .then((config) => { savedConfig = config ?? {} - props.platform.fields.forEach((field) => { + if (modeField.value) form[modeField.value.key] = String(savedConfig[modeField.value.key] ?? modeField.value.default) + activeFields.value.forEach((field) => { form[field.key] = String(savedConfig[field.key] ?? '') }) isCertification.value = savedConfig.is_certification ?? false @@ -73,7 +82,29 @@ onMounted(loadPlatformConfig)
-