From 733052720c89cad0fe873e3fd916b85d90bf3853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sat, 20 Jul 2024 10:28:47 +0800 Subject: [PATCH] build: 1.6.6-build02 --- src/common/utils/helper.ts | 4 ++-- src/core/src/apis/user.ts | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/common/utils/helper.ts b/src/common/utils/helper.ts index c7fcbff0..9f8242bc 100644 --- a/src/common/utils/helper.ts +++ b/src/common/utils/helper.ts @@ -89,7 +89,7 @@ export function CacheClassFuncAsync(ttl: number = 3600 * 1000, customKey: string } 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); function logExecutionTime(target: any, methodName: string, descriptor: PropertyDescriptor) { //console.log('logExecutionTime', target, methodName, descriptor); @@ -108,7 +108,7 @@ export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: } // const start = Date.now(); const result = await originalMethod.apply(this, args); - if (!checker(result)) { + if (!checker(...args, result)) { return result;//丢弃缓存 } // const end = Date.now(); diff --git a/src/core/src/apis/user.ts b/src/core/src/apis/user.ts index f53bc958..3b7de889 100644 --- a/src/core/src/apis/user.ts +++ b/src/core/src/apis/user.ts @@ -6,7 +6,7 @@ import { ProfileListener } from '@/core/listeners'; import { rejects } from 'assert'; import { randomUUID } from 'crypto'; 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'; const userInfoCache: Record = {}; // uid: User @@ -163,7 +163,13 @@ export class NTQQUserApi { } 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) { let ret = await NTEventDispatch.CallNoListenerEvent <(Uin: string[]) => Promise<{ uidInfo: Map }>>( @@ -182,7 +188,7 @@ export class NTQQUserApi { }); //uid = Array.from(friends.values()).find((t) => { t.uin == Uin })?.uid; // 从NC维护的QQ Buddy缓存 转换 } - + // if (!uid) { // uid = (await NTQQFriendApi.getFriends(false)).find((t) => { t.uin == Uin })?.uid; //从QQ Native 缓存转换 方法一 // } @@ -197,7 +203,13 @@ export class NTQQUserApi { } 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) { if (!Uid) { return '';