Skip to content

Commit

Permalink
refactor: 及时释放没用变量
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Aug 26, 2024
1 parent e10892b commit 2793e92
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/design/src/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const mouseleaveHandler = () => {
timer = globalThis.setTimeout(() => {
popoverVisible.value = false;
timer = null;
}, 350);
};
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/SearchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const filterTextChangeHandler = () => {
timer && clearTimeout(timer);
timer = setTimeout(() => {
emit('search', filterText.value);
timer = null;
}, 300);
};
</script>
2 changes: 2 additions & 0 deletions packages/form/src/containers/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ const upHandler = (index: number) => {
timer = setTimeout(() => {
swapArray(index, index - 1);
timer = undefined;
}, 300);
};
Expand All @@ -525,6 +526,7 @@ const downHandler = (index: number) => {
timer = setTimeout(() => {
swapArray(index, index + 1);
timer = undefined;
}, 300);
};
Expand Down
10 changes: 8 additions & 2 deletions runtime/vue-runtime-help/src/hooks/use-dsl.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 2793e92

Please sign in to comment.