mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-15 05:31:42 +03:00
6ec54c53b5
* feat(core): allow `dev_path`, `dist_dir` as array of paths, fixes #1897 * fix: clippy
58 lines
1.6 KiB
HTML
58 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Tauri</title>
|
|
</head>
|
|
|
|
<body>
|
|
<h3>Counter</h3>
|
|
<div>
|
|
<button id="increment-btn">Increment counter</button>
|
|
</div>
|
|
<h3>Database</h3>
|
|
<div>
|
|
<input id="store-input" placeholder="The value to store">
|
|
<button id="store-btn">Store</button>
|
|
</div>
|
|
<div>
|
|
<button id="read-btn">Read</button>
|
|
</div>
|
|
<div id="response"></div>
|
|
|
|
<script>
|
|
const KEY = 'db-key'
|
|
const storeBtn = document.querySelector('#store-btn')
|
|
const readBtn = document.querySelector('#read-btn')
|
|
const incrementBtn = document.querySelector('#increment-btn')
|
|
const storeInput = document.querySelector('#store-input')
|
|
const responseContainer = document.querySelector('#response')
|
|
|
|
function updateResponse(response) {
|
|
responseContainer.innerHTML = typeof response === "string" ? response : JSON.stringify(response)
|
|
}
|
|
|
|
incrementBtn.addEventListener('click', () => {
|
|
window.__TAURI__.invoke('increment_counter').then(updateResponse).catch(updateResponse)
|
|
})
|
|
|
|
storeBtn.addEventListener('click', () => {
|
|
window.__TAURI__.invoke('db_insert', {
|
|
key: KEY,
|
|
value: storeInput.value
|
|
}).then(updateResponse).catch(updateResponse)
|
|
})
|
|
|
|
readBtn.addEventListener('click', () => {
|
|
window.__TAURI__.invoke('db_read', {
|
|
key: KEY
|
|
}).then(updateResponse).catch(updateResponse)
|
|
})
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|