修改并发逻辑,系统设置增加定时任务并发设置

This commit is contained in:
whyour
2023-07-01 15:26:20 +08:00
parent db227e56bf
commit 702c3160ec
18 changed files with 163 additions and 88 deletions
+1 -1
View File
@@ -60,9 +60,9 @@ const { Search } = Input;
export enum CrontabStatus {
'running',
'queued',
'idle',
'disabled',
'queued',
}
const CrontabSort: any = { 0: 0, 5: 1, 3: 2, 1: 3, 4: 4 };
-1
View File
@@ -1,6 +1,5 @@
.error-wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
+1 -1
View File
@@ -81,7 +81,7 @@ const Error = () => {
</Typography.Paragraph>
</div>
) : (
<PageLoading style={{ paddingTop: 0 }} tip="启动中,请稍后..." />
<PageLoading tip="启动中,请稍后..." />
)}
</div>
);
+42 -25
View File
@@ -19,7 +19,10 @@ const Other = ({
reloadTheme,
}: Pick<SharedContext, 'socketMessage' | 'reloadTheme' | 'systemInfo'>) => {
const defaultTheme = localStorage.getItem('qinglong_dark_theme') || 'auto';
const [logRemoveFrequency, setLogRemoveFrequency] = useState<number | null>();
const [systemConfig, setSystemConfig] = useState<{
logRemoveFrequency?: number | null;
cronConcurrency?: number | null;
}>();
const [form] = Form.useForm();
const {
@@ -45,13 +48,12 @@ const Other = ({
reloadTheme();
};
const getLogRemoveFrequency = () => {
const getSystemConfig = () => {
request
.get(`${config.apiPrefix}system/log/remove`)
.get(`${config.apiPrefix}system/config`)
.then(({ code, data }) => {
if (code === 200 && data.info) {
const { frequency } = data.info;
setLogRemoveFrequency(frequency);
setSystemConfig(data.info);
}
})
.catch((error: any) => {
@@ -59,25 +61,23 @@ const Other = ({
});
};
const updateRemoveLogFrequency = () => {
setTimeout(() => {
request
.put(`${config.apiPrefix}system/log/remove`, {
data: { frequency: logRemoveFrequency },
})
.then(({ code, data }) => {
if (code === 200) {
message.success('更新成功');
}
})
.catch((error: any) => {
console.log(error);
});
});
const updateSystemConfig = () => {
request
.put(`${config.apiPrefix}system/config`, {
data: { ...systemConfig },
})
.then(({ code, data }) => {
if (code === 200) {
message.success('更新成功');
}
})
.catch((error: any) => {
console.log(error);
});
};
useEffect(() => {
getLogRemoveFrequency();
getSystemConfig();
}, []);
return (
@@ -100,12 +100,29 @@ const Other = ({
<InputNumber
addonBefore="每"
addonAfter="天"
style={{ width: 150 }}
style={{ width: 142 }}
min={0}
value={logRemoveFrequency}
onChange={(value) => setLogRemoveFrequency(value)}
value={systemConfig?.logRemoveFrequency}
onChange={(value) => {
setSystemConfig({ ...systemConfig, logRemoveFrequency: value });
}}
/>
<Button type="primary" onClick={updateRemoveLogFrequency}>
<Button type="primary" onClick={updateSystemConfig}>
</Button>
</Input.Group>
</Form.Item>
<Form.Item label="定时任务并发数" name="frequency">
<Input.Group compact>
<InputNumber
style={{ width: 142 }}
min={1}
value={systemConfig?.cronConcurrency}
onChange={(value) => {
setSystemConfig({ ...systemConfig, cronConcurrency: value });
}}
/>
<Button type="primary" onClick={updateSystemConfig}>
</Button>
</Input.Group>