no message

This commit is contained in:
KuroSago 2025-05-06 23:36:05 +08:00
parent 1a716baca4
commit de7d1d884c
9 changed files with 58 additions and 30 deletions

View File

@ -60,6 +60,9 @@ importers:
prettier:
specifier: ^2.7.1
version: 2.8.8
typescript:
specifier: ^5.8.3
version: 5.8.3
packages:
@ -729,6 +732,11 @@ packages:
resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==}
engines: {node: '>=10'}
typescript@5.8.3:
resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==}
engines: {node: '>=14.17'}
hasBin: true
unist-util-stringify-position@3.0.3:
resolution: {integrity: sha512-k5GzIBZ/QatR8N5X2y+drfpWG8IDBzdnVj6OInRNWm1oXrzydiaAT2OQiA8DPRRZyAKb9b6I2a6PxYklZD0gKg==}
@ -1554,6 +1562,8 @@ snapshots:
type-fest@0.20.2: {}
typescript@5.8.3: {}
unist-util-stringify-position@3.0.3:
dependencies:
'@types/unist': 2.0.11

View File

@ -18,8 +18,7 @@
"simple-mind-map-plugin-themes": "^1.0.0",
"@toast-ui/editor": "^3.1.5",
"axios": "^1.7.9",
"codemirror": "^5.65.16",
"uuid": "^11.1.0"
"codemirror": "^5.65.16"
},
"main": "src/index.ts",
"module": "src/index.ts",

View File

@ -10,18 +10,35 @@
<script lang="ts" setup>
import { useMindMapStore } from "../../store/index";
import { v4 as uuidv4 } from "uuid";
import { createUid } from 'simple-mind-map/src/utils'
const { insertChildNode } = useMindMapStore();
async function addNewChildNode() {
insertChildNode(
async () => {
const { activeNodes } = useMindMapStore();
const activeNodesIds = activeNodes.map((node) => node.uid);
if (activeNodesIds.length === 0) return;
for (const uid of activeNodesIds) {
const uuid = createUid();
const parentNodeId = uid;
console.log("uuid", {
parentNodeId,
uuid,
});
insertChildNode({
parentNodeId: uid,
beforeInsertCallback: async () => {
return {
uid: uuidv4(),
text: "新节点22222",
uid: uuid,
text: uuid,
};
},
});
}
);
}
</script>

View File

@ -10,7 +10,7 @@
<script lang="ts" setup>
import { useMindMapStore } from "../../store/index";
import { v4 as uuidv4 } from "uuid";
import { createUid } from 'simple-mind-map/src/utils'
const { insertSiblingNode } = useMindMapStore();
@ -18,7 +18,7 @@
insertSiblingNode(
async () => {
return {
uid: uuidv4(),
uid: createUid(),
text: "新节点22222",
};
}

View File

@ -1,5 +1,5 @@
import { useMindMapStore } from "../../store/index";
import { v4 as uuidv4 } from "uuid";
import { createUid } from 'simple-mind-map/src/utils'
/**
*
@ -8,18 +8,22 @@ import { v4 as uuidv4 } from "uuid";
* @returns Promise
*/
export async function insertChildNode(
params : {
parentNodeId: string | number,
beforeInsertCallback: () => Promise<({ uid: number | string, text: string } | boolean)>,
nodeOptions: Record<string, any> = { uid: uuidv4(), text: " - " }
nodeOptions?: Record<string, any>
}
) {
const { getMindMapInstance } = useMindMapStore();
const _nodeOptions = {
...nodeOptions,
uid: createUid(),
text: " - ",
...(params.nodeOptions || {})
}
try {
// 如果提供了回调函数,先执行回调
const result = await beforeInsertCallback();
const result = await params.beforeInsertCallback();
if (!result) return; // 如果直接 false 则不再执行插入操作

View File

@ -1,5 +1,5 @@
import { useMindMapStore } from "../../store/index";
import { v4 as uuidv4 } from "uuid";
import { createUid } from 'simple-mind-map/src/utils'
// 插入同级节点
/**
@ -10,7 +10,7 @@ import { v4 as uuidv4 } from "uuid";
*/
export async function insertSiblingNode(
beforeInsertCallback: () => Promise<({ uid: number | string, text: string } | boolean)>,
nodeOptions: Record<string, any> = { uid: uuidv4(), text: " - " }
nodeOptions: Record<string, any> = { uid: createUid(), text: " - " }
) {
const { getMindMapInstance } = useMindMapStore();

View File

@ -41,6 +41,7 @@ export const useMindMapStore = defineStore(
// 监听节点激活事件
mindMapInstance?.on('node_active', (_ : MindMapNode, activeNodeList : MindMapNode[]) => {
console.log('激活节点', activeNodeList);
activeNodes.value = activeNodeList
})
}
@ -57,6 +58,7 @@ export const useMindMapStore = defineStore(
return {
mindMapInstance,
mindMapData,
activeNodes,
getMindMapInstance,
importFile,

View File

@ -27,3 +27,8 @@ declare module 'simple-mind-map/src/plugins/MindMapLayoutPro' {
export default MindMapLayoutPro;
}
declare module 'simple-mind-map/src/utils' {
import * as utils from 'simple-mind-map/types/src/utils';
export = utils;
}

9
web3/pnpm-lock.yaml generated
View File

@ -100,9 +100,6 @@ importers:
simple-mind-map-plugin-themes:
specifier: ^1.0.0
version: 1.0.1
uuid:
specifier: ^11.1.0
version: 11.1.0
vue:
specifier: ^3.3.4
version: 3.5.13(typescript@5.8.3)
@ -1887,10 +1884,6 @@ packages:
util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
uuid@11.1.0:
resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==}
hasBin: true
v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
@ -3745,8 +3738,6 @@ snapshots:
util-deprecate@1.0.2: {}
uuid@11.1.0: {}
v8-compile-cache-lib@3.0.1: {}
vite@4.5.13(@types/node@22.15.3)(sass@1.87.0):