Add event listener cleanup to prevent memory leaks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
* scrollable display of check results.
|
||||
*/
|
||||
|
||||
import { reactive, computed } from 'vue';
|
||||
import { reactive, computed, onBeforeUnmount } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useConformanceStore } from '@/stores/conformance';
|
||||
import emitter from '@/utils/emitter';
|
||||
@@ -265,6 +265,17 @@ emitter.on('isRadioActSeqMoreChange', (data) => {
|
||||
emitter.on('isRadioActSeqFromToChange', (data) => {
|
||||
if(data) reset();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off('actListData');
|
||||
emitter.off('actRadioData');
|
||||
emitter.off('getListSequence');
|
||||
emitter.off('reset');
|
||||
emitter.off('isRadioChange');
|
||||
emitter.off('isRadioProcessScopeChange');
|
||||
emitter.off('isRadioActSeqMoreChange');
|
||||
emitter.off('isRadioActSeqFromToChange');
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
:deep(.disc) {
|
||||
|
||||
@@ -745,6 +745,7 @@ onMounted(() => {
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
selectedAttName.value = {};
|
||||
emitter.off('map-filter-reset');
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
@@ -388,9 +388,10 @@ const vClosable = {
|
||||
e.stopPropagation();
|
||||
}
|
||||
document.addEventListener('click', handleOutsideClick);
|
||||
return () => {
|
||||
document.removeEventListener('click', handleOutsideClick);
|
||||
};
|
||||
el._handleOutsideClick = handleOutsideClick;
|
||||
},
|
||||
unmounted(el) {
|
||||
document.removeEventListener('click', el._handleOutsideClick);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user