diy支持任意仓库地址,修复添加ck报错,移除monk仓库内置

This commit is contained in:
whyour
2021-04-16 17:30:22 +08:00
parent 5de67b9679
commit 0563555a6a
7 changed files with 54 additions and 66 deletions
+27 -19
View File
@@ -220,14 +220,19 @@ const Config = () => {
.get(`${config.apiPrefix}cookies`)
.then((data: any) => {
setValue(data.data);
asyncUpdateStatus(data.data);
})
.finally(() => setLoading(false));
};
const asyncUpdateStatus = async (data: any[]) => {
for (let i = 0; i < data.length; i++) {
const cookie = data[i];
useEffect(() => {
if (value && loading) {
asyncUpdateStatus();
}
}, [value]);
const asyncUpdateStatus = async () => {
for (let i = 0; i < value.length; i++) {
const cookie = value[i];
await sleep(1000);
refreshStatus(cookie, i);
}
@@ -347,25 +352,28 @@ const Config = () => {
});
};
const handleCancel = (cookie: any) => {
const handleCancel = (cookies: any[]) => {
setIsModalVisible(false);
if (cookie) {
handleCookies(cookie);
if (cookies && cookies.length > 0) {
handleCookies(cookies);
}
};
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,
});
const handleCookies = (cookies: any[]) => {
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i];
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);
refreshStatus(cookie, index);
}
refreshStatus(cookie, index);
setValue(result);
};
const components = {
@@ -414,7 +422,7 @@ const Config = () => {
return (
<PageContainer
className="code-mirror-wrapper"
className="cookie-wrapper"
title="Cookie管理"
loading={loading}
extra={[