no message

This commit is contained in:
KuroSago 2025-05-12 15:03:44 +08:00
parent 52395c43ff
commit 1db799b52c
2 changed files with 29 additions and 17 deletions

View File

@ -1,30 +1,43 @@
<template> <template>
<div class="h-screen p-6 bg-gradient-to-br from-gray-50 to-gray-100"> <div class="h-screen p-6 bg-gradient-to-br from-gray-50 to-gray-100">
<MindMap <MindMap @onDel="onDel" @onAddChild="onAddChild" @onEdit="onEdit" />
@onDel="onDel"
@onAddChild="onAddChild"
@onEdit="onEdit"
/>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted } from "vue"; import { onMounted } from "vue";
import { MindMap } from "@mind-map/component"; import { MindMap, useMindMapStore } from "@mind-map/component";
import type { MindMapNode } from "@mind-map/component"; import type { MindMapNode } from "@mind-map/component";
onMounted(() => { onMounted(() => {
console.log("Home view mounted"); console.log("Home view mounted");
}); });
function onDel (node : MindMapNode) { const { removeNode, insertChildNode } = useMindMapStore();
console.log("Node deleted:", node);
}; function onDel(node: MindMapNode) {
function onAddChild (node : MindMapNode) { removeNode({
console.log("Child node added:", node); beforeRemoveCallback: async () => {
}; return true;
function onEdit (node : MindMapNode) { },
nodeId: node.uid,
allowRemoveWithChildren: false,
});
}
function onAddChild(node: MindMapNode) {
insertChildNode({
parentNodeId: node.uid,
beforeInsertCallback: async () => {
return {
uid: "node.uid",
text: "node.text",
};
},
});
}
function onEdit(node: MindMapNode) {
console.log("Node edited:", node); console.log("Node edited:", node);
}; }
</script> </script>

View File

@ -72,7 +72,7 @@ function defineStoreImplementation() {
createNewNodeBehavior: "activeOnly", // 插入新节点的行为 // activeOnly - 只新建激活不编辑 createNewNodeBehavior: "activeOnly", // 插入新节点的行为 // activeOnly - 只新建激活不编辑
isUseCustomNodeContent: true, // 是否使用自定义节点内容 isUseCustomNodeContent: true, // 是否使用自定义节点内容
addCustomContentToNode: getCustomNodeContent({ addCustomContentToNode: getCustomNodeContent({
allowRemoveWithChildren: false, allowRemoveWithChildren: false,
del: (node: MindMapNode) => { del: (node: MindMapNode) => {
@ -139,7 +139,6 @@ function defineStoreImplementation() {
} }
return { return {
// mindMapInstance,
mindMapData, mindMapData,
activeNodes, activeNodes,
currentLayout, currentLayout,