完成演示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

@@ -53,16 +53,16 @@ const cloneNode = (original: FlowNode): FlowNode => {
### FlowNode Interface (Existing) ### FlowNode Interface (Existing)
```typescript ```typescript
interface FlowNode { interface FlowNode {
id: string; // Unique identifier id: string // Unique identifier
name: string; // Display name name: string // Display name
type: string; // Node type category type: string // Node type category
taskId: string; // Task execution identifier taskId: string // Task execution identifier
icon: string; // Icon name icon: string // Icon name
backgroundColor: string; backgroundColor: string
shape: "square" | "circle" | "rounded"; shape: "square" | "circle" | "rounded"
textColor: string; textColor: string
category: "控制类" | "设备类" | "媒体类" | "灯光类" | "延时类"; category: "控制类" | "设备类" | "媒体类" | "灯光类" | "延时类"
config?: Record<string, any>; config?: Record<string, any>
} }
``` ```

View File

@@ -97,3 +97,9 @@
- Initialize dialog plugin in lib.rs - Initialize dialog plugin in lib.rs
- Remove invalid configuration fields that caused startup errors - Remove invalid configuration fields that caused startup errors
- _Requirements: 2.1, 3.1_ - _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({ export default defineAppConfig({
app: { app: {
name: "Nuxtor", name: "PlayTool-Demo",
author: "Nicola Spadari", author: "Estel",
repo: "https://github.com/NicolaSpadari/nuxtor", repo: "https://github.com/estel-li",
tauriSite: "https://tauri.app", tauriSite: "https://tauri.app",
nuxtSite: "https://nuxt.com", nuxtSite: "https://nuxt.com",
nuxtUiSite: "https://ui.nuxt.dev" nuxtUiSite: "https://ui.nuxt.dev"

View File

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

View File

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

View File

@@ -3,50 +3,11 @@
<div class="grid size-full place-content-center gap-y-8"> <div class="grid size-full place-content-center gap-y-8">
<SvgoLogo :filled="true" :font-controlled="false" class="mx-auto size-40" /> <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"> <div class="flex justify-center">
<UButton <UButton
to="/workflows" to="/workflows"
> >
Star on GitHub 开始演示
</UButton> </UButton>
</div> </div>
</div> </div>

View File

@@ -25,7 +25,7 @@
"dependencies": { "dependencies": {
"@nuxt/ui-pro": "^3.2.0", "@nuxt/ui-pro": "^3.2.0",
"@tauri-apps/api": "^2.6.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-fs": "^2.4.0",
"@tauri-apps/plugin-notification": "^2.3.0", "@tauri-apps/plugin-notification": "^2.3.0",
"@tauri-apps/plugin-os": "^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 specifier: ^2.6.0
version: 2.6.0 version: 2.6.0
'@tauri-apps/plugin-dialog': '@tauri-apps/plugin-dialog':
specifier: ^2.3.0 specifier: ~2
version: 2.3.3 version: 2.3.3
'@tauri-apps/plugin-fs': '@tauri-apps/plugin-fs':
specifier: ^2.4.0 specifier: ^2.4.0

View File

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

View File

@@ -41,6 +41,9 @@
"fs:allow-document-write", "fs:allow-document-write",
"store:default", "store:default",
"core:webview:allow-create-webview", "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", "title": "Nuxtor",
"width": 1366, "width": 1366,
"height": 768, "height": 768,
"minWidth": 375, "minWidth": 800,
"minHeight": 812, "minHeight": 600,
"resizable": false, "resizable": true,
"fullscreen": false "fullscreen": false
} }
], ],