feat(editor): 获取联动组件的方法函数中添加组件id参数

This commit is contained in:
roymondchen 2025-05-28 17:47:12 +08:00
parent 8142a7ab6d
commit 0196eb343a
2 changed files with 5 additions and 5 deletions

View File

@ -232,7 +232,7 @@ const compActionConfig = computed(() => {
let methods: EventOption[] | CascaderOption[] = [];
methods = eventsService.getMethod(node.type);
methods = eventsService.getMethod(node.type, model.to);
if (node.type === 'page-fragment-container' && node.pageFragmentId) {
const pageFragment = editorService.get('root')?.items?.find((page) => page.id === node.pageFragmentId);
@ -240,7 +240,7 @@ const compActionConfig = computed(() => {
methods = [];
pageFragment.items.forEach((node: MComponent | MContainer) => {
traverseNode<MComponent | MContainer>(node, (node) => {
const nodeMethods = (node.type && eventsService.getMethod(node.type)) || [];
const nodeMethods = (node.type && eventsService.getMethod(node.type, node.id)) || [];
if (nodeMethods.length) {
methods.push({
@ -317,7 +317,7 @@ const tableConfig = computed(() => ({
const node = editorService.getNodeById(model.to);
if (!node?.type) return [];
return eventsService.getMethod(node.type).map((option: any) => ({
return eventsService.getMethod(node.type, model.to).map((option: any) => ({
text: option.label,
value: option.value,
}));

View File

@ -20,7 +20,7 @@ import { reactive } from 'vue';
import { cloneDeep } from 'lodash-es';
import type { Writable } from 'type-fest';
import { type EventOption } from '@tmagic/core';
import { type EventOption, type Id } from '@tmagic/core';
import { toLine } from '@tmagic/utils';
import type { AsyncHookPlugin, SyncHookPlugin } from '@editor/type';
@ -70,7 +70,7 @@ class Events extends BaseService {
methodMap[toLine(type)] = [...method];
}
public getMethod(type: string) {
public getMethod(type: string, _targetId: Id) {
return cloneDeep(methodMap[toLine(type)]) || [];
}