mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Update system.Environment
This commit is contained in:
@@ -3,6 +3,7 @@ package application
|
||||
import (
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"github.com/wailsapp/wails/v3/internal/operatingsystem"
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
@@ -891,11 +892,15 @@ func (a *App) BrowserOpenFile(path string) error {
|
||||
}
|
||||
|
||||
func (a *App) Environment() EnvironmentInfo {
|
||||
return EnvironmentInfo{
|
||||
OS: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
Debug: a.isDebugMode,
|
||||
info, _ := operatingsystem.Info()
|
||||
result := EnvironmentInfo{
|
||||
OS: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
Debug: a.isDebugMode,
|
||||
OSInfo: info,
|
||||
}
|
||||
result.PlatformInfo = a.platformEnvironment()
|
||||
return result
|
||||
}
|
||||
|
||||
func (a *App) shouldQuit() bool {
|
||||
|
||||
@@ -355,3 +355,7 @@ func (a *App) logPlatformInfo() {
|
||||
a.info("Platform Info:", info.AsLogSlice()...)
|
||||
|
||||
}
|
||||
|
||||
func (a *App) platformEnvironment() map[string]any {
|
||||
return map[string]any{}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
package application
|
||||
|
||||
/*
|
||||
#include "gtk/gtk.h"
|
||||
#include "webkit2/webkit2.h"
|
||||
static guint get_compiled_gtk_major_version() { return GTK_MAJOR_VERSION; }
|
||||
static guint get_compiled_gtk_minor_version() { return GTK_MINOR_VERSION; }
|
||||
static guint get_compiled_gtk_micro_version() { return GTK_MICRO_VERSION; }
|
||||
static guint get_compiled_webkit_major_version() { return WEBKIT_MAJOR_VERSION; }
|
||||
static guint get_compiled_webkit_minor_version() { return WEBKIT_MINOR_VERSION; }
|
||||
static guint get_compiled_webkit_micro_version() { return WEBKIT_MICRO_VERSION; }
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
@@ -216,3 +226,33 @@ func processWindowEvent(windowID C.uint, eventID C.uint) {
|
||||
EventID: uint(eventID),
|
||||
}
|
||||
}
|
||||
|
||||
func buildVersionString(major, minor, micro C.uint) string {
|
||||
return fmt.Sprintf("%d.%d.%d", uint(major), uint(minor), uint(micro))
|
||||
}
|
||||
|
||||
func (a *App) platformEnvironment() map[string]any {
|
||||
result := map[string]any{}
|
||||
result["gtk3-compiled"] = buildVersionString(
|
||||
C.get_compiled_gtk_major_version(),
|
||||
C.get_compiled_gtk_minor_version(),
|
||||
C.get_compiled_gtk_micro_version(),
|
||||
)
|
||||
result["gtk3-runtime"] = buildVersionString(
|
||||
C.gtk_get_major_version(),
|
||||
C.gtk_get_minor_version(),
|
||||
C.gtk_get_micro_version(),
|
||||
)
|
||||
|
||||
result["webkit2gtk-compiled"] = buildVersionString(
|
||||
C.get_compiled_webkit_major_version(),
|
||||
C.get_compiled_webkit_minor_version(),
|
||||
C.get_compiled_webkit_micro_version(),
|
||||
)
|
||||
result["webkit2gtk-runtime"] = buildVersionString(
|
||||
C.webkit_get_major_version(),
|
||||
C.webkit_get_minor_version(),
|
||||
C.webkit_get_micro_version(),
|
||||
)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -350,3 +350,11 @@ func (a *App) logPlatformInfo() {
|
||||
|
||||
a.info("Platform Info:", args...)
|
||||
}
|
||||
|
||||
func (a *App) platformEnvironment() map[string]any {
|
||||
result := map[string]any{}
|
||||
webviewVersion, _ := webviewloader.GetAvailableCoreWebView2BrowserVersionString(a.options.Windows.WebviewBrowserPath)
|
||||
result["Go-WebView2Loader"] = webviewloader.UsingGoWebview2Loader
|
||||
result["WebView2"] = webviewVersion
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package application
|
||||
|
||||
import "github.com/wailsapp/wails/v3/internal/operatingsystem"
|
||||
|
||||
// EnvironmentInfo represents information about the current environment.
|
||||
//
|
||||
// Fields:
|
||||
// - OS: the operating system that the program is running on.
|
||||
// - Arch: the architecture of the operating system.
|
||||
// - Debug: indicates whether debug mode is enabled.
|
||||
// - OSInfo: information about the operating system.
|
||||
type EnvironmentInfo struct {
|
||||
OS string
|
||||
Arch string
|
||||
Debug bool
|
||||
OS string
|
||||
Arch string
|
||||
Debug bool
|
||||
OSInfo *operatingsystem.OS
|
||||
PlatformInfo map[string]any
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user