5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 19:50:15 +08:00

Add Environment and WindowReloadApp calls to runtime. Updated default templates.

This commit is contained in:
Lea Anthony 2022-04-20 20:28:41 +10:00
parent 2e3c90c096
commit f6257d3d31
40 changed files with 440 additions and 48 deletions

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -185,7 +185,7 @@ func CreateApp(appoptions *options.App) (*App, error) {
} }
eventHandler := runtime.NewEvents(myLogger) eventHandler := runtime.NewEvents(myLogger)
ctx = context.WithValue(ctx, "events", eventHandler) ctx = context.WithValue(ctx, "events", eventHandler)
messageDispatcher := dispatcher.NewDispatcher(myLogger, appBindings, eventHandler) messageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler)
// Create the frontends and register to event handler // Create the frontends and register to event handler
desktopFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher) desktopFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)

View File

@ -85,8 +85,6 @@ func CreateApp(appoptions *options.App) (*App, error) {
appBindings := binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions) appBindings := binding.NewBindings(myLogger, appoptions.Bind, bindingExemptions)
eventHandler := runtime.NewEvents(myLogger) eventHandler := runtime.NewEvents(myLogger)
ctx = context.WithValue(ctx, "events", eventHandler) ctx = context.WithValue(ctx, "events", eventHandler)
messageDispatcher := dispatcher.NewDispatcher(myLogger, appBindings, eventHandler)
// Attach logger to context // Attach logger to context
if debug { if debug {
ctx = context.WithValue(ctx, "buildtype", "debug") ctx = context.WithValue(ctx, "buildtype", "debug")
@ -94,6 +92,7 @@ func CreateApp(appoptions *options.App) (*App, error) {
ctx = context.WithValue(ctx, "buildtype", "production") ctx = context.WithValue(ctx, "buildtype", "production")
} }
messageDispatcher := dispatcher.NewDispatcher(ctx, myLogger, appBindings, eventHandler)
appFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher) appFrontend := desktop.NewFrontend(ctx, appoptions, myLogger, appBindings, messageDispatcher)
eventHandler.AddFrontend(appFrontend) eventHandler.AddFrontend(appFrontend)

View File

