feat(examples): showcase basics of multiwindows feature on api example (#1468)

This commit is contained in:
Lucas Fernandes Nogueira 2021-04-12 23:35:57 -03:00 committed by GitHub
parent 186deb43d5
commit 5b6c7bb6ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 7 deletions

View File

@ -422,7 +422,7 @@ where
},
)
}
WindowUrl::External(url) => (false, url.to_string()),
WindowUrl::External(url) => (url.as_str().starts_with("tauri://"), url.to_string()),
};
let attributes = pending.attributes.clone();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
<script>
import { appWindow } from "@tauri-apps/api/window";
import { appWindow, WebviewWindow } from "@tauri-apps/api/window";
import { open as openDialog } from "@tauri-apps/api/dialog";
import { open } from "@tauri-apps/api/shell";
@ -12,7 +12,6 @@
unminimize,
show,
hide,
setTransparent,
setDecorations,
setAlwaysOnTop,
setWidth,
@ -27,6 +26,8 @@
setIcon,
} = appWindow;
export let onMessage;
let urlValue = "https://tauri.studio";
let resizable = true;
let maximized = false;
@ -69,6 +70,13 @@
}).then(setIcon);
}
function createWindow() {
const webview = new WebviewWindow(Math.random().toString());
webview.once('tauri://error', function () {
onMessage("Error creating new webview")
})
}
$: setResizable(resizable);
$: maximized ? maximize() : unmaximize();
//$: setTransparent(transparent)
@ -174,6 +182,7 @@
<input id="url" bind:value={urlValue} />
<button class="button" id="open-url"> Open URL </button>
</form>
<button class="button" on:click={createWindow}>New window</button>
<style>
.flex-row {

View File

@ -477,7 +477,7 @@ export class WindowManager {
const appWindow = new WindowManager()
export interface WindowOptions {
url?: 'app' | string
url?: string
x?: number
y?: number
width?: number