mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-28 12:27:16 +03:00
feat(examples): showcase basics of multiwindows feature on api example (#1468)
This commit is contained in:
parent
186deb43d5
commit
5b6c7bb6ee
@ -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();
|
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
@ -1,5 +1,5 @@
|
|||||||
<script>
|
<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 as openDialog } from "@tauri-apps/api/dialog";
|
||||||
import { open } from "@tauri-apps/api/shell";
|
import { open } from "@tauri-apps/api/shell";
|
||||||
|
|
||||||
@ -12,7 +12,6 @@
|
|||||||
unminimize,
|
unminimize,
|
||||||
show,
|
show,
|
||||||
hide,
|
hide,
|
||||||
setTransparent,
|
|
||||||
setDecorations,
|
setDecorations,
|
||||||
setAlwaysOnTop,
|
setAlwaysOnTop,
|
||||||
setWidth,
|
setWidth,
|
||||||
@ -27,6 +26,8 @@
|
|||||||
setIcon,
|
setIcon,
|
||||||
} = appWindow;
|
} = appWindow;
|
||||||
|
|
||||||
|
export let onMessage;
|
||||||
|
|
||||||
let urlValue = "https://tauri.studio";
|
let urlValue = "https://tauri.studio";
|
||||||
let resizable = true;
|
let resizable = true;
|
||||||
let maximized = false;
|
let maximized = false;
|
||||||
@ -69,6 +70,13 @@
|
|||||||
}).then(setIcon);
|
}).then(setIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
const webview = new WebviewWindow(Math.random().toString());
|
||||||
|
webview.once('tauri://error', function () {
|
||||||
|
onMessage("Error creating new webview")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
$: setResizable(resizable);
|
$: setResizable(resizable);
|
||||||
$: maximized ? maximize() : unmaximize();
|
$: maximized ? maximize() : unmaximize();
|
||||||
//$: setTransparent(transparent)
|
//$: setTransparent(transparent)
|
||||||
@ -174,6 +182,7 @@
|
|||||||
<input id="url" bind:value={urlValue} />
|
<input id="url" bind:value={urlValue} />
|
||||||
<button class="button" id="open-url"> Open URL </button>
|
<button class="button" id="open-url"> Open URL </button>
|
||||||
</form>
|
</form>
|
||||||
|
<button class="button" on:click={createWindow}>New window</button>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.flex-row {
|
.flex-row {
|
||||||
|
@ -477,7 +477,7 @@ export class WindowManager {
|
|||||||
const appWindow = new WindowManager()
|
const appWindow = new WindowManager()
|
||||||
|
|
||||||
export interface WindowOptions {
|
export interface WindowOptions {
|
||||||
url?: 'app' | string
|
url?: string
|
||||||
x?: number
|
x?: number
|
||||||
y?: number
|
y?: number
|
||||||
width?: number
|
width?: number
|
||||||
|
Loading…
Reference in New Issue
Block a user