index.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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">
  163. Call Request (async) API
  164. </button>
  165. <button class="button" id="event">Send event to Rust</button>
  166. <button class="button" id="notification">
  167. Send test notification
  168. </button>
  169. <div style="margin-top: 24px">
  170. <input id="title" value="Awesome Tauri Example!" />
  171. <button class="button" id="set-title">Set title</button>
  172. </div>
  173. </div>
  174. </div>
  175. <div class="tab">
  176. <input type="radio" id="tab-2" name="tab-group-1" />
  177. <label class="tabber" for="tab-2">File System</label>
  178. <div class="content">
  179. <div style="margin-top: 24px">
  180. <select class="button" id="dir">
  181. <option value="">None</option>
  182. </select>
  183. <input id="path-to-read" placeholder="Type the path to read..." />
  184. <button class="button" id="read">Read</button>
  185. </div>
  186. <div style="margin-top: 24px">
  187. <input id="dialog-default-path" placeholder="Default path" />
  188. <input id="dialog-filter" placeholder="Extensions filter" />
  189. <div>
  190. <input type="checkbox" id="dialog-multiple" />
  191. <label>Multiple</label>
  192. </div>
  193. <div>
  194. <input type="checkbox" id="dialog-directory" />
  195. <label>Directory</label>
  196. </div>
  197. <button class="button" id="open-dialog">Open dialog</button>
  198. <button class="button" id="save-dialog">Open save dialog</button>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="tab">
  203. <input type="radio" id="tab-3" name="tab-group-1" />
  204. <label class="tabber" for="tab-3">Communication</label>
  205. <div class="content">
  206. <div style="margin-top: 24px">
  207. <input id="url" value="https://tauri.studio" />
  208. <button class="button" id="open-url">Open URL</button>
  209. </div>
  210. <div style="margin-top: 24px">
  211. <select class="button" id="request-method">
  212. <option value="GET">GET</option>
  213. <option value="POST">POST</option>
  214. <option value="PUT">PUT</option>
  215. <option value="PATCH">PATCH</option>
  216. <option value="DELETE">DELETE</option>
  217. </select>
  218. <input id="request-url" placeholder="Type the request URL..." />
  219. <br />
  220. <textarea
  221. id="request-body"
  222. placeholder="Request body"
  223. rows="5"
  224. style="width: 100%; margin-right: 10px; font-size: 12px"
  225. ></textarea>
  226. <br />
  227. <button class="button" id="make-request">Make request</button>
  228. </div>
  229. </div>
  230. </div>
  231. <div class="tab">
  232. <input type="radio" id="tab-4" name="tab-group-1" />
  233. <label class="tabber" for="tab-4">CLI</label>
  234. <div class="content">
  235. <div style="margin-top: 24px">
  236. <button class="button" id="cli-matches">Get matches</button>
  237. </div>
  238. </div>
  239. </div>
  240. </div>
  241. </div>
  242. <div id="response"></div>
  243. <div class="bottom">
  244. <a class="dark-link" target="_blank" href="https://tauri.studio"
  245. >Tauri Documentation</a
  246. >&nbsp;&nbsp;&nbsp;
  247. <a
  248. class="dark-link"
  249. target="_blank"
  250. href="https://github.com/tauri-apps/tauri"
  251. >Github Repo</a
  252. >&nbsp;&nbsp;&nbsp;
  253. <a
  254. class="dark-link"
  255. target="_blank"
  256. href="https://github.com/tauri-apps/tauri/tree/dev/tauri/examples/communication"
  257. >Source for this App</a
  258. >
  259. </div>
  260. <script>
  261. function registerResponse(response) {
  262. document.getElementById("response").innerHTML =
  263. typeof response === "object" ? JSON.stringify(response) : response;
  264. }
  265. function addClickEnterHandler(button, input, handler) {
  266. button.addEventListener("click", handler);
  267. input.addEventListener("keyup", function (e) {
  268. if (e.keyCode === 13) {
  269. handler();
  270. }
  271. });
  272. }
  273. window.__TAURI__.event.listen("rust-event", function (res) {
  274. document.getElementById("response").innerHTML = JSON.stringify(res);
  275. });
  276. document.querySelector(".logo").addEventListener("click", function () {
  277. window.__TAURI__.shell.open("https://tauri.studio/");
  278. });
  279. var dirSelect = document.getElementById("dir");
  280. for (var key in window.__TAURI__.fs.Dir) {
  281. if (isNaN(parseInt(key))) {
  282. var value = window.__TAURI__.fs.Dir[key];
  283. var opt = document.createElement("option");
  284. opt.value = value;
  285. opt.innerHTML = key;
  286. dirSelect.appendChild(opt);
  287. }
  288. }
  289. </script>
  290. <script src="communication.js"></script>
  291. <script src="fs.js"></script>
  292. <script src="window.js"></script>
  293. <script src="dialog.js"></script>
  294. <script src="http.js"></script>
  295. <script src="cli.js"></script>
  296. <script src="notification.js"></script>
  297. </body>
  298. </html>