From effe37fa6ceb262e8fa7f84907e994e33bb92988 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Wed, 26 Feb 2025 11:30:04 +0800 Subject: [PATCH] fix: URL encoding parameters not decompiled (#2409) --- .../ai-chat/component/user-form/index.vue | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ui/src/components/ai-chat/component/user-form/index.vue b/ui/src/components/ai-chat/component/user-form/index.vue index 2744102af..b2c89a0e4 100644 --- a/ui/src/components/ai-chat/component/user-form/index.vue +++ b/ui/src/components/ai-chat/component/user-form/index.vue @@ -286,18 +286,42 @@ const checkInputParam = () => { let msg = [] for (let f of apiInputFieldList.value) { if (!api_form_data_context.value[f.field]) { - api_form_data_context.value[f.field] = route.query[f.field] + let _value = route.query[f.field] + if (_value != null) { + if (_value instanceof Array) { + _value = _value + .map((item) => { + if (item != null) { + return decodeQuery(item) + } + return null + }) + .filter((item) => item != null) + } else { + _value = decodeQuery(_value) + } + api_form_data_context.value[f.field] = _value + } } if (f.required && !api_form_data_context.value[f.field]) { msg.push(f.field) } } if (msg.length > 0) { - MsgWarning(`${t('chat.tip.inputParamMessage1')} ${msg.join('、')}${t('chat.tip.inputParamMessage2')}`) + MsgWarning( + `${t('chat.tip.inputParamMessage1')} ${msg.join('、')}${t('chat.tip.inputParamMessage2')}` + ) return false } return true } +const decodeQuery = (query: string) => { + try { + return decodeURIComponent(query) + } catch (e) { + return query + } +} defineExpose({ checkInputParam }) onMounted(() => { handleInputFieldList()