5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 03:21:32 +08:00

[mac] Port IPC

This commit is contained in:
Lea Anthony 2021-09-15 22:50:39 +10:00
parent badacdd45b
commit eac8f23341
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
4 changed files with 15 additions and 3 deletions

View File

@ -16,8 +16,8 @@ The electron alternative for Go
*/
// const windows = 0;
// const linux = 1;
// const macos = 2;
// const macos = 1;
// const linux = 2;
window.WailsInvoke = function (message) {
@ -25,8 +25,10 @@ window.WailsInvoke = function (message) {
if (PLATFORM === 0) {
window.chrome.webview.postMessage(message);
} else if (PLATFORM === 1) {
window.blah();
window.webkit.messageHandlers.external.postMessage(message);
} else if (PLATFORM === 2) {
console.error("Unsupported Platform");
} else {
console.error("Unsupported Platform");
}
};

View File

@ -0,0 +1,8 @@
//go:build darwin
package runtime
import _ "embed"
//go:embed ipc_darwin.js
var DesktopIPC []byte

View File

@ -0,0 +1 @@
(()=>{window.WailsInvoke=function(e){window.webkit.messageHandlers.external.postMessage(e)};})();

View File

@ -6,6 +6,7 @@
"scripts": {
"build": "run-p build:*",
"build:ipc-windows": "esbuild desktop/ipc.js --bundle --minify --outfile=ipc_windows.js --define:PLATFORM=0",
"build:ipc-darwin": "esbuild desktop/ipc.js --bundle --minify --outfile=ipc_darwin.js --define:PLATFORM=1",
"build:ipc-dev": "cd dev && npm run build",
"build:runtime-desktop-prod": "esbuild desktop/main.js --bundle --minify --outfile=runtime_prod_desktop.js --define:ENV=1",
"build:runtime-desktop-dev": "esbuild desktop/main.js --bundle --sourcemap=inline --outfile=runtime_dev_desktop.js --define:ENV=0",