|
@@ -5,39 +5,43 @@
|
|
|
<button id="log">Call Log API</button>
|
|
|
<button id="request">Call Request (async) API</button>
|
|
|
<button id="event">Send event to Rust</button>
|
|
|
- <div id="response"></div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div style="margin-top: 24px">
|
|
|
+ <input id="path-to-read" placeholder="Type the path to read...">
|
|
|
+ <button id="read">Read</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="margin-top: 24px">
|
|
|
+ <input id="url" value="https://tauri.studio">
|
|
|
+ <button id="open-url">Open URL</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="margin-top: 24px">
|
|
|
+ <input id="title" value="Awesome Tauri Example!">
|
|
|
+ <button id="set-title">Set title</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div id="response"></div>
|
|
|
+
|
|
|
<script>
|
|
|
- window.onTauriInit = function () {
|
|
|
- window.tauri.listen('rust-event', function (res) {
|
|
|
- document.getElementById('response').innerHTML = JSON.stringify(res)
|
|
|
- })
|
|
|
+ function registerResponse (response) {
|
|
|
+ document.getElementById('response').innerHTML = typeof response === 'object'
|
|
|
+ ? JSON.stringify(response)
|
|
|
+ : response
|
|
|
}
|
|
|
|
|
|
- document.getElementById('log').addEventListener('click', function () {
|
|
|
- window.tauri.invoke({
|
|
|
- cmd: 'logOperation',
|
|
|
- event: 'tauri-click',
|
|
|
- payload: 'this payload is optional because we used Option in Rust'
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- document.getElementById('request').addEventListener('click', function () {
|
|
|
- window.tauri.promisified({
|
|
|
- cmd: 'performRequest',
|
|
|
- endpoint: 'dummy endpoint arg',
|
|
|
- body: {
|
|
|
- id: 5,
|
|
|
- name: 'test'
|
|
|
+ function addClickEnterHandler (button, input, handler) {
|
|
|
+ button.addEventListener('click', handler)
|
|
|
+ input.addEventListener('keyup', function (e) {
|
|
|
+ if (e.keyCode === 13) {
|
|
|
+ handler()
|
|
|
}
|
|
|
- }).then(function (response) {
|
|
|
- document.getElementById('response').innerHTML = JSON.stringify(response)
|
|
|
})
|
|
|
- })
|
|
|
-
|
|
|
- document.getElementById('event').addEventListener('click', function () {
|
|
|
- window.tauri.emit('js-event', 'this is the payload string')
|
|
|
- })
|
|
|
+ }
|
|
|
</script>
|
|
|
+ <script src="communication.js"></script>
|
|
|
+ <script src="fs.js"></script>
|
|
|
+ <script src="window.js"></script>
|
|
|
</body>
|
|
|
-</html>
|
|
|
+</html>
|