fix: 28060

This commit is contained in:
手瓜一十雪
2024-09-15 09:35:10 +08:00
parent afcdd01c0d
commit 45dedb4872
3 changed files with 21 additions and 18 deletions

View File

@@ -179,18 +179,18 @@ export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
}; };
} }
export function getQQPackageInfoPath(exePath: string = ''): string { export function getQQPackageInfoPath(exePath: string = '', version: string): string {
if (os.platform() === 'darwin') { if (os.platform() === 'darwin') {
return path.join(path.dirname(exePath), '..', 'Resources', 'app', 'package.json'); return path.join(path.dirname(exePath), '..', 'Resources', 'app', 'package.json');
} else { } else {
return path.join(path.dirname(exePath), 'resources', 'app', 'package.json'); return path.join(path.dirname(exePath), './versions/9.9.15-28060/resources/app/package.json');
} }
} }
export function getQQVersionConfigPath(exePath: string = ''): string | undefined { export function getQQVersionConfigPath(exePath: string = ''): string | undefined {
let configVersionInfoPath; let configVersionInfoPath;
if (os.platform() === 'win32') { if (os.platform() === 'win32') {
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json'); configVersionInfoPath = path.join(path.dirname(exePath), 'versions', 'config.json');
} else if (os.platform() === 'darwin') { } else if (os.platform() === 'darwin') {
const userPath = os.homedir(); const userPath = os.homedir();
const appDataPath = path.resolve(userPath, './Library/Application Support/QQ'); const appDataPath = path.resolve(userPath, './Library/Application Support/QQ');

View File

@@ -19,14 +19,16 @@ export class QQBasicInfoWrapper {
//基础目录获取 //基础目录获取
this.context = context; this.context = context;
this.QQMainPath = process.execPath; this.QQMainPath = process.execPath;
this.QQPackageInfoPath = getQQPackageInfoPath(this.QQMainPath);
this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath); this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath);
//基础信息获取 无快更则启用默认模板填充 //基础信息获取 无快更则启用默认模板填充
this.isQuickUpdate = !!this.QQVersionConfigPath; this.isQuickUpdate = !!this.QQVersionConfigPath;
this.QQVersionConfig = this.isQuickUpdate this.QQVersionConfig = this.isQuickUpdate
? JSON.parse(fs.readFileSync(this.QQVersionConfigPath!).toString()) ? JSON.parse(fs.readFileSync(this.QQVersionConfigPath!).toString())
: getDefaultQQVersionConfigInfo(); : getDefaultQQVersionConfigInfo();
this.QQPackageInfoPath = getQQPackageInfoPath(this.QQMainPath, this.QQVersionConfig?.curVersion!);
this.QQPackageInfo = JSON.parse(fs.readFileSync(this.QQPackageInfoPath).toString()); this.QQPackageInfo = JSON.parse(fs.readFileSync(this.QQPackageInfoPath).toString());
const { appid: IQQVersionAppid, qua: IQQVersionQua } = this.getAppidV2(); const { appid: IQQVersionAppid, qua: IQQVersionQua } = this.getAppidV2();
this.QQVersionAppid = IQQVersionAppid; this.QQVersionAppid = IQQVersionAppid;

View File

@@ -46,14 +46,15 @@ export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
if (os.platform() === 'darwin') { if (os.platform() === 'darwin') {
appPath = path.resolve(path.dirname(process.execPath), '../Resources/app'); appPath = path.resolve(path.dirname(process.execPath), '../Resources/app');
} else { } else {
appPath = path.resolve(path.dirname(process.execPath), './resources/app'); appPath = path.resolve(path.dirname(process.execPath), `./versions/${QQVersion}/`);
} }
let wrapperNodePath = path.resolve(appPath, 'wrapper.node'); let wrapperNodePath = path.resolve(appPath, 'wrapper.node');
if (!fs.existsSync(wrapperNodePath)) { if (!fs.existsSync(wrapperNodePath)) {
wrapperNodePath = path.join(appPath, `versions/${QQVersion}/wrapper.node`); wrapperNodePath = path.join(appPath, `./resources/app./wrapper.node`);
} }
const nativemodule: any = { exports: {} }; const nativemodule: any = { exports: {} };
process.dlopen(nativemodule, wrapperNodePath); process.dlopen(nativemodule, wrapperNodePath);
//\versions\9.9.15-28060\resources\app\wrapper.node
return nativemodule.exports; return nativemodule.exports;
} }