feat: 优化载入流程

This commit is contained in:
手瓜一十雪 2024-07-05 16:47:08 +08:00
parent 56d6ebe916
commit 9857f6e437

View File

@ -286,11 +286,7 @@ let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/
if (!fs.existsSync(wrapperNodePath)) {
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${qqVersionConfigInfo.curVersion}/wrapper.node`);
}
let WrapperLoader = path.join(__dirname, "WrapperLoader.cjs");
//此处待优化
fs.writeFileSync(WrapperLoader, `
module.exports = require("${wrapperNodePath.replace(/\\/g, "\\\\")}");
exports = module.exports;
`)
const QQWrapper: WrapperNodeApi = (await import("file://" + WrapperLoader)).default;
const nativemodule: any = { exports: {} };
process.dlopen(nativemodule, wrapperNodePath);
const QQWrapper: WrapperNodeApi = nativemodule.exports;
export default QQWrapper;