mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-26 20:42:18 +03:00
58 lines
1.8 KiB
HTML
58 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<style>
|
|
#response {
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="window-label"></div>
|
|
<div id="container"></div>
|
|
<div id="response"></div>
|
|
|
|
<script>
|
|
const { WebviewWindow } = window.__TAURI__.webviewWindow
|
|
const thisTauriWindow = window.__TAURI__.window.getCurrent()
|
|
const windowLabel = thisTauriWindow.label
|
|
const windowLabelContainer = document.getElementById('window-label')
|
|
windowLabelContainer.innerText = 'This is the ' + windowLabel + ' window.'
|
|
|
|
const container = document.getElementById('container')
|
|
|
|
const responseContainer = document.getElementById('response')
|
|
function runCommand(commandName, args, optional) {
|
|
window.__TAURI__.core
|
|
.invoke(commandName, args)
|
|
.then((response) => {
|
|
responseContainer.innerText += `Ok(${response})\n\n`
|
|
})
|
|
.catch((error) => {
|
|
responseContainer.innerText += `Err(${error})\n\n`
|
|
})
|
|
}
|
|
window.__TAURI__.event.listen('tauri://window-created', function (event) {
|
|
responseContainer.innerText += 'Got window-created event\n\n'
|
|
})
|
|
|
|
const createWindowButton = document.createElement('button')
|
|
const windowId = Math.random().toString().replace('.', '')
|
|
let windowNumber = 1
|
|
createWindowButton.innerHTML = 'Create child window ' + windowNumber
|
|
createWindowButton.addEventListener('click', function () {
|
|
new WebviewWindow(`child-${windowId}-${windowNumber}`, {
|
|
title: 'Child',
|
|
width: 400,
|
|
height: 300,
|
|
parent: thisTauriWindow
|
|
})
|
|
windowNumber += 1
|
|
createWindowButton.innerHTML = 'Create child window ' + windowNumber
|
|
})
|
|
container.appendChild(createWindowButton)
|
|
</script>
|
|
</body>
|
|
</html>
|