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:
parent
badacdd45b
commit
eac8f23341
@ -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");
|
||||
}
|
||||
};
|
||||
|
8
v2/internal/frontend/runtime/ipc_darwin.go
Normal file
8
v2/internal/frontend/runtime/ipc_darwin.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build darwin
|
||||
|
||||
package runtime
|
||||
|
||||
import _ "embed"
|
||||
|
||||
//go:embed ipc_darwin.js
|
||||
var DesktopIPC []byte
|
1
v2/internal/frontend/runtime/ipc_darwin.js
Normal file
1
v2/internal/frontend/runtime/ipc_darwin.js
Normal file
@ -0,0 +1 @@
|
||||
(()=>{window.WailsInvoke=function(e){window.webkit.messageHandlers.external.postMessage(e)};})();
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user