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

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

@ -224,7 +224,7 @@ const handleLogin = async (params) => {
console.log('登录-224') console.log('登录-224')
getCode() getCode()
loginLoading.value = false 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 mobileCodeTimer = ref(0)
const msgTimer = ref<NodeJS.Timeout | number>()
const redirect = ref<string>('') const redirect = ref<string>('')
const getSmsCode = async () => { const getSmsCode = async () => {
await getTenantId() await getTenantId()
@ -156,14 +157,19 @@ const getSmsCode = async () => {
message.success(t('login.SmsSendMsg')) message.success(t('login.SmsSendMsg'))
// //
mobileCodeTimer.value = 60 mobileCodeTimer.value = 60
let msgTimer = setInterval(() => { msgTimer.value = setInterval(() => {
mobileCodeTimer.value = mobileCodeTimer.value - 1 mobileCodeTimer.value = mobileCodeTimer.value - 1
if (mobileCodeTimer.value <= 0) { if (mobileCodeTimer.value <= 0) {
clearInterval(msgTimer) clearInterval(msgTimer.value)
} }
}, 1000) }, 1000)
}) })
} }
onBeforeUnmount(() => {
if(msgTimer.value){
clearInterval(msgTimer.value)
}
})
watch( watch(
() => currentRoute.value, () => currentRoute.value,
(route: RouteLocationNormalizedLoaded) => { (route: RouteLocationNormalizedLoaded) => {

Loading…
Cancel
Save