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(); }