* [story #77918] suppport showing diff view in ai tool calling result.
This commit is contained in:
@@ -67,3 +67,8 @@ $lang->aiapp->langData->globalMemoryTitle = '禅道';
|
||||
$lang->aiapp->langData->zaiConfigNotValid = '尚未进行ZAI配置,请联系管理员进行<a href="{zaiConfigUrl}">ZAI配置</a>。<br>若已完成相关配置,请尝试重新加载页面。';
|
||||
$lang->aiapp->langData->unauthorizedError = '授权失败,无效的 API 密钥,请联系管理员进行<a href="{zaiConfigUrl}">ZAI配置</a>。<br>若已完成相关配置,请尝试重新加载页面。';
|
||||
$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表单';
|
||||
|
||||
@@ -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 = $('<div/>').html(oldValue).text();
|
||||
const isSame = oldValue === value;
|
||||
return h`<tr class="whitespace-pre-wrap">
|
||||
<td class=${isSame ? 'text-gray' : 'font-bold'}>${propNames[prop] || prop}</td>
|
||||
<td class=${isSame ? '' : 'success-pale'}>${value}</td>
|
||||
<td class=${isSame ? '' : 'danger-pale'}>${oldValue}</td>
|
||||
</tr>`;
|
||||
};
|
||||
diffView = h`<h6>${zui.formatString(langData.changeTitleFormat, {type: propNames.common || info.objectType, id: info.objectID})}</h6>
|
||||
<table class="table bordered" style="min-width: 600px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 100px;">${langData.changeProp}</th>
|
||||
<th>${langData.afterChange}</th>
|
||||
<th>${langData.beforeChange}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${Object.entries(result).map(entry => renderProp(entry[0], entry[1]))}
|
||||
</tbody>
|
||||
</table>`;
|
||||
}
|
||||
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))),
|
||||
|
||||
Reference in New Issue
Block a user