|
@@ -219,17 +219,18 @@ function getAll(): WebviewWindow[] {
|
|
|
/** @ignore */
|
|
|
// events that are emitted right here instead of by the created webview
|
|
|
const localTauriEvents = ['tauri://created', 'tauri://error']
|
|
|
-
|
|
|
+/** @ignore */
|
|
|
+export type WindowLabel = string | null | undefined
|
|
|
/**
|
|
|
* A webview window handle allows emitting and listening to events from the backend that are tied to the window.
|
|
|
*/
|
|
|
class WebviewWindowHandle {
|
|
|
/** Window label. */
|
|
|
- label: string | null
|
|
|
+ label: WindowLabel
|
|
|
/** Local event listeners. */
|
|
|
listeners: { [key: string]: Array<EventCallback<any>> }
|
|
|
|
|
|
- constructor(label: string | null) {
|
|
|
+ constructor(label: WindowLabel) {
|
|
|
this.label = label
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
|
this.listeners = Object.create(null)
|
|
@@ -625,6 +626,26 @@ class WindowManager extends WebviewWindowHandle {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Toggles the window maximized state.
|
|
|
+ *
|
|
|
+ * @returns A promise indicating the success or failure of the operation.
|
|
|
+ */
|
|
|
+ async toggleMaximize(): Promise<void> {
|
|
|
+ return invokeTauriCommand({
|
|
|
+ __tauriModule: 'Window',
|
|
|
+ message: {
|
|
|
+ cmd: 'manage',
|
|
|
+ data: {
|
|
|
+ label: this.label,
|
|
|
+ cmd: {
|
|
|
+ type: 'toggleMaximize'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Minimizes the window.
|
|
|
*
|
|
@@ -1071,7 +1092,7 @@ class WindowManager extends WebviewWindowHandle {
|
|
|
* ```
|
|
|
*/
|
|
|
class WebviewWindow extends WindowManager {
|
|
|
- constructor(label: string | null, options: WindowOptions = {}) {
|
|
|
+ constructor(label: WindowLabel, options: WindowOptions = {}) {
|
|
|
super(label)
|
|
|
// @ts-expect-error
|
|
|
if (!options?.skip) {
|