index.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. * {
  6. font-family: Arial, Helvetica, sans-serif;
  7. }
  8. body {
  9. background: #889;
  10. }
  11. .logo-container {
  12. width: 95%;
  13. margin: 0px auto;
  14. overflow: hidden;
  15. }
  16. .logo-link {
  17. font-weight: 700;
  18. position: absolute;
  19. top: 150px;
  20. right: 10px;
  21. }
  22. .logo {
  23. width: 32px;
  24. height: 32px;
  25. cursor: pointer;
  26. position: fixed;
  27. z-index: 10;
  28. top: 7px;
  29. right: 10px;
  30. }
  31. #response {
  32. position: absolute;
  33. left: 10px;
  34. right: 10px;
  35. top: 440px;
  36. min-height: 110px;
  37. background: #aab;
  38. font-family: 'Courier New', Courier, monospace;
  39. font-size: 12px;
  40. word-wrap: break-word;
  41. padding: 5px;
  42. border-radius: 5px;
  43. overflow-y: auto;
  44. }
  45. input,
  46. select {
  47. background: white;
  48. font-family: system-ui, sans-serif;
  49. border: 0;
  50. border-radius: 0.25rem;
  51. font-size: 1rem;
  52. line-height: 1.2;
  53. padding: 0.25rem 0.5rem;
  54. margin: 0.25rem;
  55. }
  56. button:hover,
  57. button:focus {
  58. background: #0053ba;
  59. }
  60. button:focus {
  61. outline: 1px solid #fff;
  62. outline-offset: -4px;
  63. }
  64. button:active {
  65. transform: scale(0.99);
  66. }
  67. .button {
  68. border: 0;
  69. border-radius: 0.25rem;
  70. background: #1E88E5;
  71. color: white;
  72. font-family: system-ui, sans-serif;
  73. font-size: 1rem;
  74. line-height: 1.2;
  75. white-space: nowrap;
  76. text-decoration: none;
  77. padding: 0.25rem 0.5rem;
  78. margin: 0.25rem;
  79. cursor: pointer;
  80. }
  81. .bottom {
  82. position: fixed;
  83. bottom: 0;
  84. left: 0;
  85. text-align: center;
  86. width: 100%;
  87. padding: 5px;
  88. background: #333;
  89. color: #eef;
  90. }
  91. .dark-link {
  92. color: white;
  93. text-decoration: none !important;
  94. }
  95. .tabs-container {
  96. position: fixed;
  97. height: 400px;
  98. top: 20px;
  99. left: 10px;
  100. right: 10px;
  101. z-index: 9;
  102. }
  103. .tabs {
  104. position: relative;
  105. min-height: 400px;
  106. clear: both;
  107. }
  108. .tab {
  109. float: left;
  110. }
  111. .tab>label {
  112. background: #eee;
  113. padding: 10px;
  114. border: 1px solid transparent;
  115. margin-left: -1px;
  116. position: relative;
  117. left: 1px;
  118. }
  119. .tabs>.tabber {
  120. border-top-left-radius: 5px;
  121. }
  122. .tabs>.tabber~.tabber {
  123. border-top-left-radius: none;
  124. }
  125. .tab [type=radio] {
  126. display: none;
  127. }
  128. .content {
  129. position: absolute;
  130. top: 28px;
  131. left: 0;
  132. background: #bbc;
  133. right: 0;
  134. bottom: 0;
  135. padding: 20px;
  136. border: 1px solid transparent;
  137. border-top-right-radius: 5px;
  138. border-bottom-left-radius: 5px;
  139. border-bottom-right-radius: 5px;
  140. }
  141. [type=radio]:checked~label {
  142. background: #bbc;
  143. border-bottom: 1px solid transparent;
  144. z-index: 2;
  145. }
  146. [type=radio]:checked~label~.content {
  147. z-index: 1;
  148. }
  149. </style>
  150. </head>
  151. <body>
  152. <div class="logo-container">
  153. <img src="icon.png" class="logo">
  154. </div>
  155. <div class="tabs-container">
  156. <div class="tabs">
  157. <div class="tab">
  158. <input type="radio" id="tab-1" name="tab-group-1" checked>
  159. <label class="tabber" for="tab-1">Messages</label>
  160. <div class="content">
  161. <button class="button" id="log">Call Log API</button>
  162. <button class="button" id="request">Call Request (async) API</button>
  163. <button class="button" id="event">Send event to Rust</button>
  164. <button class="button" id="notification">Send test notification</button>
  165. <div style="margin-top: 24px">
  166. <input id="title" value="Awesome Tauri Example!">
  167. <button class="button" id="set-title">Set title</button>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="tab">
  172. <input type="radio" id="tab-2" name="tab-group-1">
  173. <label class="tabber" for="tab-2">File System</label>
  174. <div class="content">
  175. <div style="margin-top: 24px">
  176. <select class="button" id="dir">
  177. <option value="">None</option>
  178. </select>
  179. <input id="path-to-read" placeholder="Type the path to read...">
  180. <button class="button" id="read">Read</button>
  181. </div>
  182. <div style="margin-top: 24px">
  183. <input id="dialog-default-path" placeholder="Default path">
  184. <input id="dialog-filter" placeholder="Extensions filter">
  185. <div>
  186. <input type="checkbox" id="dialog-multiple">
  187. <label>Multiple</label>
  188. </div>
  189. <div>
  190. <input type="checkbox" id="dialog-directory">
  191. <label>Directory</label>
  192. </div>
  193. <button class="button" id="open-dialog">Open dialog</button>
  194. <button class="button" id="save-dialog">Open save dialog</button>
  195. </div>
  196. </div>
  197. </div>
  198. <div class="tab">
  199. <input type="radio" id="tab-3" name="tab-group-1">
  200. <label class="tabber" for="tab-3">Communication</label>
  201. <div class="content">
  202. <div style="margin-top: 24px">
  203. <input id="url" value="https://tauri.studio">
  204. <button class="button" id="open-url">Open URL</button>
  205. </div>
  206. <div style="margin-top: 24px">
  207. <select class="button" id="request-method">
  208. <option value="GET">GET</option>
  209. <option value="POST">POST</option>
  210. <option value="PUT">PUT</option>
  211. <option value="PATCH">PATCH</option>
  212. <option value="DELETE">DELETE</option>
  213. </select>
  214. <input id="request-url" placeholder="Type the request URL...">
  215. <br />
  216. <textarea id="request-body" placeholder="Request body" rows="5"
  217. style="width:100%;margin-right:10px;font-size:12px"></textarea>
  218. </br>
  219. <button class="button" id="make-request">Make request</button>
  220. </div>
  221. </div>
  222. </div>
  223. <div class="tab">
  224. <input type="radio" id="tab-4" name="tab-group-1">
  225. <label class="tabber" for="tab-4">CLI</label>
  226. <div class="content">
  227. <div style="margin-top: 24px">
  228. <button class="button" id="cli-matches">Get matches</button>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. <div id="response"></div>
  235. <div class="bottom">
  236. <a class="dark-link" target="_blank" href="https://tauri.studio">Tauri Documentation</a>&nbsp;&nbsp;&nbsp;
  237. <a class="dark-link" target="_blank" href="https://github.com/tauri-apps/tauri">Github Repo</a>&nbsp;&nbsp;&nbsp;
  238. <a class="dark-link" target="_blank"
  239. href="https://github.com/tauri-apps/tauri/tree/dev/tauri/examples/communication">Source for this App</a>
  240. </div>
  241. <script>
  242. function registerResponse(response) {
  243. document.getElementById('response').innerHTML = typeof response === 'object' ?
  244. JSON.stringify(response) :
  245. response
  246. }
  247. function addClickEnterHandler(button, input, handler) {
  248. button.addEventListener('click', handler)
  249. input.addEventListener('keyup', function (e) {
  250. if (e.keyCode === 13) {
  251. handler()
  252. }
  253. })
  254. }
  255. window.__TAURI__.event.listen('rust-event', function (res) {
  256. document.getElementById('response').innerHTML = JSON.stringify(res)
  257. })
  258. document.querySelector('.logo').addEventListener('click', function () {
  259. window.__TAURI__.window.open('https://tauri.studio/')
  260. })
  261. var dirSelect = document.getElementById('dir')
  262. for (var key in window.__TAURI__.fs.Dir) {
  263. if (isNaN(parseInt(key))) {
  264. var value = window.__TAURI__.fs.Dir[key]
  265. var opt = document.createElement("option")
  266. opt.value = value
  267. opt.innerHTML = key
  268. dirSelect.appendChild(opt)
  269. }
  270. }
  271. </script>
  272. <script src="communication.js"></script>
  273. <script src="fs.js"></script>
  274. <script src="window.js"></script>
  275. <script src="dialog.js"></script>
  276. <script src="http.js"></script>
  277. <script src="cli.js"></script>
  278. <script src="notification.js"></script>
  279. </body>
  280. </html>