pull/426/head
Lucas Nogueira 2 years ago
parent b9720d634b
commit 23d3205d30
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

@ -2,4 +2,4 @@
"shell": "patch"
---
Added `Command::arg`, `Command::env` and changed `Command::new` input type.
Added `Command::arg`, `Command::env` and changed `Command::new` input type.

@ -1,7 +1,7 @@
<script>
import { writable } from "svelte/store";
import { open } from "@tauri-apps/plugin-shell";
import { appWindow, getCurrent } from "@tauri-apps/plugin-window";
import { getCurrent } from "@tauri-apps/plugin-window";
import * as os from "@tauri-apps/plugin-os";
import Welcome from "./views/Welcome.svelte";
@ -22,6 +22,8 @@
import { onMount } from "svelte";
import { ask } from "@tauri-apps/plugin-dialog";
const appWindow = getCurrent();
if (appWindow.label !== "main") {
appWindow.onCloseRequested(async (event) => {
const confirmed = await confirm("Are you sure?");
@ -121,20 +123,20 @@
// Window controls
let isWindowMaximized;
onMount(async () => {
const window = getCurrent();
isWindowMaximized = await window.isMaximized();
isWindowMaximized = await appWindow.isMaximized();
window.onResized(async () => {
isWindowMaximized = await window.isMaximized();
isWindowMaximized = await appWindow.isMaximized();
});
});
function minimize() {
getCurrent().minimize();
appWindow.minimize();
}
async function toggleMaximize() {
const window = getCurrent();
(await window.isMaximized()) ? window.unmaximize() : window.maximize();
(await appWindow.isMaximized())
? appWindow.unmaximize()
: appWindow.maximize();
}
let confirmed_close = false;
@ -147,7 +149,7 @@
}
);
if (confirmed_close) {
getCurrent().close();
appWindow.close();
}
}
}

@ -1,8 +1,10 @@
<script>
import { appWindow } from "@tauri-apps/plugin-window";
import { getCurrent } from "@tauri-apps/plugin-window";
import { invoke } from "@tauri-apps/api/tauri";
import { onMount, onDestroy } from "svelte";
const appWindow = getCurrent();
export let onMessage;
let unlisten;

@ -1,7 +1,6 @@
<script>
import {
appWindow,
WebviewWindow,
getCurrent,
LogicalSize,
UserAttentionType,
PhysicalSize,
@ -12,6 +11,8 @@
import { open as openDialog } from "@tauri-apps/plugin-dialog";
import { open } from "@tauri-apps/plugin-shell";
const appWindow = getCurrent();
let selectedWindow = appWindow.label;
const windowMap = {
[appWindow.label]: appWindow,

@ -60,18 +60,20 @@ fn main() {
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
```javascript
import { appWindow, WebviewWindow } from "@tauri-apps/plugin-window";
import { getCurrent, Window } from "@tauri-apps/plugin-window";
const appWindow = getCurrent();
// manipulating this window
await appWindow.setResizable(false);
// Creating new windows:
// loading embedded asset:
const webview = new WebviewWindow("theUniqueLabel", {
const webview = new Window("theUniqueLabel", {
url: "path/to/page.html",
});
// alternatively, load a remote URL:
const webview = new WebviewWindow("theUniqueLabel", {
const webview = new Window("theUniqueLabel", {
url: "https://github.com/tauri-apps/tauri",
});
```

@ -335,7 +335,7 @@ class Window {
listeners: Record<string, Array<EventCallback<any>>>;
/**
* Creates a new WebviewWindow.
* Creates a new Window.
* @example
* ```typescript
* import { Window } from '@tauri-apps/plugin-window';
@ -374,22 +374,22 @@ class Window {
}
/**
* Gets the WebviewWindow for the webview associated with the given label.
* Gets the Window for the webview associated with the given label.
* @example
* ```typescript
* import { WebviewWindow } from '@tauri-apps/plugin-window';
* const mainWindow = WebviewWindow.getByLabel('main');
* import { Window } from '@tauri-apps/plugin-window';
* const mainWindow = Window.getByLabel('main');
* ```
*
* @param label The webview window label.
* @returns The WebviewWindow instance to communicate with the webview or null if the webview doesn't exist.
* @returns The Window instance to communicate with the webview or null if the webview doesn't exist.
*
* @since 2.0.0
*/
static getByLabel(label: string): Window | null {
if (getAll().some((w) => w.label === label)) {
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
return new WebviewWindow(label, { skip: true });
return new Window(label, { skip: true });
}
return null;
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save