mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-24 07:16:08 +08:00
完善检查更新操作
This commit is contained in:
parent
ed93b919ba
commit
b26d0b4887
|
@ -1,10 +1,10 @@
|
||||||
import React, { useEffect, useState, useRef } from 'react';
|
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 { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import { version } from '../../version';
|
import { version } from '../../version';
|
||||||
|
|
||||||
const { Text, Link } = Typography;
|
const { Countdown } = Statistic;
|
||||||
|
|
||||||
const CheckUpdate = ({ ws }: any) => {
|
const CheckUpdate = ({ ws }: any) => {
|
||||||
const [updateLoading, setUpdateLoading] = useState(false);
|
const [updateLoading, setUpdateLoading] = useState(false);
|
||||||
|
@ -18,19 +18,20 @@ const CheckUpdate = ({ ws }: any) => {
|
||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}system/update-check`)
|
.put(`${config.apiPrefix}system/update-check`)
|
||||||
.then((_data: any) => {
|
.then((_data: any) => {
|
||||||
|
message.destroy();
|
||||||
const { code, data } = _data;
|
const { code, data } = _data;
|
||||||
if (code === 200 && !data.hasNewVersion) {
|
if (code === 200 && data.hasNewVersion) {
|
||||||
showConfirmUpdateModal(data);
|
showConfirmUpdateModal(data);
|
||||||
} else {
|
} else {
|
||||||
message.success('已经是最新版了!');
|
message.success('已经是最新版了!');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
message.destroy();
|
||||||
console.log(error);
|
console.log(error);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setUpdateLoading(false);
|
setUpdateLoading(false);
|
||||||
hide();
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,9 +80,10 @@ const CheckUpdate = ({ ws }: any) => {
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
closable: false,
|
closable: false,
|
||||||
okButtonProps: { disabled: true },
|
okButtonProps: { disabled: true },
|
||||||
title: <span></span>,
|
title: '更新日志',
|
||||||
centered: true,
|
centered: true,
|
||||||
content: (
|
content: (
|
||||||
|
<div style={{ height: '60vh', overflowY: 'auto' }}>
|
||||||
<pre
|
<pre
|
||||||
style={{
|
style={{
|
||||||
wordBreak: 'break-all',
|
wordBreak: 'break-all',
|
||||||
|
@ -89,19 +91,39 @@ const CheckUpdate = ({ ws }: any) => {
|
||||||
paddingTop: 15,
|
paddingTop: 15,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
minHeight: '60vh',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{value}
|
{value}
|
||||||
</pre>
|
</pre>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ws.onmessage = (e) => {
|
ws.onmessage = (e) => {
|
||||||
|
if (e.data.includes('重启面板')) {
|
||||||
|
message.warning({
|
||||||
|
content: (
|
||||||
|
<span>
|
||||||
|
系统将在
|
||||||
|
<Countdown
|
||||||
|
className="inline-countdown"
|
||||||
|
format="ss"
|
||||||
|
value={Date.now() + 1000 * 10}
|
||||||
|
/>
|
||||||
|
秒后自动刷新
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
duration: 10,
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 10000);
|
||||||
|
} else {
|
||||||
modalRef.current.update({
|
modalRef.current.update({
|
||||||
content: (
|
content: (
|
||||||
|
<div style={{ height: '60vh', overflowY: 'auto' }}>
|
||||||
<pre
|
<pre
|
||||||
style={{
|
style={{
|
||||||
wordBreak: 'break-all',
|
wordBreak: 'break-all',
|
||||||
|
@ -109,14 +131,15 @@ const CheckUpdate = ({ ws }: any) => {
|
||||||
paddingTop: 15,
|
paddingTop: 15,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
minHeight: '60vh',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{e.data + value}
|
{value + e.data}
|
||||||
</pre>
|
</pre>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
setValue(e.data);
|
setValue(e.data);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user