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 8eac0be86a
commit 64f23dd740

View File

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