Browse Source

解决内存泄漏造成页面卡顿问题

master_hella_20240701
yufei0306 8 months ago
parent
commit
5184e4a435
  1. 9
      src/layout/components/Message/src/Message.vue
  2. 2
      src/views/login/components/LoginForm.vue
  3. 10
      src/views/login/components/MobileForm.vue

9
src/layout/components/Message/src/Message.vue

@ -8,7 +8,7 @@ const { push } = useRouter()
const activeName = ref('notice')
const unreadCount = ref(0) //
const list = ref<any[]>([]) //
const interval = ref<NodeJS.Timeout | number>()
//
const getList = async () => {
list.value = await NotifyMessageApi.getUnreadNotifyMessageList()
@ -35,13 +35,18 @@ onMounted(() => {
//
getUnreadCount()
//
setInterval(
interval.value = setInterval(
() => {
getUnreadCount()
},
1000 * 60 * 2
)
})
onBeforeUnmount(() => {
if(interval.value){
clearInterval(interval.value)
}
})
</script>
<template>
<div class="message">

2
src/views/login/components/LoginForm.vue

@ -224,7 +224,7 @@ const handleLogin = async (params) => {
console.log('登录-224')
getCode()
loginLoading.value = false
loading.value.close()
loading?.value?.close()
}
}

10
src/views/login/components/MobileForm.vue

@ -148,6 +148,7 @@ const smsVO = reactive({
}
})
const mobileCodeTimer = ref(0)
const msgTimer = ref<NodeJS.Timeout | number>()
const redirect = ref<string>('')
const getSmsCode = async () => {
await getTenantId()
@ -156,14 +157,19 @@ const getSmsCode = async () => {
message.success(t('login.SmsSendMsg'))
//
mobileCodeTimer.value = 60
let msgTimer = setInterval(() => {
msgTimer.value = setInterval(() => {
mobileCodeTimer.value = mobileCodeTimer.value - 1
if (mobileCodeTimer.value <= 0) {
clearInterval(msgTimer)
clearInterval(msgTimer.value)
}
}, 1000)
})
}
onBeforeUnmount(() => {
if(msgTimer.value){
clearInterval(msgTimer.value)
}
})
watch(
() => currentRoute.value,
(route: RouteLocationNormalizedLoaded) => {

Loading…
Cancel
Save