完成演示demo

This commit is contained in:
2025-08-22 15:14:05 +08:00
parent fc2e48c6b0
commit f743f67454
20 changed files with 60 additions and 81 deletions

View File

@@ -32,11 +32,11 @@ The fix involves correcting the vuedraggable configuration to properly support:
```typescript
const cloneNode = (original: FlowNode): FlowNode => {
return {
...original,
id: `${original.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
config: original.config ? { ...original.config } : undefined
};
return {
...original,
id: `${original.id}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
config: original.config ? { ...original.config } : undefined
};
};
```
@@ -53,16 +53,16 @@ const cloneNode = (original: FlowNode): FlowNode => {
### FlowNode Interface (Existing)
```typescript
interface FlowNode {
id: string; // Unique identifier
name: string; // Display name
type: string; // Node type category
taskId: string; // Task execution identifier
icon: string; // Icon name
backgroundColor: string;
shape: "square" | "circle" | "rounded";
textColor: string;
category: "控制类" | "设备类" | "媒体类" | "灯光类" | "延时类";
config?: Record<string, any>;
id: string // Unique identifier
name: string // Display name
type: string // Node type category
taskId: string // Task execution identifier
icon: string // Icon name
backgroundColor: string
shape: "square" | "circle" | "rounded"
textColor: string
category: "控制类" | "设备类" | "媒体类" | "灯光类" | "延时类"
config?: Record<string, any>
}
```
@@ -152,4 +152,4 @@ const workflowNodes = ref<FlowNode[]>([]);
- Use efficient ID generation to avoid blocking
- Minimize re-renders during drag operations
- Optimize large workflow handling
- Cache node definitions for better performance
- Cache node definitions for better performance

View File

@@ -47,4 +47,4 @@ This feature addresses the drag and drop functionality issue in the existing wor
1. WHEN I start dragging a node THEN the system SHALL provide visual feedback indicating drag state
2. WHEN I hover over a valid drop zone THEN the system SHALL highlight the drop zone
3. WHEN I hover over an invalid drop zone THEN the system SHALL indicate the zone is not droppable
4. WHEN dragging is in progress THEN the cursor SHALL change to indicate drag operation
4. WHEN dragging is in progress THEN the cursor SHALL change to indicate drag operation

View File

@@ -97,3 +97,9 @@
- Initialize dialog plugin in lib.rs
- Remove invalid configuration fields that caused startup errors
- _Requirements: 2.1, 3.1_
- [x] 8. Fix Tauri 2.0 permissions configuration structure
- Move permissions to app section in tauri.conf.json (not root level)
- Add dialog plugin to plugins section
- Resolve "Additional properties are not allowed" configuration error
- Ensure proper Tauri 2.0 configuration format compliance
- _Requirements: 2.1, 3.1_

View File

@@ -1,8 +1,8 @@
export default defineAppConfig({
app: {
name: "Nuxtor",
author: "Nicola Spadari",
repo: "https://github.com/NicolaSpadari/nuxtor",
name: "PlayTool-Demo",
author: "Estel",
repo: "https://github.com/estel-li",
tauriSite: "https://tauri.app",
nuxtSite: "https://nuxt.com",
nuxtUiSite: "https://ui.nuxt.dev"

View File

@@ -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;

View File

@@ -1,9 +1,6 @@
<template>
<div>
<SiteNavbar class="fixed w-full" />
<SiteSidebar />
<div class="relative overflow-hidden px-6 lg:px-8">
<div>
<DesignTopBlob />
<DesignBottomBlob />

View File

@@ -3,50 +3,11 @@
<div class="grid size-full place-content-center gap-y-8">
<SvgoLogo :filled="true" :font-controlled="false" class="mx-auto size-40" />
<div class="flex flex-col items-center gap-y-3">
<h1 class="animate-pulse text-3xl sm:text-4xl text-pretty font-bold font-heading md:mb-5">
{{ app.name.toUpperCase() }}
</h1>
<p class="leading-7 text-pretty">
Powered by
</p>
<div class="flex flex-wrap justify-center gap-1 md:gap-3">
<UButton
variant="ghost"
size="xl"
:to="app.nuxtSite"
target="_blank"
external
>
Nuxt 4
</UButton>
<UButton
variant="ghost"
size="xl"
:to="app.tauriSite"
target="_blank"
external
>
Tauri 2
</UButton>
<UButton
variant="ghost"
size="xl"
:to="app.nuxtUiSite"
target="_blank"
external
>
NuxtUI 3
</UButton>
</div>
</div>
<div class="flex justify-center">
<UButton
to="/workflows"
>
Star on GitHub
开始演示
</UButton>
</div>
</div>

View File

@@ -25,7 +25,7 @@
"dependencies": {
"@nuxt/ui-pro": "^3.2.0",
"@tauri-apps/api": "^2.6.0",
"@tauri-apps/plugin-dialog": "^2.3.0",
"@tauri-apps/plugin-dialog": "~2",
"@tauri-apps/plugin-fs": "^2.4.0",
"@tauri-apps/plugin-notification": "^2.3.0",
"@tauri-apps/plugin-os": "^2.3.0",

2
pnpm-lock.yaml generated
View File

@@ -18,7 +18,7 @@ importers:
specifier: ^2.6.0
version: 2.6.0
'@tauri-apps/plugin-dialog':
specifier: ^2.3.0
specifier: ~2
version: 2.3.3
'@tauri-apps/plugin-fs':
specifier: ^2.4.0

View File

@@ -24,7 +24,7 @@ tauri-plugin-shell = "2.3.0"
tauri-plugin-notification = "2.3.0"
tauri-plugin-os = "2.3.0"
tauri-plugin-fs = "2.4.0"
tauri-plugin-dialog = "2.3.0"
tauri-plugin-dialog = "2"
tauri-plugin-store = "2.3.0"
serde_json = "1"

View File

@@ -41,6 +41,9 @@
"fs:allow-document-write",
"store:default",
"core:webview:allow-create-webview",
"core:webview:allow-create-webview-window"
"core:webview:allow-create-webview-window",
"dialog:default",
"dialog:default",
"dialog:default"
]
}

View File

@@ -1 +1 @@
{"main":{"identifier":"main","description":"Capabilities for the app window","local":true,"windows":["main","secondary"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","shell:allow-open",{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"notification:default","os:allow-platform","os:allow-arch","os:allow-family","os:allow-version","os:allow-locale","fs:allow-document-read","fs:allow-document-write","store:default","core:webview:allow-create-webview","core:webview:allow-create-webview-window"]}}
{"main":{"identifier":"main","description":"Capabilities for the app window","local":true,"windows":["main","secondary"],"permissions":["core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","shell:allow-open",{"identifier":"shell:allow-execute","allow":[{"args":["-c",{"validator":"\\S+"}],"cmd":"sh","name":"exec-sh","sidecar":false}]},"notification:default","os:allow-platform","os:allow-arch","os:allow-family","os:allow-version","os:allow-locale","fs:allow-document-read","fs:allow-document-write","store:default","core:webview:allow-create-webview","core:webview:allow-create-webview-window","dialog:default","dialog:default","dialog:default"]}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -41,9 +41,9 @@
"title": "Nuxtor",
"width": 1366,
"height": 768,
"minWidth": 375,
"minHeight": 812,
"resizable": false,
"minWidth": 800,
"minHeight": 600,
"resizable": true,
"fullscreen": false
}
],