Files
admin-ui/src/views/settings/workflow/component/PromptEditor.vue
T
2910410219 0e6381d2b3 1. 上游节点输出引用(核心功能)
- 新增 upstreamNodes computed:遍历当前选中节点的前驱链路,仅 model / http / form 三类节点被识别为有输出的节点
  - 新增 getNodeOutputFields,按节点类型提取可引用字段:
    - form → formConfig 的字段
    - http → response schema 的叶子字段
    - model → modelResponseBodyMapping(模型返回参数)的 key
    - 开始节点 → runFormFields(运行表单字段),从而让下游节点能引用"用户填的运行表单"作为输出

  2. 开始节点运行表单字段聚合
  - syncRunFormFields + 深监听:开始节点 formConfig 变化时自动聚合字段,存为 runFormFields,作为开始节点自身可被下游引用的输出

  3. 模型返回参数
  - handleModelConfirm 用 stripReadonlyFields 清理 requestBodyMapping 冗余字段,同时保存 modelResponseBodyMapping 供下游引用
  - 保存时 collectExposedFields 提取对外暴露字段存 modelFormFields

  4. 提示词 / 反向提示词
  - 保存 prompt、negativePrompt、runFormFields 到节点 DSL

  5. 其他
  - nodeTypes 用 markRaw 包裹 FlowNode,修复 Vue 警告
  - buildNodeFormConfigFromDsl 的 responseType 匹配改为兼容 key/value 两种取值
2026-08-12 17:26:58 +08:00

94 lines
2.1 KiB
Vue

<template>
<div class="prompt-editor">
<el-button type="primary" plain style="width: 100%" @click="visible = true">
<el-icon><EditPen /></el-icon>
{{ buttonText }}
</el-button>
<div v-if="modelValue" class="pe-filled">
<span class="pe-filled-text" :title="modelValue">{{ modelValue }}</span>
<el-button size="small" text type="danger" @click="clear">清除</el-button>
</div>
<el-dialog
v-model="visible"
:title="dialogTitle"
width="720px"
:close-on-click-modal="false"
destroy-on-close
append-to-body
>
<el-input v-model="draft" type="textarea" :rows="12" maxlength="5000" show-word-limit placeholder="请输入提示词内容" />
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="handleConfirm">确定</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { EditPen } from '@element-plus/icons-vue';
defineOptions({ name: 'PromptEditor' });
const props = withDefaults(
defineProps<{
modelValue?: string;
buttonText?: string;
dialogTitle?: string;
}>(),
{
modelValue: '',
buttonText: '编辑提示词',
dialogTitle: '编辑提示词',
}
);
const emit = defineEmits<{ (e: 'update:modelValue', value: string): void }>();
const visible = ref(false);
const draft = ref('');
// 打开弹窗时同步当前值,关闭时丢弃未确认的草稿
watch(visible, (val) => {
if (val) draft.value = props.modelValue || '';
});
const handleConfirm = () => {
emit('update:modelValue', draft.value.trim());
visible.value = false;
};
const clear = () => {
emit('update:modelValue', '');
};
</script>
<style scoped lang="scss">
.prompt-editor {
width: 100%;
.pe-filled {
display: flex;
align-items: center;
gap: 6px;
margin-top: 6px;
background: #f0f9ff;
border: 1px solid #bae6fd;
border-radius: 4px;
padding: 4px 8px;
.pe-filled-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 12px;
color: #0369a1;
}
}
}
</style>