From d6e0b6bbb1e4c73219a4965ed1772d68003a4a8a Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Thu, 16 Jul 2026 19:47:52 +0800 Subject: [PATCH] chore(example): clean up and migrate to ts partially (#3492) * chore(example): clean up and migrate to ts * Add missing permissions * Mirror line-height: 1.5 and remove h-* --- examples/api/src-tauri/capabilities/base.json | 1 + examples/api/src/App.svelte | 215 ++++++++++-------- examples/api/src/app.css | 4 + examples/api/src/lib/TitleBar.svelte | 23 +- examples/api/src/views/Clipboard.svelte | 3 +- examples/api/src/views/Dialog.svelte | 160 ++++++------- examples/api/src/views/FileSystem.svelte | 6 +- 7 files changed, 224 insertions(+), 188 deletions(-) diff --git a/examples/api/src-tauri/capabilities/base.json b/examples/api/src-tauri/capabilities/base.json index f5286a4ac..91b2d6b45 100644 --- a/examples/api/src-tauri/capabilities/base.json +++ b/examples/api/src-tauri/capabilities/base.json @@ -15,6 +15,7 @@ ] }, "core:default", + "core:app:allow-set-app-theme", "fs:default", "core:window:allow-minimize", "core:window:allow-toggle-maximize", diff --git a/examples/api/src/App.svelte b/examples/api/src/App.svelte index b9b0fb8ea..3d9f4987a 100644 --- a/examples/api/src/App.svelte +++ b/examples/api/src/App.svelte @@ -1,8 +1,16 @@ - + + {#if isWindows} - + {/if} @@ -413,9 +433,10 @@ id="console" class="select-none h-15rem grid grid-rows-[2px_2rem_1fr] gap-1 overflow-hidden" > -
@@ -426,7 +447,7 @@ hover:bg-hoverOverlay dark:hover:bg-darkHoverOverlay active:bg-hoverOverlay/25 dark:active:bg-darkHoverOverlay/25 " - on:click={clear} + onclick={clear} >
@@ -435,8 +456,8 @@ bind:this={consoleTextEl} class="px-2 overflow-y-auto all:font-mono code-block all:text-xs select-text mr-2" > - {#each $messages as r} - {@html r.html} + {#each $messages as messageHtml} + {@html messageHtml} {/each}
diff --git a/examples/api/src/app.css b/examples/api/src/app.css index bbf0fdd9a..20df36aa1 100644 --- a/examples/api/src/app.css +++ b/examples/api/src/app.css @@ -1,3 +1,7 @@ +:root { + line-height: 1.5; +} + *:not(h1, h2, h3, h4, h5, h6) { margin: 0; padding: 0; diff --git a/examples/api/src/lib/TitleBar.svelte b/examples/api/src/lib/TitleBar.svelte index ec927d12b..c1e425316 100644 --- a/examples/api/src/lib/TitleBar.svelte +++ b/examples/api/src/lib/TitleBar.svelte @@ -1,13 +1,14 @@ @@ -173,15 +180,16 @@
- - + - - + - - - + +
diff --git a/examples/api/src/views/FileSystem.svelte b/examples/api/src/views/FileSystem.svelte index fbec86282..bc35547ec 100644 --- a/examples/api/src/views/FileSystem.svelte +++ b/examples/api/src/views/FileSystem.svelte @@ -5,7 +5,7 @@ import { arrayBufferToBase64 } from '../lib/utils' import { onDestroy, onMount } from 'svelte' - const { onMessage, insecureRenderHtml } = $props() + const { onMessage } = $props() let path = $state('') let img @@ -118,12 +118,12 @@ new Uint8Array(response), function (base64) { const src = 'data:image/png;base64,' + base64 - insecureRenderHtml('') + onMessage('') } ) } else { const value = String.fromCharCode.apply(null, response) - insecureRenderHtml( + onMessage( '' ) setTimeout(() => {