mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
refactor: 及时释放没用变量
This commit is contained in:
parent
0be82bedee
commit
ee469dfd65
@ -140,6 +140,7 @@ const mouseleaveHandler = () => {
|
||||
|
||||
timer = globalThis.setTimeout(() => {
|
||||
popoverVisible.value = false;
|
||||
timer = null;
|
||||
}, 350);
|
||||
};
|
||||
|
||||
|
@ -32,6 +32,7 @@ const filterTextChangeHandler = () => {
|
||||
timer && clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
emit('search', filterText.value);
|
||||
timer = null;
|
||||
}, 300);
|
||||
};
|
||||
</script>
|
||||
|
@ -500,6 +500,7 @@ const upHandler = (index: number) => {
|
||||
|
||||
timer = setTimeout(() => {
|
||||
swapArray(index, index - 1);
|
||||
timer = undefined;
|
||||
}, 300);
|
||||
};
|
||||
|
||||
@ -525,6 +526,7 @@ const downHandler = (index: number) => {
|
||||
|
||||
timer = setTimeout(() => {
|
||||
swapArray(index, index + 1);
|
||||
timer = undefined;
|
||||
}, 300);
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { nextTick, reactive, ref } from 'vue-demi';
|
||||
import { nextTick, onBeforeUnmount, reactive, ref } from 'vue-demi';
|
||||
|
||||
import Core from '@tmagic/core';
|
||||
import type { ChangeEvent } from '@tmagic/data-source';
|
||||
@ -8,7 +8,7 @@ import { isPage, replaceChildNode } from '@tmagic/utils';
|
||||
export const useDsl = (app: Core | undefined) => {
|
||||
const pageConfig = ref(app?.page?.data || {});
|
||||
|
||||
app?.dataSourceManager?.on('update-data', (nodes: MNode[], sourceId: string, changeEvent: ChangeEvent) => {
|
||||
const updateDataHandler = (nodes: MNode[], sourceId: string, changeEvent: ChangeEvent) => {
|
||||
nodes.forEach((node) => {
|
||||
if (isPage(node)) {
|
||||
pageConfig.value = node;
|
||||
@ -22,6 +22,12 @@ export const useDsl = (app: Core | undefined) => {
|
||||
nextTick(() => {
|
||||
app.emit('replaced-node', { nodes, sourceId, ...changeEvent });
|
||||
});
|
||||
};
|
||||
|
||||
app?.dataSourceManager?.on('update-data', updateDataHandler);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
app?.dataSourceManager?.off('update-data', updateDataHandler);
|
||||
});
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user