更新模型选择器以支持更多模型类型,重构输入栏以移除快捷指令和工作流功能,新增工作空间功能以支持文件预览和下载,优化工作流组件以增强节点数据处理的可选性和安全性。

This commit is contained in:
2026-05-29 14:20:27 +08:00
parent 78d1fd93c8
commit 538e153473
6 changed files with 356 additions and 107 deletions

View File

@@ -120,6 +120,7 @@ const emit = defineEmits<{
margin-bottom: 8px;
padding-bottom: 4px;
border-bottom: 1px solid #e7ecf3;
padding-left: 2px;
}
.node-group-items {
@@ -129,9 +130,10 @@ const emit = defineEmits<{
}
.node-item {
justify-content: flex-start;
justify-content: flex-start !important;
width: 100%;
padding: 8px 10px;
padding: 0 !important;
margin: 0 !important;
color: #475569;
border-radius: 6px;
font-size: 13px;
@@ -139,11 +141,24 @@ const emit = defineEmits<{
background: transparent;
border: none;
transition: all 0.15s ease;
text-align: left !important;
min-height: 34px;
height: auto !important;
display: block !important;
&:hover {
background: #f1f5f9;
color: #1e293b;
}
:deep(.el-button__inner) {
width: 100%;
padding: 8px !important;
margin: 0 !important;
text-align: left !important;
justify-content: flex-start !important;
display: block !important;
}
}
}
</style>

View File

@@ -5,7 +5,6 @@
<el-tab-pane label="我的工作流" name="user"></el-tab-pane>
<el-tab-pane label="模板工作流" name="template"></el-tab-pane>
</el-tabs>
<el-button type="success" size="small" @click="emit('create')">新建</el-button>
</div>
<div class="workflow-list-content" v-loading="loading">
<el-empty v-if="currentList.length === 0" description="暂无工作流" :image-size="60" />
@@ -65,7 +64,6 @@ const currentList = computed(() => {
flex-direction: column;
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
border: 1px solid #e6eaf0;
}
.panel-header {
display: flex;
@@ -188,4 +186,5 @@ const currentList = computed(() => {
padding: 4px 8px;
}
}
}
</style>

View File

@@ -126,7 +126,7 @@ interface ParamRef {
label: string;
}
const { addNodes, addEdges, findNode, removeNodes, getNodes } = useVueFlow();
const { addNodes, addEdges, findNode, removeNodes, getNodes, updateNode } = useVueFlow();
// 常量定义
const START_NODE_CODE = '__start__';
@@ -254,6 +254,8 @@ const onNodeClick = (event: { node: Node<NodeData, any, string> }) => {
const updateSelectedNode = (updatedNode: Node<NodeData, any, string>) => {
selectedNode.value = updatedNode;
// 使用 VueFlow 的 API 更新节点,确保内部状态同步
updateNode(updatedNode.id, updatedNode);
// 同步更新到 nodes 数组
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
@@ -284,29 +286,47 @@ const availableParams = computed(() => {
const addParam = (param: ParamRef) => {
if (!selectedNode.value?.data) return;
if (!selectedNode.value.data.inputSource) {
selectedNode.value.data.inputSource = [];
}
const updatedNode: Node<NodeData> = {
...selectedNode.value,
data: {
...selectedNode.value.data,
inputSource: selectedNode.value.data.inputSource || [],
},
};
// 查找是否已存在该节点的引用
const existingIndex = selectedNode.value.data.inputSource.findIndex((item) => item.nodeId === param.id);
const existingIndex = updatedNode.data.inputSource!.findIndex((item) => item.nodeId === param.id);
if (existingIndex >= 0) {
// 已存在,添加 output 到 field 数组
const existing = selectedNode.value.data.inputSource[existingIndex];
const existing = updatedNode.data.inputSource![existingIndex];
if (!existing.field.includes('output')) {
existing.field.push('output');
selectedNode.value = updatedNode;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
nodes.value[index] = updatedNode;
}
ElMessage.success('已添加参数引用');
} else {
ElMessage.info('该参数已被引用');
}
} else {
// 不存在,创建新的引用
selectedNode.value.data.inputSource.push({
updatedNode.data.inputSource!.push({
nodeId: param.id,
field: ['output'],
quoteOutput: false,
});
selectedNode.value = updatedNode;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
nodes.value[index] = updatedNode;
}
ElMessage.success('已添加参数引用');
}
};
@@ -330,6 +350,8 @@ const handleModelConfirm = (model: any) => {
selectedNode.value = updatedNode;
selectedModelData.value = model;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
@@ -353,6 +375,8 @@ const handleRemoveModel = () => {
selectedNode.value = updatedNode;
selectedModelData.value = null;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
@@ -376,6 +400,8 @@ const handleSkillConfirm = (skill: any) => {
selectedNode.value = updatedNode;
selectedSkillData.value = skill;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
@@ -399,6 +425,8 @@ const handleRemoveSkill = () => {
selectedNode.value = updatedNode;
selectedSkillData.value = null;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
@@ -436,6 +464,8 @@ const handleRemoveField = (nodeId: string, fieldName: string) => {
};
selectedNode.value = updatedNode;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
nodes.value[index] = updatedNode;
@@ -478,6 +508,8 @@ const handleToggleOutput = (nodeId: string, enabled: boolean) => {
};
selectedNode.value = updatedNode;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
nodes.value[index] = updatedNode;
@@ -534,6 +566,8 @@ const handleAddParamByValue = (paramValue: string) => {
};
selectedNode.value = updatedNode;
// 同步更新到 VueFlow 内部状态
updateNode(updatedNode.id, updatedNode);
const index = nodes.value.findIndex((n) => n.id === updatedNode.id);
if (index >= 0) {
nodes.value[index] = updatedNode;
@@ -652,15 +686,15 @@ const fetchWorkflowList = async () => {
// 添加默认开始节点
const addDefaultStartNode = () => {
addNodes([
{
id: 'start-node',
type: 'input',
position: { x: 200, y: 200 },
data: { label: '开始', nodeCode: '__start__', inputSource: null },
style: { background: '#10b981', color: '#fff', border: '2px solid #059669', borderRadius: '8px', padding: '10px 20px' },
},
]);
const startNode = {
id: 'start-node',
type: 'input',
position: { x: 200, y: 200 },
data: { label: '开始', nodeCode: '__start__', inputSource: null },
style: { background: '#10b981', color: '#fff', border: '2px solid #059669', borderRadius: '8px', padding: '10px 20px' },
};
addNodes([startNode]);
nodes.value.push(startNode);
};
// 新建工作流