From a8b85a34f7ef1c7dda99f01b73fc47c44f646f7d 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: Tue, 17 Sep 2024 23:17:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BF=BD=E5=B9=B3NT=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/wrapper.ts | 7 +++---- src/shell/napcat.ts | 27 ++++++++++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/core/wrapper.ts b/src/core/wrapper.ts index 4968e953..eba151b1 100644 --- a/src/core/wrapper.ts +++ b/src/core/wrapper.ts @@ -144,7 +144,7 @@ export interface NodeQQNTWrapperUtil { export interface NodeIQQNTWrapperSession { create(): NodeIQQNTWrapperSession; - + init( wrapperSessionInitConfig: WrapperSessionInitConfig, nodeIDependsAdapter: NodeIDependsAdapter, @@ -249,7 +249,7 @@ export interface NodeIQQNTWrapperSession { export interface EnginInitDesktopConfig { base_path_prefix: string; - platform_type: 3; + platform_type: PlatformType; app_type: 4; app_version: string; os_version: string; @@ -262,8 +262,7 @@ export interface EnginInitDesktopConfig { } export interface NodeIQQNTWrapperEngine { - // eslint-disable-next-line @typescript-eslint/no-misused-new - new(): NodeIQQNTWrapperEngine; + get(): NodeIQQNTWrapperEngine; initWithDeskTopConfig(config: EnginInitDesktopConfig, nodeIGlobalAdapter: NodeIGlobalAdapter): void; } diff --git a/src/shell/napcat.ts b/src/shell/napcat.ts index 469caa6d..22e157bc 100644 --- a/src/shell/napcat.ts +++ b/src/shell/napcat.ts @@ -11,6 +11,7 @@ import { NapCatCore, NapCatCoreWorkingEnv, NodeIQQNTWrapperSession, + PlatformType, WrapperNodeApi, } from '@/core'; import { QQBasicInfoWrapper } from '@/common/qq-basic-info'; @@ -43,7 +44,7 @@ export async function NCoreInitShell() { InitWebUi(logger, pathWrapper).then().catch(logger.logError); // from constructor - const engine = new wrapper.NodeIQQNTWrapperEngine(); + const engine = wrapper.NodeIQQNTWrapperEngine.get(); //const util = wrapper.NodeQQNTWrapperUtil.get(); const loginService = wrapper.NodeIKernelLoginService.get(); const session = wrapper.NodeIQQNTWrapperSession.create(); @@ -63,17 +64,29 @@ export async function NCoreInitShell() { const dataPathGlobal = path.resolve(dataPath, './nt_qq/global'); return [dataPath, dataPathGlobal]; })(); - + let systemPlatform = PlatformType.KWINDOWS; + switch (os.platform()) { + case 'win32': + systemPlatform = PlatformType.KWINDOWS; + break; + case 'darwin': + systemPlatform = PlatformType.KMAC; + break; + case 'linux': + systemPlatform = PlatformType.KANDROID; //Android 怎么不算Linux! + break; + } + if (!basicInfoWrapper.QQVersionAppid || !basicInfoWrapper.QQVersionQua) throw new Error('QQVersionAppid or QQVersionQua is not defined'); // from initConfig engine.initWithDeskTopConfig( { base_path_prefix: '', - platform_type: 3, + platform_type: systemPlatform, app_type: 4, app_version: basicInfoWrapper.getFullQQVesion(), - os_version: 'Windows 10 Pro', + os_version: systemVersion, use_xlog: true, - qua: basicInfoWrapper.QQVersionQua!, + qua: basicInfoWrapper.QQVersionQua, global_path_config: { desktopGlobalPath: dataPathGlobal, }, @@ -83,7 +96,7 @@ export async function NCoreInitShell() { ); loginService.initConfig({ machineId: '', - appid: basicInfoWrapper.QQVersionAppid!, + appid: basicInfoWrapper.QQVersionAppid, platVer: systemVersion, commonPath: dataPathGlobal, clientVer: basicInfoWrapper.getFullQQVesion(), @@ -209,7 +222,7 @@ export async function NCoreInitShell() { logger.log(`可用于快速登录的 QQ:\n${historyLoginList .map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`) .join('\n') - }`); + }`); } loginService.getQRCodePicture(); }