From ccef63a40b1fe6a43fdd918b3cb3d4186dddcd42 Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 25 Sep 2025 08:51:09 +0800 Subject: [PATCH] * [story #77918] suppport showing diff view in ai tool calling result. --- module/aiapp/lang/zh-cn.php | 5 +++++ www/js/zui3/ai.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/module/aiapp/lang/zh-cn.php b/module/aiapp/lang/zh-cn.php index afe7249e1b..11aaed61c4 100644 --- a/module/aiapp/lang/zh-cn.php +++ b/module/aiapp/lang/zh-cn.php @@ -67,3 +67,8 @@ $lang->aiapp->langData->globalMemoryTitle = '禅道'; $lang->aiapp->langData->zaiConfigNotValid = '尚未进行ZAI配置,请联系管理员进行ZAI配置。
若已完成相关配置,请尝试重新加载页面。'; $lang->aiapp->langData->unauthorizedError = '授权失败,无效的 API 密钥,请联系管理员进行ZAI配置。
若已完成相关配置,请尝试重新加载页面。'; $lang->aiapp->langData->applyFormFormat = '应用到%s表单'; +$lang->aiapp->langData->beforeChange = '变更前'; +$lang->aiapp->langData->afterChange = '变更后'; +$lang->aiapp->langData->changeProp = '属性'; +$lang->aiapp->langData->changeTitleFormat = '变更{type} #{id}'; +$lang->aiapp->langData->applyFormSuccess = '已成功应用到%s表单'; diff --git a/www/js/zui3/ai.js b/www/js/zui3/ai.js index dae9d4dd16..52f8f9c14f 100644 --- a/www/js/zui3/ai.js +++ b/www/js/zui3/ai.js @@ -49,7 +49,38 @@ window.executeZentaoPrompt = async function(info) const langData = zaiPanel.options.langData || {}; const applyFormFormat = langData.applyFormFormat; + const originObject = info.object && info.object[info.objectType]; + const propNames = info.dataPropNames ? (info.dataPropNames[info.objectType] || {}) : {}; + let diffView = null; + if(originObject) + { + const h = zui.html; + const renderProp = (prop, value) => { + let oldValue = originObject[prop]; + if(typeof oldValue === 'string' && oldValue.length) oldValue = $('
').html(oldValue).text(); + const isSame = oldValue === value; + return h` + ${propNames[prop] || prop} + ${value} + ${oldValue} +`; + }; + diffView = h`
${zui.formatString(langData.changeTitleFormat, {type: propNames.common || info.objectType, id: info.objectID})}
+ + + + + + + + + + ${Object.entries(result).map(entry => renderProp(entry[0], entry[1]))} + +
${langData.changeProp}${langData.afterChange}${langData.beforeChange}
`; + } return { + view: diffView, actions: [{ text : (applyFormFormat || '%s').replace('%s', info.targetFormName || info.targetForm), onClick : () => openPageForm(info.formLocation, result, () => zui.Messager.success(langData.applyFormSuccess.replace('%s', info.targetFormName || info.targetForm))),