mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 01:14:50 +08:00
修复添加ck和cron未更新列表
This commit is contained in:
+17
-16
@@ -322,26 +322,24 @@ const Config = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleCancel = (needUpdate?: boolean) => {
|
||||
const handleCancel = (cookie: any) => {
|
||||
setIsModalVisible(false);
|
||||
if (needUpdate) {
|
||||
getCookieDetail(editedCookie);
|
||||
if (cookie) {
|
||||
handleCookies(cookie);
|
||||
}
|
||||
};
|
||||
|
||||
const getCookieDetail = (cookie: any) => {
|
||||
request
|
||||
.get(`${config.apiPrefix}cookies/${cookie._id}`)
|
||||
.then((data: any) => {
|
||||
const index = value.findIndex((x) => x._id === cookie._id);
|
||||
const result = [...value];
|
||||
result.splice(index, 1, {
|
||||
...cookie,
|
||||
...data.data,
|
||||
});
|
||||
setValue(result);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
const handleCookies = (cookie: any) => {
|
||||
const index = value.findIndex((x) => x._id === cookie._id);
|
||||
const result = [...value];
|
||||
if (index === -1) {
|
||||
result.push(...cookie);
|
||||
} else {
|
||||
result.splice(index, 1, {
|
||||
...cookie,
|
||||
});
|
||||
}
|
||||
setValue(result);
|
||||
};
|
||||
|
||||
const components = {
|
||||
@@ -352,6 +350,9 @@ const Config = () => {
|
||||
|
||||
const moveRow = useCallback(
|
||||
(dragIndex, hoverIndex) => {
|
||||
if (dragIndex === hoverIndex) {
|
||||
return;
|
||||
}
|
||||
const dragRow = value[dragIndex];
|
||||
const newData = [...value];
|
||||
newData.splice(dragIndex, 1);
|
||||
|
||||
@@ -43,7 +43,7 @@ const CookieModal = ({
|
||||
message: data,
|
||||
});
|
||||
}
|
||||
handleCancel(true);
|
||||
handleCancel(data);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -347,10 +347,10 @@ const Crontab = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancel = (needUpdate?: boolean) => {
|
||||
const handleCancel = (cron?: any) => {
|
||||
setIsModalVisible(false);
|
||||
if (needUpdate) {
|
||||
getCronDetail(editedCron);
|
||||
if (cron) {
|
||||
handleCrons(cron);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -358,6 +358,19 @@ const Crontab = () => {
|
||||
setSearchText(value);
|
||||
};
|
||||
|
||||
const handleCrons = (cron: any) => {
|
||||
const index = value.findIndex((x) => x._id === cron._id);
|
||||
const result = [...value];
|
||||
if (index === -1) {
|
||||
result.push(cron);
|
||||
} else {
|
||||
result.splice(index, 1, {
|
||||
...cron,
|
||||
});
|
||||
}
|
||||
setValue(result);
|
||||
};
|
||||
|
||||
const getCronDetail = (cron: any) => {
|
||||
request
|
||||
.get(`${config.apiPrefix}crons/${cron._id}`)
|
||||
|
||||
@@ -33,7 +33,7 @@ const CronModal = ({
|
||||
message: data,
|
||||
});
|
||||
}
|
||||
handleCancel(true);
|
||||
handleCancel(data);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user