1
0
mirror of synced 2025-12-15 15:27:55 +08:00

refactor: 及时释放没用变量

This commit is contained in:
roymondchen
2024-08-26 14:24:12 +08:00
committed by roymondchen
parent 0be82bedee
commit ee469dfd65
4 changed files with 12 additions and 2 deletions

View File

@@ -140,6 +140,7 @@ const mouseleaveHandler = () => {
timer = globalThis.setTimeout(() => {
popoverVisible.value = false;
timer = null;
}, 350);
};

View File

@@ -32,6 +32,7 @@ const filterTextChangeHandler = () => {
timer && clearTimeout(timer);
timer = setTimeout(() => {
emit('search', filterText.value);
timer = null;
}, 300);
};
</script>

View File

@@ -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);
};

View File

@@ -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 {