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>
|
</magic-ui-container>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent, onBeforeUnmount, ref } from 'vue';
|
||||||
|
|
||||||
import Core from '@tmagic/core';
|
import Core from '@tmagic/core';
|
||||||
import type { MNode } from '@tmagic/schema';
|
import type { MContainer, MNode, MPage } from '@tmagic/schema';
|
||||||
|
|
||||||
import useApp from '../../useApp';
|
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)) {
|
if (path.find((node: MNode) => node.id === props.config.id)) {
|
||||||
openOverlay();
|
openOverlay();
|
||||||
} else {
|
} else {
|
||||||
closeOverlay();
|
closeOverlay();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
app?.page?.on('editor:select', editorSelectHandler);
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
app?.page?.off('editor:select', editorSelectHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<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';
|
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)) {
|
if (path.find((node: MNode) => node.id === props.config.id)) {
|
||||||
node?.instance.openOverlay();
|
node?.instance.openOverlay();
|
||||||
} else {
|
} else {
|
||||||
node?.instance.closeOverlay();
|
node?.instance.closeOverlay();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
app?.page?.on('editor:select', editorSelectHandler);
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
app?.page?.off('editor:select', editorSelectHandler);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user