Fix download button and API prefix issues #53

Merged
jimmy merged 7 commits from dev into main 2026-04-21 21:49:21 +08:00
Showing only changes of commit c18d677797 - Show all commits
+2 -6
View File
@@ -6,7 +6,6 @@
let currentPath = $state(""); let currentPath = $state("");
let loading = $state(true); let loading = $state(true);
let uploading = $state(false); let uploading = $state(false);
let downloading = $state(false);
let error = $state(""); let error = $state("");
let fileInput; let fileInput;
@@ -33,15 +32,12 @@
async function handleDownload(name) { async function handleDownload(name) {
const path = currentPath ? `${currentPath}/${name}` : name; const path = currentPath ? `${currentPath}/${name}` : name;
downloading = true;
error = ""; error = "";
try { try {
await download(path, name); await download(path, name);
} catch (e) { } catch (e) {
error = `Failed to download "${name}": ${e.message}`; error = `Failed to download "${name}": ${e.message}`;
console.error("Download failed:", e); console.error("Download failed:", e);
} finally {
downloading = false;
} }
} }
@@ -165,8 +161,8 @@
<span class="text-xs text-surface-400 text-right">{e.is_dir ? "—" : formatSize(e.size)}</span> <span class="text-xs text-surface-400 text-right">{e.is_dir ? "—" : formatSize(e.size)}</span>
<div class="flex items-center justify-end gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity"> <div class="flex items-center justify-end gap-1 opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity">
{#if !e.is_dir} {#if !e.is_dir}
<button onclick={() => handleDownload(e.name)} class="text-[11px] text-primary-500 hover:text-primary-700 font-medium transition-colors disabled:opacity-50" disabled={downloading}> <button onclick={() => handleDownload(e.name)} class="text-[11px] text-primary-500 hover:text-primary-700 font-medium transition-colors">
{downloading ? "..." : "DL"} DL
</button> </button>
{/if} {/if}
<button class="text-[11px] text-rose-400 hover:text-rose-600 font-medium transition-colors" onclick={() => remove(e.name)}>Del</button> <button class="text-[11px] text-rose-400 hover:text-rose-600 font-medium transition-colors" onclick={() => remove(e.name)}>Del</button>