Skip to content

Commit 0a7fa75

Browse files
shaohuzhang1liuruibin
authored andcommitted
feat: The sendMessage function in html_rander supports passing interface/user input parameters (#6205)
1 parent b9cda5f commit 0a7fa75

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

ui/src/components/ai-chat/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,10 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean, other_para
719719
...api_form_data.value,
720720
},
721721
}
722+
723+
if (other_params_data && other_params_data.form_data) {
724+
obj.form_data = { ...obj.form_data, ...other_params_data.form_data }
725+
}
722726
// 对话
723727
getChatMessageAPI()(chartOpenId.value, obj)
724728
.then((response) => {

ui/src/components/markdown/HtmlRander.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ ${sourceHtml}
8181
<script>
8282
const INSTANCE_ID = '${instanceId}';
8383
84-
function sendMessage(message) {
85-
parent.postMessage({ type: 'chatMessage', instanceId: INSTANCE_ID, message }, '*');
84+
function sendMessage(message,other_params_data) {
85+
parent.postMessage({ type: 'chatMessage', instanceId: INSTANCE_ID, message,other_params_data }, '*');
8686
}
8787
let lastSentHeight = 0;
8888
let timer = null;
@@ -125,7 +125,7 @@ function onMessage(e: MessageEvent) {
125125
window.open(e.data.url, '_blank')
126126
}
127127
if (e.data.type === 'chatMessage') {
128-
props.sendMessage?.(e.data.message, 'new')
128+
props.sendMessage?.(e.data.message, 'new', e.data.other_params_data)
129129
}
130130
if (e.data?.type === 'chatUserProfile') {
131131
const iframe = htmlRef.value

0 commit comments

Comments
 (0)