refactor: get cookies

This commit is contained in:
手瓜一十雪
2024-05-29 12:03:35 +08:00
parent 6f8ea9677f
commit c459587dcd
2 changed files with 5 additions and 8 deletions

View File

@@ -122,6 +122,11 @@ export class NTQQUserApi {
@cacheFunc(60 * 30 * 1000)
static async getCookies(domain: string) {
if (domain.endsWith("qzone.qq.com")) {
let data = (await NTQQUserApi.getQzoneCookies());
const CookieValue = 'p_skey=' + data.p_skey + '; skey=' + data.skey + '; p_uin=o' + selfInfo.uin + '; uin=o' + selfInfo.uin;
return { bkn: NTQQUserApi.genBkn(data.p_skey), cookies: CookieValue };
}
const skey = await this.getSkey();
const pskey = (await this.getPSkey([domain])).get(domain);
if (!pskey || !skey) {

View File

@@ -12,14 +12,6 @@ export class GetCookies extends BaseAction<Payload, { cookies: string; bkn: stri
protected async _handle(payload: Payload) {
const domain = payload.domain || 'qun.qq.com'
if (domain.endsWith("qzone.qq.com")) {
const _Skey = await NTQQUserApi.getSkey() as string;
// 兼容整个 *.qzone.qq.com
let data = (await NTQQUserApi.getQzoneCookies());
const Bkn = WebApi.genBkn(data.p_skey);
const CookieValue = 'p_skey=' + data.p_skey + '; skey=' + data.skey + '; p_uin=o' + selfInfo.uin + '; uin=o' + selfInfo.uin;
return { bkn: WebApi.genBkn(data.p_skey), cookies: CookieValue };
}
return NTQQUserApi.getCookies(domain);
}
}