chore: 组件卸载时移除emitter

This commit is contained in:
dap 2024-11-27 08:35:38 +08:00
parent 41b69b5f93
commit a70ae0f603
2 changed files with 8 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import type { UserProfile } from '#/api/system/profile/model';
import { onMounted, ref } from 'vue';
import { onMounted, onUnmounted, ref } from 'vue';
import { Page } from '@vben/common-ui';
import { useUserStore } from '@vben/stores';
@ -34,7 +34,8 @@ async function handleUploadFinish() {
userStore.setUserInfo(userInfo);
}
emitter.on('updateProfile', loadProfile);
onMounted(() => emitter.on('updateProfile', loadProfile));
onUnmounted(() => emitter.off('updateProfile'));
</script>
<template>

View File

@ -1,8 +1,13 @@
<script setup lang="ts">
import { onUnmounted } from 'vue';
import { Page } from '@vben/common-ui';
import DictDataPanel from './data/index.vue';
import { emitter } from './mitt';
import DictTypePanel from './type/index.vue';
onUnmounted(() => emitter.off('rowClick'));
</script>
<template>