App.svelte 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <script>
  2. import { onMount } from "svelte";
  3. import { open } from "@tauri-apps/api/shell";
  4. import Welcome from "./components/Welcome.svelte";
  5. import Cli from "./components/Cli.svelte";
  6. import Communication from "./components/Communication.svelte";
  7. import Dialog from "./components/Dialog.svelte";
  8. import FileSystem from "./components/FileSystem.svelte";
  9. import Http from "./components/Http.svelte";
  10. import Notifications from "./components/Notifications.svelte";
  11. import Window from "./components/Window.svelte";
  12. import Shortcuts from "./components/Shortcuts.svelte";
  13. import Shell from "./components/Shell.svelte";
  14. import Updater from "./components/Updater.svelte";
  15. const views = [
  16. {
  17. label: "Welcome",
  18. component: Welcome,
  19. },
  20. {
  21. label: "Messages",
  22. component: Communication,
  23. },
  24. {
  25. label: "CLI",
  26. component: Cli,
  27. },
  28. {
  29. label: "Dialog",
  30. component: Dialog,
  31. },
  32. {
  33. label: "File system",
  34. component: FileSystem,
  35. },
  36. {
  37. label: "HTTP",
  38. component: Http,
  39. },
  40. {
  41. label: "Notifications",
  42. component: Notifications,
  43. },
  44. {
  45. label: "Window",
  46. component: Window,
  47. },
  48. {
  49. label: "Shortcuts",
  50. component: Shortcuts,
  51. },
  52. {
  53. label: "Shell",
  54. component: Shell,
  55. },
  56. {
  57. label: "Updater",
  58. component: Updater,
  59. },
  60. ];
  61. let selected = views[0];
  62. let responses = [""];
  63. function select(view) {
  64. selected = view;
  65. }
  66. function onMessage(value) {
  67. responses += typeof value === "string" ? value : JSON.stringify(value);
  68. responses += "\n";
  69. }
  70. function onLogoClick() {
  71. open("https://tauri.studio/");
  72. }
  73. </script>
  74. <main>
  75. <div class="flex row noselect just-around" style="margin=1em;" data-tauri-drag-region>
  76. <img src="tauri.png" height="60" on:click={onLogoClick} alt="logo" />
  77. <div>
  78. <a class="dark-link" target="_blank" href="https://tauri.studio/en/docs/getting-started/intro">
  79. Documentation
  80. </a>
  81. <a class="dark-link" target="_blank" href="https://github.com/tauri-apps/tauri">
  82. Github
  83. </a>
  84. <a class="dark-link" target="_blank" href="https://github.com/tauri-apps/tauri/tree/dev/tauri/examples/api">
  85. Source
  86. </a>
  87. </div>
  88. </div>
  89. <div class="flex row">
  90. <div style="width:15em; margin-left:0.5em">
  91. {#each views as view}
  92. <p class="nv noselect {selected === view ? 'nv_selected' : ''}" on:click={()=> select(view)}
  93. >
  94. {view.label}
  95. </p>
  96. {/each}
  97. </div>
  98. <div class="content">
  99. <svelte:component this={selected.component} {onMessage} />
  100. </div>
  101. </div>
  102. <div id="response" style="white-space: pre-line">
  103. <p class="flex row just-around">
  104. <strong>Tauri Console</strong>
  105. <a class="nv" on:click={()=> {
  106. responses = [""];
  107. }}>clear</a>
  108. </p>
  109. {responses}
  110. </div>
  111. </main>