mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-06 19:26:07 +08:00
修改获取切换 node 和 linux 源日志
This commit is contained in:
parent
c6a25e5359
commit
5afec03548
|
@ -17,4 +17,6 @@ export type SockMessageType =
|
|||
| 'updateSystemVersion'
|
||||
| 'manuallyRunScript'
|
||||
| 'runSubscriptionEnd'
|
||||
| 'reloadSystem';
|
||||
| 'reloadSystem'
|
||||
| 'updateNodeMirror'
|
||||
| 'updateLinuxMirror';
|
||||
|
|
|
@ -142,15 +142,19 @@ export default class SystemService {
|
|||
{
|
||||
onStart: async (cp) => {
|
||||
res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
||||
},
|
||||
onEnd: async () => {
|
||||
res.end();
|
||||
},
|
||||
onEnd: async () => {
|
||||
this.sockService.sendMessage({
|
||||
type: 'updateNodeMirror',
|
||||
message: 'update node mirror end',
|
||||
});
|
||||
},
|
||||
onError: async (message: string) => {
|
||||
res.write(`\n${message}`);
|
||||
this.sockService.sendMessage({ type: 'updateNodeMirror', message });
|
||||
},
|
||||
onLog: async (message: string) => {
|
||||
res.write(`\n${message}`);
|
||||
this.sockService.sendMessage({ type: 'updateNodeMirror', message });
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -192,15 +196,19 @@ export default class SystemService {
|
|||
{
|
||||
onStart: async (cp) => {
|
||||
res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
||||
},
|
||||
onEnd: async () => {
|
||||
res.end();
|
||||
},
|
||||
onEnd: async () => {
|
||||
this.sockService.sendMessage({
|
||||
type: 'updateLinuxMirror',
|
||||
message: 'update linux mirror end',
|
||||
});
|
||||
},
|
||||
onError: async (message: string) => {
|
||||
res.write(`\n${message}`);
|
||||
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
||||
},
|
||||
onLog: async (message: string) => {
|
||||
res.write(`\n${message}`);
|
||||
this.sockService.sendMessage({ type: 'updateLinuxMirror', message });
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -475,5 +475,5 @@
|
|||
"代理地址, 支持HTTP(S)/SOCK5": "Proxy Address, supports HTTP(S)/SOCK5",
|
||||
"NPM 镜像源": "NPM Mirror Source",
|
||||
"PyPI 镜像源": "PyPI Mirror Source",
|
||||
"alpine linux 镜像源": "Alpine Linux Mirror Source"
|
||||
"alpine linux 镜像源, 例如 mirrors.aliyun.com": "Alpine Linux Mirror Source, e.g. mirrors.aliyun.com"
|
||||
}
|
||||
|
|
|
@ -475,5 +475,5 @@
|
|||
"代理地址, 支持HTTP(S)/SOCK5": "代理地址, 支持HTTP(S)/SOCK5",
|
||||
"NPM 镜像源": "NPM 镜像源",
|
||||
"PyPI 镜像源": "PyPI 镜像源",
|
||||
"alpine linux 镜像源": "alpine linux 镜像源"
|
||||
"alpine linux 镜像源, 例如 mirrors.aliyun.com": "alpine linux 镜像源, 例如 mirrors.aliyun.com"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { request } from '@/utils/http';
|
|||
import './index.less';
|
||||
import Ansi from 'ansi-to-react';
|
||||
import pick from 'lodash/pick';
|
||||
import WebSocketManager from '@/utils/websocket';
|
||||
|
||||
const dataMap = {
|
||||
'dependence-proxy': 'dependenceProxy',
|
||||
|
@ -38,18 +39,13 @@ const Dependence = () => {
|
|||
};
|
||||
|
||||
const updateSystemConfigStream = (path: keyof typeof dataMap) => {
|
||||
setLog('执行中...');
|
||||
setLog('执行中...\n');
|
||||
request
|
||||
.put<string>(
|
||||
`${config.apiPrefix}system/config/${path}`,
|
||||
pick(systemConfig, dataMap[path]),
|
||||
{
|
||||
responseType: 'stream',
|
||||
},
|
||||
)
|
||||
.then((res) => {
|
||||
setLog(() => res);
|
||||
})
|
||||
.then((res) => {})
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
});
|
||||
|
@ -72,6 +68,22 @@ const Dependence = () => {
|
|||
});
|
||||
};
|
||||
|
||||
const handleMessage = (payload: any) => {
|
||||
const { message } = payload;
|
||||
setLog((p) => `${p}${message}`);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const ws = WebSocketManager.getInstance();
|
||||
ws.subscribe('updateNodeMirror', handleMessage);
|
||||
ws.subscribe('updateLinuxMirror', handleMessage);
|
||||
|
||||
return () => {
|
||||
ws.subscribe('updateNodeMirror', handleMessage);
|
||||
ws.unsubscribe('updateLinuxMirror', handleMessage);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getSystemConfig();
|
||||
}, []);
|
||||
|
@ -87,7 +99,7 @@ const Dependence = () => {
|
|||
<Input.Group compact>
|
||||
<Input
|
||||
placeholder={intl.get('代理地址, 支持HTTP(S)/SOCK5')}
|
||||
style={{ width: 330 }}
|
||||
style={{ width: 360 }}
|
||||
value={systemConfig?.dependenceProxy}
|
||||
onChange={(e) => {
|
||||
setSystemConfig({
|
||||
|
@ -110,7 +122,7 @@ const Dependence = () => {
|
|||
<Form.Item label={intl.get('Node 软件包镜像源')} name="node">
|
||||
<Input.Group compact>
|
||||
<Input
|
||||
style={{ width: 330 }}
|
||||
style={{ width: 360 }}
|
||||
placeholder={intl.get('NPM 镜像源')}
|
||||
value={systemConfig?.nodeMirror}
|
||||
onChange={(e) => {
|
||||
|
@ -134,7 +146,7 @@ const Dependence = () => {
|
|||
<Form.Item label={intl.get('Python 软件包镜像源')} name="python">
|
||||
<Input.Group compact>
|
||||
<Input
|
||||
style={{ width: 330 }}
|
||||
style={{ width: 360 }}
|
||||
placeholder={intl.get('PyPI 镜像源')}
|
||||
value={systemConfig?.pythonMirror}
|
||||
onChange={(e) => {
|
||||
|
@ -158,8 +170,10 @@ const Dependence = () => {
|
|||
<Form.Item label={intl.get('Linux 软件包镜像源')} name="linux">
|
||||
<Input.Group compact>
|
||||
<Input
|
||||
style={{ width: 330 }}
|
||||
placeholder={intl.get('alpine linux 镜像源')}
|
||||
style={{ width: 360 }}
|
||||
placeholder={intl.get(
|
||||
'alpine linux 镜像源, 例如 mirrors.aliyun.com',
|
||||
)}
|
||||
value={systemConfig?.linuxMirror}
|
||||
onChange={(e) => {
|
||||
setSystemConfig({
|
||||
|
@ -185,7 +199,7 @@ const Dependence = () => {
|
|||
fontFamily: 'Source Code Pro',
|
||||
zoom: 0.83,
|
||||
maxHeight: '100%',
|
||||
overflowY: 'auto'
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<Ansi>{log}</Ansi>
|
||||
|
|
|
@ -5,4 +5,6 @@ export type SockMessageType =
|
|||
| 'updateSystemVersion'
|
||||
| 'manuallyRunScript'
|
||||
| 'runSubscriptionEnd'
|
||||
| 'reloadSystem';
|
||||
| 'reloadSystem'
|
||||
| 'updateNodeMirror'
|
||||
| 'updateLinuxMirror';
|
||||
|
|
Loading…
Reference in New Issue
Block a user