mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-12 19:30:48 +08:00
修复 command-run 接口日志绑定
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
import { disableBody } from '@/utils';
|
||||
import config from '@/utils/config';
|
||||
import { request } from '@/utils/http';
|
||||
import WebSocketManager from '@/utils/websocket';
|
||||
import Ansi from 'ansi-to-react';
|
||||
import { Button, Modal, Statistic, message } from 'antd';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { disableBody } from "@/utils";
|
||||
import config from "@/utils/config";
|
||||
import { request } from "@/utils/http";
|
||||
import WebSocketManager from "@/utils/websocket";
|
||||
import Ansi from "ansi-to-react";
|
||||
import { Button, Modal, Statistic, message } from "antd";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import intl from "react-intl-universal";
|
||||
|
||||
const { Countdown } = Statistic;
|
||||
|
||||
const CheckUpdate = ({ systemInfo }: any) => {
|
||||
const [updateLoading, setUpdateLoading] = useState(false);
|
||||
const [value, setValue] = useState('');
|
||||
const [value, setValue] = useState("");
|
||||
const modalRef = useRef<any>();
|
||||
|
||||
const checkUpgrade = () => {
|
||||
if (updateLoading) return;
|
||||
setUpdateLoading(true);
|
||||
message.loading(intl.get('检查更新中...'), 0);
|
||||
message.loading(intl.get("检查更新中..."), 0);
|
||||
request
|
||||
.put(`${config.apiPrefix}system/update-check`)
|
||||
.then(({ code, data }) => {
|
||||
@@ -42,22 +42,22 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
const showForceUpdateModal = (data: any) => {
|
||||
Modal.confirm({
|
||||
width: 500,
|
||||
title: intl.get('更新'),
|
||||
title: intl.get("更新"),
|
||||
content: (
|
||||
<>
|
||||
<div>{intl.get('已经是最新版了!')}</div>
|
||||
<div>{intl.get("已经是最新版了!")}</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 400, marginTop: 5 }}>
|
||||
{intl.get('青龙')} {data.lastVersion}{' '}
|
||||
{intl.get('是目前检测到的最新可用版本了。')}
|
||||
{intl.get("青龙")} {data.lastVersion}{" "}
|
||||
{intl.get("是目前检测到的最新可用版本了。")}
|
||||
</div>
|
||||
</>
|
||||
),
|
||||
okText: intl.get('重新下载'),
|
||||
okText: intl.get("重新下载"),
|
||||
onOk() {
|
||||
showUpdatingModal();
|
||||
request
|
||||
.put(`${config.apiPrefix}system/update`)
|
||||
.then((_data: any) => {})
|
||||
.then((_data: any) => { })
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
});
|
||||
@@ -71,10 +71,10 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
width: 500,
|
||||
title: (
|
||||
<>
|
||||
<div>{intl.get('更新可用')}</div>
|
||||
<div>{intl.get("更新可用")}</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 400, marginTop: 5 }}>
|
||||
{intl.get('新版本')} {lastVersion}{' '}
|
||||
{intl.get('可用,你使用的版本为')} {systemInfo.version}。
|
||||
{intl.get("新版本")} {lastVersion}{" "}
|
||||
{intl.get("可用,你使用的版本为")} {systemInfo.version}。
|
||||
</div>
|
||||
</>
|
||||
),
|
||||
@@ -83,13 +83,13 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
<Ansi>{lastLog}</Ansi>
|
||||
</pre>
|
||||
),
|
||||
okText: intl.get('下载更新'),
|
||||
cancelText: intl.get('以后再说'),
|
||||
okText: intl.get("下载更新"),
|
||||
cancelText: intl.get("以后再说"),
|
||||
onOk() {
|
||||
showUpdatingModal();
|
||||
request
|
||||
.put(`${config.apiPrefix}system/update`)
|
||||
.then((_data: any) => {})
|
||||
.then((_data: any) => { })
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
});
|
||||
@@ -98,14 +98,14 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
};
|
||||
|
||||
const showUpdatingModal = () => {
|
||||
setValue('');
|
||||
setValue("");
|
||||
modalRef.current = Modal.info({
|
||||
width: 600,
|
||||
maskClosable: false,
|
||||
closable: false,
|
||||
keyboard: false,
|
||||
okButtonProps: { disabled: true },
|
||||
title: intl.get('下载更新中...'),
|
||||
title: intl.get("下载更新中..."),
|
||||
centered: true,
|
||||
content: (
|
||||
<pre>
|
||||
@@ -122,13 +122,13 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
message.success({
|
||||
content: (
|
||||
<span>
|
||||
{intl.get('系统将在')}
|
||||
{intl.get("系统将在")}
|
||||
<Countdown
|
||||
className="inline-countdown"
|
||||
format="ss"
|
||||
value={Date.now() + 1000 * 30}
|
||||
/>
|
||||
{intl.get('秒后自动刷新')}
|
||||
{intl.get("秒后自动刷新")}
|
||||
</span>
|
||||
),
|
||||
duration: 30,
|
||||
@@ -147,12 +147,12 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
Modal.confirm({
|
||||
width: 600,
|
||||
maskClosable: false,
|
||||
title: intl.get('确认重启'),
|
||||
title: intl.get("确认重启"),
|
||||
centered: true,
|
||||
content: intl.get('系统安装包下载成功,确认重启'),
|
||||
okText: intl.get('重启'),
|
||||
content: intl.get("系统安装包下载成功,确认重启"),
|
||||
okText: intl.get("重启"),
|
||||
onOk() {
|
||||
reloadSystem('system');
|
||||
reloadSystem("system");
|
||||
},
|
||||
onCancel() {
|
||||
modalRef.current.update({
|
||||
@@ -166,7 +166,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!value) return;
|
||||
const updateFailed = value.includes('失败,请检查');
|
||||
const updateFailed = value.includes("失败,请检查");
|
||||
|
||||
modalRef.current.update({
|
||||
maskClosable: updateFailed,
|
||||
@@ -185,19 +185,19 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
|
||||
const handleMessage = useCallback((payload: any) => {
|
||||
let { message: _message } = payload;
|
||||
const updateFailed = _message.includes('失败,请检查');
|
||||
const updateFailed = _message.includes("失败,请检查");
|
||||
|
||||
if (updateFailed) {
|
||||
message.error(intl.get('更新失败,请检查网络及日志或稍后再试'));
|
||||
message.error(intl.get("更新失败,请检查网络及日志或稍后再试"));
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
document
|
||||
.querySelector('#log-identifier')!
|
||||
.scrollIntoView({ behavior: 'smooth' });
|
||||
.querySelector("#log-identifier")
|
||||
?.scrollIntoView({ behavior: "smooth" });
|
||||
}, 600);
|
||||
|
||||
if (_message.includes('更新包下载成功')) {
|
||||
if (_message.includes("更新包下载成功")) {
|
||||
setTimeout(() => {
|
||||
showReloadModal();
|
||||
}, 1000);
|
||||
@@ -208,24 +208,24 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
||||
|
||||
useEffect(() => {
|
||||
const ws = WebSocketManager.getInstance();
|
||||
ws.subscribe('updateSystemVersion', handleMessage);
|
||||
ws.subscribe("updateSystemVersion", handleMessage);
|
||||
|
||||
return () => {
|
||||
ws.unsubscribe('updateSystemVersion', handleMessage);
|
||||
ws.unsubscribe("updateSystemVersion", handleMessage);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button type="primary" onClick={checkUpgrade}>
|
||||
{intl.get('检查更新')}
|
||||
{intl.get("检查更新")}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => reloadSystem('reload')}
|
||||
onClick={() => reloadSystem("reload")}
|
||||
style={{ marginLeft: 8 }}
|
||||
>
|
||||
{intl.get('重新启动')}
|
||||
{intl.get("重新启动")}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user