UPDATE: VERSION-20260315

This commit is contained in:
libertyspy
2026-03-15 16:15:23 +08:00
parent 6019738aca
commit 22e71a24d3
2 changed files with 23 additions and 15 deletions

View File

@@ -7,8 +7,8 @@
<div class="ks-model-builder-left">
<PlatformCard
ref="treesCardRef"
@create-tree="handleCreateTree"
@select-tree="handleSelectTree"
@create="handleCreate"
@select="handleSelect"
/>
<NodesCard
@drag-item-start="handleDragStart"
@@ -52,11 +52,11 @@ import { Wrapper } from '@/components/wrapper';
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
import Header from '../header.vue';
import type { currentScenario, NodeDragTemplate, NodeTemplate } from '../types';
import type { Scenario } from './types';
import { createLineOptions } from '../builder/line';
import type { GraphTaskElement, NodeGraph } from '../builder/element';
import { useGraphCanvas } from '../builder/hooks';
import { registerNodeElement } from '../builder/register';
import { createLineOptions } from '../builder/line';
import { createTree, findOneTreeById, updateTree } from '../designer/api';
import { createGraphTaskElement, hasElements, hasRootElementNode, resolveNodeGraph } from '../builder/utils';
import { createGraphTaskElementFromTemplate } from '../utils/node';
@@ -84,10 +84,10 @@ export default defineComponent({
const canvas = ref<HTMLDivElement | null>(null);
const graph = ref<Graph | null>(null);
const currentZoom = ref<number>(1);
const draggedNodeData = ref<NodeDragTemplate | null>(null);
const draggedNodeData = ref<Scenario | null>(null);
const isDraggingOver = ref(false);
const currentTreeEditing = ref<boolean>(false);
const currentScenario = ref<currentScenario | null>(null);
const currentScenario = ref<Scenario | null>(null);
const currentNodeGraph = ref<NodeGraph | null>(null);
const selectedModelNode = ref<Node<NodeProperties> | null>(null);
const selectedNodeTaskElement = ref<GraphTaskElement | null>(null);
@@ -105,7 +105,7 @@ export default defineComponent({
} = useGraphCanvas();
// 处理拖动开始
const handleDragStart = (nm: NodeDragTemplate) => {
const handleDragStart = (nm: Scenario) => {
draggedNodeData.value = nm;
};
@@ -156,14 +156,14 @@ export default defineComponent({
try {
// 获取拖动的数据
const template = draggedNodeData.value as NodeDragTemplate;
const template = draggedNodeData.value as Scenario;
if (!hasElements(graph.value as Graph) && template.type !== 'root') {
if (!hasElements(graph.value as Graph)) {
message.error('请先添加根节点.');
return;
}
if (hasRootElementNode(graph.value as Graph) && template.type === 'root') {
if (hasRootElementNode(graph.value as Graph)) {
message.error('根节点已经存在.');
return;
}
@@ -193,8 +193,8 @@ export default defineComponent({
}
};
const handleSelectTree = (tree: currentScenario) => {
console.info('handleSelectTree', tree);
const handleSelect = (tree: Scenario) => {
console.info('handleSelect', tree);
findOneTreeById(tree.id).then(r => {
if (r.data) {
let nodeGraph: NodeGraph | null = null;
@@ -254,7 +254,7 @@ export default defineComponent({
});
};
const handleCreateTree = () => {
const handleCreate = () => {
currentScenario.value = {
id: 0,
name: '行为树',
@@ -404,7 +404,7 @@ export default defineComponent({
return {
treesCardRef,
handleCreateTree,
handleCreate,
currentTreeEditing,
currentScenario,
currentNodeGraph,
@@ -424,7 +424,7 @@ export default defineComponent({
isDraggingOver,
handleSave,
handleUpdateElement,
handleSelectTree,
handleSelect,
};
},
});

View File

@@ -0,0 +1,8 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/