Skip to content

Commit

Permalink
feat(main): enable electron nodeIntegrationInSubFrames window option (#…
Browse files Browse the repository at this point in the history
…337)

1. fix load jQuery failed
2. remove agora-electron-sdk support in wechat login page
  • Loading branch information
BlackHole1 committed Mar 2, 2021
1 parent 677cedc commit ebea2f8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
},
"dependencies": {
"agora-electron-sdk": "education290",
"jquery": "^3.5.1",
"ts-enum-util": "^4.0.2"
},
"license": "MIT"
Expand Down
22 changes: 21 additions & 1 deletion src/main-app/preload.js
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
window.AgoraRtcEngine = require("agora-electron-sdk").default;
const fixJQueryHosts = ["open.weixin.qq.com"];

if (fixJQueryHosts.includes(location.host)) {
document.addEventListener("DOMNodeInserted", function fixJQuery() {
if (window && !window.$) {
window.$ = window.jQuery = require("jquery");
document.removeEventListener("DOMNodeInserted", fixJQuery);
}
});
}

const disableInjectionAgoraAddonHosts = ["open.weixin.qq.com"];

if (!disableInjectionAgoraAddonHosts.includes(location.host)) {
document.addEventListener("DOMNodeInserted", function injectionAgoraAddon() {
if (window) {
window.AgoraRtcEngine = require("agora-electron-sdk").default;
document.removeEventListener("DOMNodeInserted", injectionAgoraAddon);
}
});
}
1 change: 1 addition & 0 deletions src/main-app/src/utils/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const defaultBrowserWindowOptions: BrowserWindowConstructorOptions = {
webviewTag: true,
nativeWindowOpen: true,
backgroundThrottling: false,
nodeIntegrationInSubFrames: true,
},
};

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7383,6 +7383,11 @@ jju@~1.4.0:
resolved "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo=

jquery@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==

js-base64@^2.5.2:
version "2.6.4"
resolved "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"
Expand Down

0 comments on commit ebea2f8

Please sign in to comment.