loading compatible modules in renderer process

This commit is contained in:
antelle 2020-05-26 23:24:00 +02:00
parent a1b8682316
commit 701bb4caa4
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
1 changed files with 7 additions and 1 deletions

View File

@ -14,6 +14,7 @@ const Launcher = {
thirdPartyStoragesSupported: true,
clipboardSupported: true,
req: window.require,
mainProcessModules: ['usb'],
platform() {
return process.platform;
},
@ -27,7 +28,12 @@ const Launcher = {
return this.electron().remote.require(mod);
},
reqNative(mod) {
return this.electron().remote.app.reqNative(mod);
if (this.mainProcessModules.includes(mod)) {
return this.electron().remote.app.reqNative(mod);
} else {
const fileName = `${mod}-${process.platform}-${process.arch}.node`;
return this.req(`@keeweb/keeweb-native-modules/${fileName}`);
}
},
openLink(href) {
if (/^(http|https|ftp|sftp|mailto):/i.test(href)) {