mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
ck管理添加异步状态获取
This commit is contained in:
parent
5f25fcc49f
commit
6b7a64845e
|
@ -81,10 +81,11 @@ export default class CookieService {
|
||||||
|
|
||||||
public async refreshCookie(_id: string) {
|
public async refreshCookie(_id: string) {
|
||||||
const current = await this.get(_id);
|
const current = await this.get(_id);
|
||||||
const { status } = await this.getJdInfo(current.value);
|
const { status, nickname } = await this.getJdInfo(current.value);
|
||||||
return {
|
return {
|
||||||
...current,
|
...current,
|
||||||
status,
|
status,
|
||||||
|
nickname,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,12 @@ const Config = () => {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '昵称',
|
||||||
|
dataIndex: 'nickname',
|
||||||
|
key: 'nickname',
|
||||||
|
align: 'center' as const,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '值',
|
title: '值',
|
||||||
dataIndex: 'value',
|
dataIndex: 'value',
|
||||||
|
@ -208,10 +214,23 @@ const Config = () => {
|
||||||
.get(`${config.apiPrefix}cookies`)
|
.get(`${config.apiPrefix}cookies`)
|
||||||
.then((data: any) => {
|
.then((data: any) => {
|
||||||
setValue(data.data);
|
setValue(data.data);
|
||||||
|
asyncUpdateStatus(data.data);
|
||||||
})
|
})
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const asyncUpdateStatus = async (data: any[]) => {
|
||||||
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
const cookie = data[i];
|
||||||
|
await sleep(1000);
|
||||||
|
refreshStatus(cookie, i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sleep = (time: number) => {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, time));
|
||||||
|
};
|
||||||
|
|
||||||
const refreshStatus = (record: any, index: number) => {
|
const refreshStatus = (record: any, index: number) => {
|
||||||
request
|
request
|
||||||
.get(`${config.apiPrefix}cookies/${record._id}/refresh`)
|
.get(`${config.apiPrefix}cookies/${record._id}/refresh`)
|
||||||
|
@ -339,6 +358,7 @@ const Config = () => {
|
||||||
...cookie,
|
...cookie,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
refreshStatus(cookie, index);
|
||||||
setValue(result);
|
setValue(result);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user