mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-06 17:01:33 +08:00

This update adds implementation to several menu item functions, replacing their previous 'not implemented' state. This includes actions for close, reload, forcing reload, toggling of fullscreen, reset zoom, and others. The update also includes modifications for the handling of developer tools toggle under different build configurations. This refactoring is aimed to standardize devtools configuration across different operating systems.
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
//go:build darwin && (!production || devtools)
|
|
|
|
package application
|
|
|
|
/*
|
|
#cgo CFLAGS: -mmacosx-version-min=10.13 -x objective-c
|
|
#cgo LDFLAGS: -framework Cocoa
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#include "webview_window_darwin.h"
|
|
|
|
@interface _WKInspector : NSObject
|
|
- (void)show;
|
|
- (void)detach;
|
|
@end
|
|
|
|
@interface WKWebView ()
|
|
- (_WKInspector *)_inspector;
|
|
@end
|
|
|
|
//void showDevTools(void *window) {
|
|
// // get main window
|
|
// WebviewWindow* nsWindow = (WebviewWindow*)window;
|
|
// dispatch_async(dispatch_get_main_queue(), ^{
|
|
// [nsWindow.webView._inspector show];
|
|
// });
|
|
//}
|
|
|
|
void showDevTools(void *window) {
|
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
if (@available(macOS 12.0, *)) {
|
|
WebviewWindow* nsWindow = (WebviewWindow*)window;
|
|
|
|
@try {
|
|
[nsWindow.webView._inspector show];
|
|
} @catch (NSException *exception) {
|
|
NSLog(@"Opening the inspector failed: %@", exception.reason);
|
|
return;
|
|
}
|
|
} else {
|
|
NSLog(@"Opening the inspector needs at least MacOS 12");
|
|
}
|
|
});
|
|
#endif
|
|
}
|
|
|
|
// Enable NSWindow devtools
|
|
void windowEnableDevTools(void* nsWindow) {
|
|
WebviewWindow* window = (WebviewWindow*)nsWindow;
|
|
// Enable devtools in webview
|
|
[window.webView.configuration.preferences setValue:@YES forKey:@"developerExtrasEnabled"];
|
|
}
|
|
|
|
*/
|
|
import "C"
|
|
import "unsafe"
|
|
|
|
func init() {
|
|
showDevTools = func(window unsafe.Pointer) {
|
|
C.showDevTools(window)
|
|
}
|
|
}
|
|
|
|
func (w *macosWebviewWindow) enableDevTools() {
|
|
C.windowEnableDevTools(w.nsWindow)
|
|
}
|