feat: logger
This commit is contained in:
parent
276f45c58e
commit
da2c947efd
@ -4,6 +4,7 @@ import type { ClubInfo, EventDetail, IEventInfo, MatchSummary, Player } from "..
|
||||
import dayjs from "dayjs";
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
import { logger } from "@/utils/logger";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
@ -224,7 +225,7 @@ export class KaiqiuService {
|
||||
public static async login(username: string, password: string) {
|
||||
const loginPageRes = await fetch('https://kaiqiuwang.cc/home/do.php?ac=668g&&ref');
|
||||
const cookies = loginPageRes.headers.getSetCookie().map(c => c.split(';')[0]).join('; ');
|
||||
console.debug('init cookies: ', cookies);
|
||||
logger.debug('Bind user', { cookies, username, password });
|
||||
let $ = cheerio.load(await loginPageRes.text());
|
||||
const loginsubmit = $('#loginsubmit').val()?.toString() || '';
|
||||
const formhash = $('#loginform > input[type=hidden]').val()?.toString() || '';
|
||||
@ -269,7 +270,6 @@ export class KaiqiuService {
|
||||
.filter(cookie => !cookie?.includes('uchome_auth=deleted'))
|
||||
.join('; ')
|
||||
].join('; ');
|
||||
console.debug('auth cookies', authCookies);
|
||||
const networkPageReq = await fetch("https://kaiqiuwang.cc/home/network.php", {
|
||||
"headers": {
|
||||
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { logger } from '@/utils/logger';
|
||||
import { xcxApi } from '../utils/server';
|
||||
|
||||
export const getUidScore = async (uids: string[], force?: boolean): Promise<Record<string, string>> => {
|
||||
const entries: [string, string][] = [];
|
||||
console.debug('getUidScore(%s): start', uids.length);
|
||||
logger.debug('getUidScore(%s): start', uids.length);
|
||||
for (const uid of uids) {
|
||||
const profile = await xcxApi.getAdvProfile(uid, force);
|
||||
entries.push([uid, profile?.score ?? '']);
|
||||
}
|
||||
console.debug('getUidScore(%s): end', uids.length);
|
||||
return Object.fromEntries(entries);
|
||||
}
|
||||
@ -43,7 +43,7 @@ export class XCXAPI {
|
||||
if (!cacheProfile || force) {
|
||||
const url = `/api/User/adv_profile?uid=${uid}`;
|
||||
const profile = await this.#fetch<XCXProfile>(url);
|
||||
console.debug('Save profile: %s - %s', profile?.uid, profile?.realname);
|
||||
logger.debug('Save profile', { uid: profile?.uid, name: profile?.realname, realname: profile?.realname });
|
||||
await redis.setex(`my-kaiqiuwang:profile:${uid}`, 60 * 60 * 24, JSON.stringify(profile));
|
||||
return profile;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user