From b26d0b488717eed20a0978147705a0b760ee082a Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Tue, 12 Oct 2021 22:54:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=A3=80=E6=9F=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/setting/checkUpdate.tsx | 83 ++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/src/pages/setting/checkUpdate.tsx b/src/pages/setting/checkUpdate.tsx index 811f860b..c5c3b60e 100644 --- a/src/pages/setting/checkUpdate.tsx +++ b/src/pages/setting/checkUpdate.tsx @@ -1,10 +1,10 @@ import React, { useEffect, useState, useRef } from 'react'; -import { Typography, Modal, Tag, Button, Spin, message } from 'antd'; +import { Statistic, Modal, Tag, Button, Spin, message } from 'antd'; import { request } from '@/utils/http'; import config from '@/utils/config'; import { version } from '../../version'; -const { Text, Link } = Typography; +const { Countdown } = Statistic; const CheckUpdate = ({ ws }: any) => { const [updateLoading, setUpdateLoading] = useState(false); @@ -18,19 +18,20 @@ const CheckUpdate = ({ ws }: any) => { request .put(`${config.apiPrefix}system/update-check`) .then((_data: any) => { + message.destroy(); const { code, data } = _data; - if (code === 200 && !data.hasNewVersion) { + if (code === 200 && data.hasNewVersion) { showConfirmUpdateModal(data); } else { message.success('已经是最新版了!'); } }) .catch((error: any) => { + message.destroy(); console.log(error); }) .finally(() => { setUpdateLoading(false); - hide(); }); }; @@ -79,29 +80,10 @@ const CheckUpdate = ({ ws }: any) => { maskClosable: false, closable: false, okButtonProps: { disabled: true }, - title: , + title: '更新日志', centered: true, content: ( -
-          {value}
-        
- ), - }); - }; - - useEffect(() => { - ws.onmessage = (e) => { - modalRef.current.update({ - content: ( +
 {
               paddingTop: 15,
               fontSize: 12,
               fontWeight: 400,
-              minHeight: '60vh',
             }}
           >
-            {e.data + value}
+            {value}
           
- ), - }); - setValue(e.data); +
+ ), + }); + }; + + useEffect(() => { + ws.onmessage = (e) => { + if (e.data.includes('重启面板')) { + message.warning({ + content: ( + + 系统将在 + + 秒后自动刷新 + + ), + duration: 10, + }); + setTimeout(() => { + window.location.reload(); + }, 10000); + } else { + modalRef.current.update({ + content: ( +
+
+                {value + e.data}
+              
+
+ ), + }); + setValue(e.data); + } }; }, []);