diff --git a/src/common/helper.ts b/src/common/helper.ts index f4ad9812..693187fb 100644 --- a/src/common/helper.ts +++ b/src/common/helper.ts @@ -157,13 +157,21 @@ export function getDefaultQQVersionConfigInfo(): QQVersionConfigType { } export function getQQPackageInfoPath(exePath: string = ''): string { - return path.join(path.dirname(exePath), 'resources', 'app', 'package.json'); + if (os.platform() === 'darwin') { + return path.join(path.dirname(exePath), '..', 'Resources', 'app', 'package.json'); + } else { + return path.join(path.dirname(exePath), 'resources', 'app', 'package.json'); + } } export function getQQVersionConfigPath(exePath: string = ''): string | undefined { let configVersionInfoPath; if (os.platform() === 'win32') { configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json'); + } else if (os.platform() === 'darwin') { + const userPath = os.homedir(); + const appDataPath = path.resolve(userPath, './Library/Application Support/QQ'); + configVersionInfoPath = path.resolve(appDataPath, './versions/config.json'); } else { const userPath = os.homedir(); const appDataPath = path.resolve(userPath, './.config/QQ'); diff --git a/src/common/path.ts b/src/common/path.ts index 308bcfd5..b204cb20 100644 --- a/src/common/path.ts +++ b/src/common/path.ts @@ -13,7 +13,11 @@ export class NapCatPathWrapper { constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) { this.binaryPath = mainPath; let writePath: string; - writePath = this.binaryPath; + if (os.platform() === 'darwin') { + writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat'); + } else { + writePath = this.binaryPath; + } this.logsPath = path.join(writePath, 'logs'); this.configPath = path.join(writePath, 'config'); this.cachePath = path.join(writePath, 'cache'); diff --git a/src/common/qq-basic-info.ts b/src/common/qq-basic-info.ts index 79556fab..555f1195 100644 --- a/src/common/qq-basic-info.ts +++ b/src/common/qq-basic-info.ts @@ -54,7 +54,9 @@ export class QQBasicInfoWrapper { getQUAInternal() { switch (systemPlatform) { case 'linux': - return `V1_LNX_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`; + return `V1_LNX_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`; + case 'darwin': + return `V1_MAC_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`; default: return `V1_WIN_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`; } @@ -64,6 +66,8 @@ export class QQBasicInfoWrapper { switch (systemPlatform) { case 'linux': return '537243600'; + case 'darwin': + return '537243441'; default: return '537243538'; } diff --git a/src/core/external/appid.json b/src/core/external/appid.json index 9375e295..3f05c08b 100644 --- a/src/core/external/appid.json +++ b/src/core/external/appid.json @@ -6,5 +6,9 @@ "9.9.15-27597": { "appid": 537243441, "qua": "V1_WIN_NQ_9.9.15_27597_GW_B" + }, + "6.9.53-27597": { + "appid": 537243538, + "qua": "V1_MAC_NQ_6.9.53_27597_GW_B" } } diff --git a/src/core/index.ts b/src/core/index.ts index 5fc2912e..c6e9f0ea 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -43,7 +43,11 @@ export enum NapCatCoreWorkingEnv { export function loadQQWrapper(QQVersion: string): WrapperNodeApi { let appPath; - appPath = path.resolve(path.dirname(process.execPath), './resources/app'); + if (os.platform() === 'darwin') { + appPath = path.resolve(path.dirname(process.execPath), '../Resources/app'); + } else { + appPath = path.resolve(path.dirname(process.execPath), './resources/app'); + } let wrapperNodePath = path.resolve(appPath, 'wrapper.node'); if (!fs.existsSync(wrapperNodePath)) { wrapperNodePath = path.join(appPath, `versions/${QQVersion}/wrapper.node`); diff --git a/src/shell/napcat.ts b/src/shell/napcat.ts index 044155df..4beeded5 100644 --- a/src/shell/napcat.ts +++ b/src/shell/napcat.ts @@ -50,6 +50,11 @@ export async function NCoreInitShell() { // from get dataPath const [dataPath, dataPathGlobal] = (() => { + if (os.platform() === 'darwin') { + const userPath = os.homedir(); + const appDataPath = path.resolve(userPath, './Library/Application Support/QQ'); + return [appDataPath, path.join(appDataPath, 'global')]; + } let dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig(); if (!dataPath) { dataPath = path.resolve(os.homedir(), './.config/QQ');