fix: 修复工作流入口标题与提示词校验
- 支持系统入口标题清空占位与下游引用展示同步 - 降低字段编辑触发的节点图重算和无效渲染 - 在保存及执行前拦截空白的大模型用户提示词
This commit is contained in:
@@ -52,9 +52,10 @@
|
||||
return param.formType ? [param.formType] : [];
|
||||
});
|
||||
let parameterNameDraft = $state<string | null>(null);
|
||||
let systemLabelDraft = $state<string | null>(null);
|
||||
let displayParamName = $derived.by(() => {
|
||||
if (isSystemStartParam) {
|
||||
return '用户问题';
|
||||
return systemLabelDraft ?? trimString(param.formLabel);
|
||||
}
|
||||
return parameterNameDraft ?? param.name;
|
||||
});
|
||||
@@ -76,6 +77,8 @@
|
||||
|
||||
const applyStartFieldPatch = (fieldKey: string, patch: Record<string, any>) => {
|
||||
const currentFieldId = trimString(param.id);
|
||||
const shouldSyncReferences = Object.prototype.hasOwnProperty.call(patch, 'key')
|
||||
|| Object.prototype.hasOwnProperty.call(patch, 'label');
|
||||
store.updateNodes((nodes) => {
|
||||
const edges = store.getEdges();
|
||||
let nextFieldKey = fieldKey;
|
||||
@@ -98,6 +101,9 @@
|
||||
}
|
||||
};
|
||||
});
|
||||
if (!shouldSyncReferences) {
|
||||
return nextNodes;
|
||||
}
|
||||
return renameStartFieldReferencesInNodes(
|
||||
nextNodes,
|
||||
edges,
|
||||
@@ -172,11 +178,11 @@
|
||||
const updateName = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const newValue = input.value;
|
||||
parameterNameDraft = newValue;
|
||||
if (isStartNodeInputParam) {
|
||||
const normalizedValue = trimString(newValue);
|
||||
if (!normalizedValue) {
|
||||
parameterNameError = '参数名不能为空';
|
||||
parameterNameDraft = newValue;
|
||||
return;
|
||||
}
|
||||
if (!isStartFormFieldKeyAvailable(
|
||||
@@ -185,13 +191,66 @@
|
||||
normalizedValue
|
||||
)) {
|
||||
parameterNameError = '参数名已存在';
|
||||
parameterNameDraft = newValue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
parameterNameError = '';
|
||||
};
|
||||
|
||||
const updateVisibleName = (event: Event) => {
|
||||
if (isSystemStartParam) {
|
||||
systemLabelDraft = (event.target as HTMLInputElement).value;
|
||||
return;
|
||||
}
|
||||
updateName(event);
|
||||
};
|
||||
|
||||
const commitName = () => {
|
||||
if (parameterNameDraft === null) {
|
||||
return;
|
||||
}
|
||||
const draftValue = parameterNameDraft;
|
||||
if (isStartNodeInputParam) {
|
||||
const normalizedValue = trimString(draftValue);
|
||||
if (!normalizedValue) {
|
||||
parameterNameError = '参数名不能为空';
|
||||
return;
|
||||
}
|
||||
if (!isStartFormFieldKeyAvailable(
|
||||
node?.current?.data as Record<string, any>,
|
||||
param.name || '',
|
||||
normalizedValue
|
||||
)) {
|
||||
parameterNameError = '参数名已存在';
|
||||
return;
|
||||
}
|
||||
parameterNameDraft = null;
|
||||
parameterNameError = '';
|
||||
if (normalizedValue !== trimString(param.name)) {
|
||||
updateParameter('name', normalizedValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
parameterNameDraft = null;
|
||||
parameterNameError = '';
|
||||
updateParameter('name', newValue);
|
||||
if (draftValue !== (param.name || '')) {
|
||||
updateParameter('name', draftValue);
|
||||
}
|
||||
};
|
||||
|
||||
const commitVisibleName = () => {
|
||||
if (!isSystemStartParam) {
|
||||
commitName();
|
||||
return;
|
||||
}
|
||||
if (systemLabelDraft === null) {
|
||||
return;
|
||||
}
|
||||
const nextLabel = trimString(systemLabelDraft);
|
||||
systemLabelDraft = null;
|
||||
if (nextLabel !== trimString(param.formLabel)) {
|
||||
updateParameter('formLabel', nextLabel);
|
||||
}
|
||||
};
|
||||
|
||||
const updateRequired = (event: Event) => {
|
||||
@@ -236,11 +295,13 @@
|
||||
|
||||
|
||||
<div class="input-item input-item-name">
|
||||
<Input style="width: 100%;" value={displayParamName} placeholder="请输入参数名称"
|
||||
disabled={param.nameDisabled === true}
|
||||
<Input style="width: 100%;" value={displayParamName}
|
||||
placeholder={isSystemStartParam ? '用户问题' : '请输入参数名称'}
|
||||
disabled={isSystemStartParam ? false : param.nameDisabled === true}
|
||||
aria-invalid={parameterNameError ? 'true' : undefined}
|
||||
aria-describedby={parameterNameError ? parameterNameErrorId : undefined}
|
||||
oninput={updateName} />
|
||||
oninput={updateVisibleName}
|
||||
onchange={commitVisibleName} />
|
||||
{#if parameterNameError}
|
||||
<div id={parameterNameErrorId} class="input-error" role="alert">
|
||||
{parameterNameError}
|
||||
@@ -296,7 +357,7 @@
|
||||
数据标题:
|
||||
<Textarea rows={1} style="width: 100%;" onchange={(event)=>{
|
||||
updateParamByEvent('formLabel', event)
|
||||
}} value={param.formLabel} />
|
||||
}} value={param.formLabel} placeholder={isSystemStartParam ? '用户问题' : undefined} />
|
||||
</div>
|
||||
|
||||
<div class="input-more-item">
|
||||
|
||||
Reference in New Issue
Block a user