mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-09 22:56:58 +08:00
fix(ui): overlay销毁需要异常page上的事件
This commit is contained in:
parent
5ac768f15b
commit
094635cc0e
@ -4,10 +4,10 @@
|
||||
</magic-ui-container>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { defineComponent, onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
import Core from '@tmagic/core';
|
||||
import type { MNode } from '@tmagic/schema';
|
||||
import type { MContainer, MNode, MPage } from '@tmagic/schema';
|
||||
|
||||
import useApp from '../../useApp';
|
||||
|
||||
@ -43,12 +43,25 @@ export default defineComponent({
|
||||
}
|
||||
};
|
||||
|
||||
app?.page?.on('editor:select', (info, path) => {
|
||||
const editorSelectHandler = (
|
||||
info: {
|
||||
node: MNode;
|
||||
page: MPage;
|
||||
parent: MContainer;
|
||||
},
|
||||
path: MNode[],
|
||||
) => {
|
||||
if (path.find((node: MNode) => node.id === props.config.id)) {
|
||||
openOverlay();
|
||||
} else {
|
||||
closeOverlay();
|
||||
}
|
||||
};
|
||||
|
||||
app?.page?.on('editor:select', editorSelectHandler);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
app?.page?.off('editor:select', editorSelectHandler);
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -5,9 +5,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
import type { MContainer, MNode } from '@tmagic/schema';
|
||||
import type { MContainer, MNode, MPage } from '@tmagic/schema';
|
||||
|
||||
import useApp from '../../useApp';
|
||||
|
||||
@ -41,11 +41,24 @@ const { app, node } = useApp({
|
||||
},
|
||||
});
|
||||
|
||||
app?.page?.on('editor:select', (info, path) => {
|
||||
const editorSelectHandler = (
|
||||
info: {
|
||||
node: MNode;
|
||||
page: MPage;
|
||||
parent: MContainer;
|
||||
},
|
||||
path: MNode[],
|
||||
) => {
|
||||
if (path.find((node: MNode) => node.id === props.config.id)) {
|
||||
node?.instance.openOverlay();
|
||||
} else {
|
||||
node?.instance.closeOverlay();
|
||||
}
|
||||
};
|
||||
|
||||
app?.page?.on('editor:select', editorSelectHandler);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
app?.page?.off('editor:select', editorSelectHandler);
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user