diff --git a/components/Notification.js b/components/Notification.js index 02215d35..4fd4fda1 100644 --- a/components/Notification.js +++ b/components/Notification.js @@ -1,5 +1,9 @@ import { useState } from 'react' +/** + * 弹框通知 + * @returns + */ const useNotification = () => { const [message, setMessage] = useState('') const [isVisible, setIsVisible] = useState(false) @@ -8,12 +12,13 @@ const useNotification = () => { setMessage(msg) setIsVisible(true) setTimeout(() => { - setIsVisible(false) + closeNotification() }, 3000) } const closeNotification = () => { setIsVisible(false) + setMessage('') } // 测试通知效果 @@ -33,11 +38,10 @@ const useNotification = () => { */ const Notification = () => { return ( -
-
+
+
{message}