mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 17:52:29 +08:00
[v2] Update Menu runtime
This commit is contained in:
parent
3c0da9fd15
commit
d6cdd1df82
@ -118,8 +118,8 @@ func (b BridgeClient) DarkModeEnabled(callbackID string) {
|
||||
b.session.log.Info("DarkModeEnabled unsupported in Bridge mode")
|
||||
}
|
||||
|
||||
func (b BridgeClient) SetApplicationMenu(menuJSON string) {
|
||||
b.session.log.Info("SetApplicationMenu unsupported in Bridge mode")
|
||||
func (b BridgeClient) MenuSetApplicationMenu(menuJSON string) {
|
||||
b.session.log.Info("MenuSetApplicationMenu unsupported in Bridge mode")
|
||||
}
|
||||
|
||||
func (b BridgeClient) SetTrayMenu(trayMenuJSON string) {
|
||||
|
@ -120,10 +120,10 @@ func processMenuItem(parent *winc.MenuItem, menuItem *menu.MenuItem) {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Frontend) SetApplicationMenu(menu *menu.Menu) {
|
||||
func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) {
|
||||
f.mainWindow.SetApplicationMenu(menu)
|
||||
}
|
||||
|
||||
func (f *Frontend) UpdateApplicationMenu() {
|
||||
func (f *Frontend) MenuUpdateApplicationMenu() {
|
||||
processMenu(f.mainWindow, f.mainWindow.applicationMenu)
|
||||
}
|
||||
|
@ -230,12 +230,12 @@ func (d *DevWebServer) WindowSetRGBA(col *options.RGBA) {
|
||||
d.desktopFrontend.WindowSetRGBA(col)
|
||||
}
|
||||
|
||||
func (d *DevWebServer) SetApplicationMenu(menu *menu.Menu) {
|
||||
d.desktopFrontend.SetApplicationMenu(menu)
|
||||
func (d *DevWebServer) MenuSetApplicationMenu(menu *menu.Menu) {
|
||||
d.desktopFrontend.MenuSetApplicationMenu(menu)
|
||||
}
|
||||
|
||||
func (d *DevWebServer) UpdateApplicationMenu() {
|
||||
d.desktopFrontend.UpdateApplicationMenu()
|
||||
func (d *DevWebServer) MenuUpdateApplicationMenu() {
|
||||
d.desktopFrontend.MenuUpdateApplicationMenu()
|
||||
}
|
||||
|
||||
func (d *DevWebServer) Notify(name string, data ...interface{}) {
|
||||
|
@ -89,8 +89,8 @@ type Frontend interface {
|
||||
WindowReload()
|
||||
|
||||
// Menus
|
||||
SetApplicationMenu(menu *menu.Menu)
|
||||
UpdateApplicationMenu()
|
||||
MenuSetApplicationMenu(menu *menu.Menu)
|
||||
MenuUpdateApplicationMenu()
|
||||
//SetTrayMenu(menu *menu.TrayMenu)
|
||||
//UpdateTrayMenuLabel(menu *menu.TrayMenu)
|
||||
//UpdateContextMenu(contextMenu *menu.ContextMenu)
|
||||
|
@ -1,11 +1,11 @@
|
||||
(() => {
|
||||
var __defProp = Object.defineProperty;
|
||||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
||||
var __export = (target, all) => {
|
||||
__markAsModule(target);
|
||||
for (var name in all)
|
||||
__defProp(target, name, {get: all[name], enumerable: true});
|
||||
};
|
||||
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
||||
var __export = (target, all) => {
|
||||
__markAsModule(target);
|
||||
for (var name in all)
|
||||
__defProp(target, name, {get: all[name], enumerable: true});
|
||||
};
|
||||
|
||||
// desktop/log.js
|
||||
var log_exports = {};
|
||||
@ -138,17 +138,17 @@
|
||||
if (timeout == null) {
|
||||
timeout = 0;
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
var callbackID;
|
||||
do {
|
||||
callbackID = name + "-" + randomFunc();
|
||||
} while (callbacks[callbackID]);
|
||||
var timeoutHandle;
|
||||
if (timeout > 0) {
|
||||
timeoutHandle = setTimeout(function () {
|
||||
reject(Error("Call to " + name + " timed out. Request ID: " + callbackID));
|
||||
}, timeout);
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
var callbackID;
|
||||
do {
|
||||
callbackID = name + "-" + randomFunc();
|
||||
} while (callbacks[callbackID]);
|
||||
var timeoutHandle;
|
||||
if (timeout > 0) {
|
||||
timeoutHandle = setTimeout(function () {
|
||||
reject(Error("Call to " + name + " timed out. Request ID: " + callbackID));
|
||||
}, timeout);
|
||||
}
|
||||
callbacks[callbackID] = {
|
||||
timeoutHandle,
|
||||
reject,
|
||||
@ -205,20 +205,20 @@
|
||||
Object.keys(bindingsMap[packageName]).forEach((structName) => {
|
||||
window.go[packageName][structName] = window.go[packageName][structName] || {};
|
||||
Object.keys(bindingsMap[packageName][structName]).forEach((methodName) => {
|
||||
window.go[packageName][structName][methodName] = function () {
|
||||
let timeout = 0;
|
||||
window.go[packageName][structName][methodName] = function () {
|
||||
let timeout = 0;
|
||||
|
||||
function dynamic() {
|
||||
const args = [].slice.call(arguments);
|
||||
return Call([packageName, structName, methodName].join("."), args, timeout);
|
||||
}
|
||||
function dynamic() {
|
||||
const args = [].slice.call(arguments);
|
||||
return Call([packageName, structName, methodName].join("."), args, timeout);
|
||||
}
|
||||
|
||||
dynamic.setTimeout = function (newTimeout) {
|
||||
timeout = newTimeout;
|
||||
};
|
||||
dynamic.getTimeout = function () {
|
||||
return timeout;
|
||||
};
|
||||
dynamic.setTimeout = function (newTimeout) {
|
||||
timeout = newTimeout;
|
||||
};
|
||||
dynamic.getTimeout = function () {
|
||||
return timeout;
|
||||
};
|
||||
return dynamic;
|
||||
}();
|
||||
});
|
||||
@ -231,23 +231,23 @@
|
||||
__export(window_exports, {
|
||||
WindowCenter: () => WindowCenter,
|
||||
WindowClose: () => WindowClose,
|
||||
WindowFullscreen: () => WindowFullscreen,
|
||||
WindowGetPosition: () => WindowGetPosition,
|
||||
WindowGetSize: () => WindowGetSize,
|
||||
WindowHide: () => WindowHide,
|
||||
WindowMaximise: () => WindowMaximise,
|
||||
WindowMinimise: () => WindowMinimise,
|
||||
WindowReload: () => WindowReload,
|
||||
WindowSetMaxSize: () => WindowSetMaxSize,
|
||||
WindowSetMinSize: () => WindowSetMinSize,
|
||||
WindowSetPosition: () => WindowSetPosition,
|
||||
WindowSetRGBA: () => WindowSetRGBA,
|
||||
WindowSetSize: () => WindowSetSize,
|
||||
WindowSetTitle: () => WindowSetTitle,
|
||||
WindowShow: () => WindowShow,
|
||||
WindowUnFullscreen: () => WindowUnFullscreen,
|
||||
WindowUnmaximise: () => WindowUnmaximise,
|
||||
WindowUnminimise: () => WindowUnminimise
|
||||
WindowFullscreen: () => WindowFullscreen,
|
||||
WindowGetPosition: () => WindowGetPosition,
|
||||
WindowGetSize: () => WindowGetSize,
|
||||
WindowHide: () => WindowHide,
|
||||
WindowMaximise: () => WindowMaximise,
|
||||
WindowMinimise: () => WindowMinimise,
|
||||
WindowReload: () => WindowReload,
|
||||
WindowSetMaxSize: () => WindowSetMaxSize,
|
||||
WindowSetMinSize: () => WindowSetMinSize,
|
||||
WindowSetPosition: () => WindowSetPosition,
|
||||
WindowSetRGBA: () => WindowSetRGBA,
|
||||
WindowSetSize: () => WindowSetSize,
|
||||
WindowSetTitle: () => WindowSetTitle,
|
||||
WindowShow: () => WindowShow,
|
||||
WindowUnFullscreen: () => WindowUnFullscreen,
|
||||
WindowUnmaximise: () => WindowUnmaximise,
|
||||
WindowUnminimise: () => WindowUnminimise
|
||||
});
|
||||
function WindowReload() {
|
||||
window.location.reload();
|
||||
@ -282,43 +282,46 @@
|
||||
function WindowGetPosition() {
|
||||
return Call(":wails:WindowGetPos");
|
||||
}
|
||||
|
||||
function WindowHide() {
|
||||
window.WailsInvoke("WH");
|
||||
}
|
||||
|
||||
function WindowShow() {
|
||||
window.WailsInvoke("WS");
|
||||
}
|
||||
|
||||
function WindowMaximise() {
|
||||
window.WailsInvoke("WM");
|
||||
}
|
||||
|
||||
function WindowUnmaximise() {
|
||||
window.WailsInvoke("WU");
|
||||
}
|
||||
function WindowUnmaximise() {
|
||||
window.WailsInvoke("WU");
|
||||
}
|
||||
|
||||
function WindowMinimise() {
|
||||
window.WailsInvoke("Wm");
|
||||
}
|
||||
function WindowMinimise() {
|
||||
window.WailsInvoke("Wm");
|
||||
}
|
||||
|
||||
function WindowUnminimise() {
|
||||
window.WailsInvoke("Wu");
|
||||
}
|
||||
function WindowUnminimise() {
|
||||
window.WailsInvoke("Wu");
|
||||
}
|
||||
|
||||
function WindowSetRGBA(RGBA) {
|
||||
let rgba = JSON.stringify(RGBA);
|
||||
window.WailsInvoke("Wr:" + rgba);
|
||||
}
|
||||
function WindowSetRGBA(RGBA) {
|
||||
let rgba = JSON.stringify(RGBA);
|
||||
window.WailsInvoke("Wr:" + rgba);
|
||||
}
|
||||
|
||||
function WindowClose() {
|
||||
window.WailsInvoke("WC");
|
||||
}
|
||||
function WindowClose() {
|
||||
window.WailsInvoke("WC");
|
||||
}
|
||||
|
||||
// desktop/main.js
|
||||
window.runtime = {
|
||||
...log_exports,
|
||||
...window_exports,
|
||||
EventsOn,
|
||||
EventsOnce,
|
||||
// desktop/main.js
|
||||
window.runtime = {
|
||||
...log_exports,
|
||||
...window_exports,
|
||||
EventsOn,
|
||||
EventsOnce,
|
||||
EventsOnMultiple,
|
||||
EventsEmit,
|
||||
EventsOff
|
||||
|
@ -2,31 +2,15 @@ package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
)
|
||||
|
||||
func UpdateApplicationMenu(ctx context.Context) {
|
||||
func MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu) {
|
||||
frontend := getFrontend(ctx)
|
||||
frontend.UpdateApplicationMenu()
|
||||
frontend.MenuSetApplicationMenu(menu)
|
||||
}
|
||||
|
||||
/*
|
||||
func UpdateContextMenu(ctx context.Context, contextMenu *menu.ContextMenu) {
|
||||
func MenuUpdateApplicationMenu(ctx context.Context) {
|
||||
frontend := getFrontend(ctx)
|
||||
bus.Publish("menu:updatecontextmenu", contextMenu)
|
||||
frontend.MenuUpdateApplicationMenu()
|
||||
}
|
||||
|
||||
func SetTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) {
|
||||
frontend := getFrontend(ctx)
|
||||
bus.Publish("menu:settraymenu", trayMenu)
|
||||
}
|
||||
|
||||
func UpdateTrayMenuLabel(ctx context.Context, trayMenu *menu.TrayMenu) {
|
||||
frontend := getFrontend(ctx)
|
||||
bus.Publish("menu:updatetraymenulabel", trayMenu)
|
||||
}
|
||||
|
||||
func DeleteTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) {
|
||||
frontend := getFrontend(ctx)
|
||||
bus.Publish("menu:deletetraymenu", trayMenu)
|
||||
}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user