完成演示demo
This commit is contained in:
@@ -237,6 +237,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { FlowNode } from "~/components/flow-nodes/nodes";
|
||||
import { open, save } from "@tauri-apps/plugin-dialog";
|
||||
import { readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";
|
||||
import {
|
||||
ArrowLeft,
|
||||
Clock,
|
||||
@@ -266,8 +268,8 @@
|
||||
getNodesByCategory,
|
||||
nodeDefinitions
|
||||
} from "~/components/flow-nodes/nodes";
|
||||
import { save, open } from '@tauri-apps/plugin-dialog';
|
||||
import { writeTextFile, readTextFile } from '@tauri-apps/plugin-fs';
|
||||
// import { toast } from "#build/ui";
|
||||
const toast = useToast();
|
||||
|
||||
const router = useRouter();
|
||||
const workflowNodes = ref<FlowNode[]>([]);
|
||||
@@ -377,6 +379,11 @@
|
||||
const startTask = () => {
|
||||
if (workflowNodes.value.length === 0) {
|
||||
console.log("请先添加任务节点");
|
||||
toast.add({
|
||||
title: "任务异常",
|
||||
description: "当前任务清单并无任何节点,请先添加节点。",
|
||||
color: "warning"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -399,6 +406,11 @@
|
||||
console.log("完整JSON数据:");
|
||||
console.log(JSON.stringify(taskData, null, 2));
|
||||
console.log("=== 执行完成 ===");
|
||||
toast.add({
|
||||
title: "任务执行成功",
|
||||
description: `总共执行了 ${taskData.nodes.length} 个节点。`,
|
||||
color: "success"
|
||||
});
|
||||
};
|
||||
|
||||
const saveTask = async () => {
|
||||
@@ -423,8 +435,8 @@
|
||||
try {
|
||||
const filePath = await save({
|
||||
filters: [{
|
||||
name: 'JSON',
|
||||
extensions: ['json']
|
||||
name: "JSON",
|
||||
extensions: ["json"]
|
||||
}],
|
||||
defaultPath: `workflow_${Date.now()}.json`
|
||||
});
|
||||
@@ -447,22 +459,22 @@
|
||||
const selected = await open({
|
||||
multiple: false,
|
||||
filters: [{
|
||||
name: 'JSON',
|
||||
extensions: ['json']
|
||||
name: "JSON",
|
||||
extensions: ["json"]
|
||||
}]
|
||||
});
|
||||
|
||||
if (selected) {
|
||||
const content = await readTextFile(selected as string);
|
||||
const data = JSON.parse(content);
|
||||
|
||||
|
||||
if (data.nodes && Array.isArray(data.nodes)) {
|
||||
// 验证并重建节点
|
||||
const importedNodes = data.nodes.map((node: any) => {
|
||||
// 提取原始节点ID(去除时间戳后缀)
|
||||
const originalId = node.id.replace(/-\d+-[a-z0-9]+$/, '');
|
||||
const originalId = node.id.replace(/-\d+-[a-z0-9]+$/, "");
|
||||
const definition = nodeDefinitions[originalId];
|
||||
|
||||
|
||||
if (!definition) {
|
||||
console.warn(`未找到节点定义: ${originalId}`);
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user