@ -34,6 +34,8 @@ import (
"github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options"
) )
const startURL = "wails://wails/"
var messageBuffer = make(chan string, 100) var messageBuffer = make(chan string, 100)
var requestBuffer = make(chan *request, 100) var requestBuffer = make(chan *request, 100)
var callbackBuffer = make(chan uint, 10) var callbackBuffer = make(chan uint, 10)
@ -65,7 +67,7 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
dispatcher: dispatcher, dispatcher: dispatcher,
ctx: ctx, ctx: ctx,
} }
result.startURL, _ = url.Parse("wails://wails/") result.startURL, _ = url.Parse(startURL)
if _starturl, _ := ctx.Value("starturl").(*url.URL); _starturl != nil { if _starturl, _ := ctx.Value("starturl").(*url.URL); _starturl != nil {
result.startURL = _starturl result.startURL = _starturl
@ -113,6 +115,10 @@ func (f *Frontend) WindowReload() {
f.ExecJS("runtime.WindowReload();") f.ExecJS("runtime.WindowReload();")
} }
func (f *Frontend) WindowReloadApp() {
f.ExecJS(fmt.Sprintf("window.location.href = '%s';", startURL))
}
func (f *Frontend) WindowSetSystemDefaultTheme() { func (f *Frontend) WindowSetSystemDefaultTheme() {
return return
} }

View File

@ -31,6 +31,8 @@ import (
"github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options"
) )
const startURL = "wails://wails/"
type Frontend struct { type Frontend struct {
// Context // Context
@ -66,7 +68,7 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
dispatcher: dispatcher, dispatcher: dispatcher,
ctx: ctx, ctx: ctx,
} }
result.startURL, _ = url.Parse("wails://wails/") result.startURL, _ = url.Parse(startURL)
if _starturl, _ := ctx.Value("starturl").(*url.URL); _starturl != nil { if _starturl, _ := ctx.Value("starturl").(*url.URL); _starturl != nil {
result.startURL = _starturl result.startURL = _starturl
@ -169,6 +171,10 @@ func (f *Frontend) WindowUnfullscreen() {
f.mainWindow.UnFullscreen() f.mainWindow.UnFullscreen()
} }
func (f *Frontend) WindowReloadApp() {
f.ExecJS(fmt.Sprintf("window.location.href = '%s';", startURL))
}
func (f *Frontend) WindowShow() { func (f *Frontend) WindowShow() {
f.mainWindow.Show() f.mainWindow.Show()
} }

View File

@ -29,6 +29,8 @@ import (
"github.com/wailsapp/wails/v2/pkg/options/windows" "github.com/wailsapp/wails/v2/pkg/options/windows"
) )
const startURL = "http://wails.localhost/"
type Frontend struct { type Frontend struct {
// Context // Context
@ -69,7 +71,7 @@ func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.
} }
// We currently can't use wails://wails/ as other platforms do, therefore we map the assets sever onto the following url. // We currently can't use wails://wails/ as other platforms do, therefore we map the assets sever onto the following url.
result.startURL, _ = url.Parse("http://wails.localhost/") result.startURL, _ = url.Parse(startURL)
if _starturl, _ := ctx.Value("starturl").(*url.URL); _starturl != nil { if _starturl, _ := ctx.Value("starturl").(*url.URL); _starturl != nil {
result.startURL = _starturl result.startURL = _starturl
@ -209,6 +211,10 @@ func (f *Frontend) WindowFullscreen() {
f.mainWindow.Fullscreen() f.mainWindow.Fullscreen()
} }
func (f *Frontend) WindowReloadApp() {
f.ExecJS(fmt.Sprintf("window.location.href = '%s';", startURL))
}
func (f *Frontend) WindowUnfullscreen() { func (f *Frontend) WindowUnfullscreen() {
runtime.LockOSThread() runtime.LockOSThread()
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false { if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {

View File

@ -1,6 +1,7 @@
package dispatcher package dispatcher
import ( import (
"context"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/wailsapp/wails/v2/internal/binding" "github.com/wailsapp/wails/v2/internal/binding"
"github.com/wailsapp/wails/v2/internal/frontend" "github.com/wailsapp/wails/v2/internal/frontend"
@ -12,14 +13,16 @@ type Dispatcher struct {
bindings *binding.Bindings bindings *binding.Bindings
events frontend.Events events frontend.Events
bindingsDB *binding.DB bindingsDB *binding.DB
ctx context.Context
} }
func NewDispatcher(log *logger.Logger, bindings *binding.Bindings, events frontend.Events) *Dispatcher { func NewDispatcher(ctx context.Context, log *logger.Logger, bindings *binding.Bindings, events frontend.Events) *Dispatcher {
return &Dispatcher{ return &Dispatcher{
log: log, log: log,
bindings: bindings, bindings: bindings,
events: events, events: events,
bindingsDB: bindings.DB(), bindingsDB: bindings.DB(),
ctx: ctx,
} }
} }

View File

@ -2,6 +2,7 @@ package dispatcher
import ( import (
"fmt" "fmt"
"github.com/wailsapp/wails/v2/pkg/runtime"
"strings" "strings"
"github.com/wailsapp/wails/v2/internal/frontend" "github.com/wailsapp/wails/v2/internal/frontend"
@ -31,6 +32,8 @@ func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Fron
case "WindowGetSize": case "WindowGetSize":
w, h := sender.WindowGetSize() w, h := sender.WindowGetSize()
return &size{w, h}, nil return &size{w, h}, nil
case "Environment":
return runtime.Environment(d.ctx), nil
default: default:
return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name) return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name)
} }

View File

@ -20,7 +20,7 @@ func (d *Dispatcher) mustAtoI(input string) int {
func (d *Dispatcher) processWindowMessage(message string, sender frontend.Frontend) (string, error) { func (d *Dispatcher) processWindowMessage(message string, sender frontend.Frontend) (string, error) {
if len(message) < 2 { if len(message) < 2 {
return "", errors.New("Invalid Event Message: " + message) return "", errors.New("Invalid Window Message: " + message)
} }
switch message[1] { switch message[1] {
@ -56,6 +56,8 @@ func (d *Dispatcher) processWindowMessage(message string, sender frontend.Fronte
go sender.WindowHide() go sender.WindowHide()
case 'S': case 'S':
go sender.WindowShow() go sender.WindowShow()
case 'R':
go sender.WindowReloadApp()
case 'r': case 'r':
var rgba options.RGBA var rgba options.RGBA
err := json.Unmarshal([]byte(message[3:]), &rgba) err := json.Unmarshal([]byte(message[3:]), &rgba)

View File

@ -87,6 +87,7 @@ type Frontend interface {
WindowUnfullscreen() WindowUnfullscreen()
WindowSetRGBA(col *options.RGBA) WindowSetRGBA(col *options.RGBA)
WindowReload() WindowReload()
WindowReloadApp()
WindowSetSystemDefaultTheme() WindowSetSystemDefaultTheme()
WindowSetLightTheme() WindowSetLightTheme()
WindowSetDarkTheme() WindowSetDarkTheme()

View File

@ -10,7 +10,7 @@ The electron alternative for Go
/* jshint esversion: 9 */ /* jshint esversion: 9 */
import * as Log from './log'; import * as Log from './log';
import {eventListeners, EventsEmit, EventsNotify, EventsOff, EventsOn, EventsOnce, EventsOnMultiple} from './events'; import {eventListeners, EventsEmit, EventsNotify, EventsOff, EventsOn, EventsOnce, EventsOnMultiple} from './events';
import {Callback, callbacks} from './calls'; import {Call, Callback, callbacks} from './calls';
import {SetBindings} from "./bindings"; import {SetBindings} from "./bindings";
import * as Window from "./window"; import * as Window from "./window";
import * as Browser from "./browser"; import * as Browser from "./browser";
@ -20,6 +20,10 @@ export function Quit() {
window.WailsInvoke('Q'); window.WailsInvoke('Q');
} }
export function Environment() {
return Call(":wails:Environment");
}
// The JS runtime // The JS runtime
window.runtime = { window.runtime = {
...Log, ...Log,
@ -30,6 +34,7 @@ window.runtime = {
EventsOnMultiple, EventsOnMultiple,
EventsEmit, EventsEmit,
EventsOff, EventsOff,
Environment,
Quit Quit
}; };
@ -64,6 +69,10 @@ if (ENV === 0) {
var dragTimeOut; var dragTimeOut;
var dragLastTime = 0; var dragLastTime = 0;
function drag() {
window.WailsInvoke("drag");
}
// Setup drag handler // Setup drag handler
// Based on code from: https://github.com/patr0nus/DeskGap // Based on code from: https://github.com/patr0nus/DeskGap
window.addEventListener('mousedown', (e) => { window.addEventListener('mousedown', (e) => {
@ -88,12 +97,10 @@ window.addEventListener('mousedown', (e) => {
} }
} }
if (new Date().getTime() - dragLastTime < window.wails.flags.dbClickInterval) { if (new Date().getTime() - dragLastTime < window.wails.flags.dbClickInterval) {
clearTimeout(dragTimeOut) clearTimeout(dragTimeOut);
break; break;
} }
dragTimeOut = setTimeout(function () { dragTimeOut = setTimeout(drag, window.wails.flags.dbClickInterval);
window.WailsInvoke("drag");
}, window.wails.flags.dbClickInterval)
dragLastTime = new Date().getTime(); dragLastTime = new Date().getTime();
e.preventDefault(); e.preventDefault();
break; break;

View File

@ -17,16 +17,20 @@ export function WindowReload() {
window.location.reload(); window.location.reload();
} }
export function WindowReloadApp() {
window.WailsInvoke('WR');
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.WailsInvoke('WASDT'); window.WailsInvoke('WASDT');
} }
export function WindowSetLightTheme() { export function WindowSetLightTheme() {
window.WailsInvoke('WALT'); window.WailsInvoke('WALT');
} }
export function WindowSetDarkTheme() { export function WindowSetDarkTheme() {
window.WailsInvoke('WADT'); window.WailsInvoke('WADT');
} }
/** /**
@ -205,7 +209,7 @@ export function WindowUnminimise() {
* @param {number} A Alpha * @param {number} A Alpha
*/ */
export function WindowSetRGBA(R, G, B, A) { export function WindowSetRGBA(R, G, B, A) {
let rgba = JSON.stringify({r:R || 0, g:G || 0, b:B || 0, a:A || 255}); let rgba = JSON.stringify({r: R || 0, g: G || 0, b: B || 0, a: A || 255});
window.WailsInvoke('Wr:' + rgba); window.WailsInvoke('Wr:' + rgba);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,12 @@ export interface Size {
h: number; h: number;
} }
// Environment information such as platform, buildtype, ...
export interface EnvironmentInfo {
buildType: string;
platform: string;
arch: string;
}
// [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit) // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
// emits the given event. Optional data may be passed with the event. // emits the given event. Optional data may be passed with the event.
@ -72,6 +78,10 @@ export function LogWarning(message: string): void;
// Forces a reload by the main application as well as connected browsers. // Forces a reload by the main application as well as connected browsers.
export function WindowReload(): void; export function WindowReload(): void;
// [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
// Reloads the application frontend.
export function WindowReloadApp(): void;
// [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme) // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
// *Windows only* // *Windows only*
// Sets window theme to system default (dark/light). // Sets window theme to system default (dark/light).
@ -161,10 +171,18 @@ export function WindowUnminimise(): void;
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void; export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
// Navigates back to the application after navigating away
export function NavigateBackToApp(): void;
// [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl) // [BrowserOpenURL](https://wails.io/docs/next/reference/runtime/browser#browseropenurl)
// Opens the given URL in the system browser. // Opens the given URL in the system browser.
export function BrowserOpenURL(url: string): void; export function BrowserOpenURL(url: string): void;
// []()
//
export function Environment(): EnvironmentInfo;
// [Quit](https://wails.io/docs/next/reference/runtime/intro#quit) // [Quit](https://wails.io/docs/next/reference/runtime/intro#quit)
// Quits the application. // Quits the application.
export function Quit(): void; export function Quit(): void;

View File

@ -61,6 +61,10 @@ export function WindowReload() {
window.runtime.WindowReload(); window.runtime.WindowReload();
} }
export function WindowReloadApp() {
window.runtime.WindowReloadApp();
}
export function WindowSetSystemDefaultTheme() { export function WindowSetSystemDefaultTheme() {
window.runtime.WindowSetSystemDefaultTheme(); window.runtime.WindowSetSystemDefaultTheme();
} }
@ -90,7 +94,7 @@ export function WindowUnfullscreen() {
} }
export function WindowGetSize() { export function WindowGetSize() {
window.runtime.WindowGetSize(); return window.runtime.WindowGetSize();
} }
export function WindowSetSize(width, height) { export function WindowSetSize(width, height) {
@ -110,7 +114,7 @@ export function WindowSetPosition(x, y) {
} }
export function WindowGetPosition() { export function WindowGetPosition() {
window.runtime.WindowGetPosition(); return window.runtime.WindowGetPosition();
} }
export function WindowHide() { export function WindowHide() {
@ -149,6 +153,10 @@ export function BrowserOpenURL(url) {
window.runtime.BrowserOpenURL(url); window.runtime.BrowserOpenURL(url);
} }
export function Environment() {
return window.runtime.Environment();
}
export function Quit() { export function Quit() {
window.runtime.Quit(); window.runtime.Quit();
} }

View File

@ -69,6 +69,8 @@ func Quit(ctx context.Context) {
type EnvironmentInfo struct { type EnvironmentInfo struct {
BuildType string `json:"buildtype"` BuildType string `json:"buildtype"`
Platform string `json:"platform"`
Arch string `json:"arch"`
} }
func Environment(ctx context.Context) EnvironmentInfo { func Environment(ctx context.Context) EnvironmentInfo {
@ -77,5 +79,7 @@ func Environment(ctx context.Context) EnvironmentInfo {
if buildType != nil { if buildType != nil {
result.BuildType = buildType.(string) result.BuildType = buildType.(string)
} }
result.Platform = goruntime.GOOS
result.Arch = goruntime.GOARCH
return result return result
} }

View File

@ -36,6 +36,12 @@ func WindowReload(ctx context.Context) {
appFrontend.WindowReload() appFrontend.WindowReload()
} }
// WindowReloadApp will reload the application
func WindowReloadApp(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowReloadApp()
}
func WindowSetSystemDefaultTheme(ctx context.Context) { func WindowSetSystemDefaultTheme(ctx context.Context) {
appFrontend := getFrontend(ctx) appFrontend := getFrontend(ctx)
appFrontend.WindowSetSystemDefaultTheme() appFrontend.WindowSetSystemDefaultTheme()

View File

@ -41,7 +41,16 @@ Go Signature: `WindowReload(ctx context.Context)`
JS Signature: `WindowReload()` JS Signature: `WindowReload()`
Performs a "reload" (Reloads index.html) Performs a "reload" (Reloads current page).
### WindowReloadApp
Go Signature: `WindowReloadApp(ctx context.Context)`
JS Signature: `WindowReloadApp()`
Reloads the application frontend.
### WindowSetSy
### WindowSetSystemDefaultTheme ### WindowSetSystemDefaultTheme
Go Signature: `WindowSetSystemDefaultTheme(ctx context.Context)` Go Signature: `WindowSetSystemDefaultTheme(ctx context.Context)`