Add platform and arch to native module path

Prepends process.platform and process.arch to the native MoeHoo module filename, ensuring the correct binary is loaded for the current environment.
This commit is contained in:
手瓜一十雪 2025-11-12 12:00:36 +08:00
parent 63f42f1592
commit 3d654791b9

View File

@ -37,6 +37,7 @@ export class NativePacketHandler {
constructor ({ logger }: { logger: LogWrapper; }) { constructor ({ logger }: { logger: LogWrapper; }) {
this.logger = logger; this.logger = logger;
try { try {
const platform = process.platform + '.' + process.arch;
const moehoo_path = path.join(dirname(fileURLToPath(import.meta.url)), './native/packet/MoeHoo.' + platform + '.node'); const moehoo_path = path.join(dirname(fileURLToPath(import.meta.url)), './native/packet/MoeHoo.' + platform + '.node');
if (!fs.existsSync(moehoo_path)) { if (!fs.existsSync(moehoo_path)) {
this.logger.logWarn(`NativePacketClient: 缺失运行时文件: ${moehoo_path}`); this.logger.logWarn(`NativePacketClient: 缺失运行时文件: ${moehoo_path}`);