build: 1.6.6-build02

This commit is contained in:
手瓜一十雪 2024-07-20 10:28:47 +08:00
parent a10f007194
commit 733052720c
2 changed files with 18 additions and 6 deletions

View File

@ -89,7 +89,7 @@ export function CacheClassFuncAsync(ttl: number = 3600 * 1000, customKey: string
} }
return logExecutionTime; return logExecutionTime;
} }
export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: string = '', checker: any = (_data: any) => { return true; }) { export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: string = '', checker: any = (...data: any[]) => { return true; }) {
//console.log('CacheClassFuncAsync', ttl, customKey); //console.log('CacheClassFuncAsync', ttl, customKey);
function logExecutionTime(target: any, methodName: string, descriptor: PropertyDescriptor) { function logExecutionTime(target: any, methodName: string, descriptor: PropertyDescriptor) {
//console.log('logExecutionTime', target, methodName, descriptor); //console.log('logExecutionTime', target, methodName, descriptor);
@ -108,7 +108,7 @@ export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey:
} }
// const start = Date.now(); // const start = Date.now();
const result = await originalMethod.apply(this, args); const result = await originalMethod.apply(this, args);
if (!checker(result)) { if (!checker(...args, result)) {
return result;//丢弃缓存 return result;//丢弃缓存
} }
// const end = Date.now(); // const end = Date.now();

View File

@ -6,7 +6,7 @@ import { ProfileListener } from '@/core/listeners';
import { rejects } from 'assert'; import { rejects } from 'assert';
import { randomUUID } from 'crypto'; import { randomUUID } from 'crypto';
import { RequestUtil } from '@/common/utils/request'; import { RequestUtil } from '@/common/utils/request';
import { logDebug, logError } from '@/common/utils/log'; import { log, logDebug, logError, logWarn } from '@/common/utils/log';
import { NTEventDispatch } from '@/common/utils/EventTask'; import { NTEventDispatch } from '@/common/utils/EventTask';
const userInfoCache: Record<string, User> = {}; // uid: User const userInfoCache: Record<string, User> = {}; // uid: User
@ -163,7 +163,13 @@ export class NTQQUserApi {
} }
return skey; return skey;
} }
@CacheClassFuncAsyncExtend(3600, 'Uin2Uid', (data: string | undefined) => { if (data && data.indexOf('u_') != -1) { return true } return false; }) @CacheClassFuncAsyncExtend(3600, 'Uin2Uid', (Uin: string, Uid: string | undefined) => {
if (Uid && Uid.indexOf('u_') != -1) {
return true
}
logWarn("uin转换到uid时异常", Uin);
return false;
})
static async getUidByUin(Uin: string) { static async getUidByUin(Uin: string) {
let ret = await NTEventDispatch.CallNoListenerEvent let ret = await NTEventDispatch.CallNoListenerEvent
<(Uin: string[]) => Promise<{ uidInfo: Map<string, string> }>>( <(Uin: string[]) => Promise<{ uidInfo: Map<string, string> }>>(
@ -197,7 +203,13 @@ export class NTQQUserApi {
} }
return uid; return uid;
} }
@CacheClassFuncAsyncExtend(3600, 'Uid2Uin', (data: number | undefined) => { if (data && data != 0 && !isNaN(data)) { return true } return false; }) @CacheClassFuncAsyncExtend(3600, 'Uid2Uin', (Uid: string | undefined, Uin: number | undefined) => {
if (Uin && Uin != 0 && !isNaN(Uin)) {
return true
}
logWarn("uin转换到uid时异常", Uid);
return false;
})
static async getUinByUid(Uid: string | undefined) { static async getUinByUid(Uid: string | undefined) {
if (!Uid) { if (!Uid) {
return ''; return '';