From 32a87ebc61cbbbc8e485929d997e5b2b5f527807 Mon Sep 17 00:00:00 2001 From: seaHi Date: Sat, 15 Aug 2026 15:06:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=9C=A8=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E3=80=81=E7=B3=BB=E5=88=97=E5=92=8C=E6=A0=87=E7=AD=BE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E4=B8=AD=E5=BA=94=E7=94=A8=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/admin/categories/+page.svelte | 315 ++++++++--------------- src/routes/admin/series/+page.svelte | 307 ++++++++-------------- src/routes/admin/tags/+page.svelte | 279 +++++++------------- 3 files changed, 289 insertions(+), 612 deletions(-) diff --git a/src/routes/admin/categories/+page.svelte b/src/routes/admin/categories/+page.svelte index 3ee2183..36dfeeb 100644 --- a/src/routes/admin/categories/+page.svelte +++ b/src/routes/admin/categories/+page.svelte @@ -4,6 +4,9 @@ import { createSlugAutoHandler } from '$lib/utils/slugify'; import { confirmState } from '$lib/stores/confirm.svelte'; import TextInput from '$lib/components/admin/TextInput.svelte'; + import Button from '$lib/components/admin/Button.svelte'; + import DataTable from '$lib/components/admin/DataTable.svelte'; + import Alert from '$lib/components/admin/Alert.svelte'; let { data, form }: { data: PageData; form: ActionData } = $props(); @@ -36,9 +39,7 @@ {#if form?.error} -
- {form.error} -
+ {/if}
@@ -84,120 +85,110 @@ variant="underline" />
- + -
- {#if data.categories.length === 0} -
-

暂无任何{$page.data.aliases?.category || '分类'}

-
- {:else} - - + {#if data.categories.length === 0} +
+

暂无任何{$page.data.aliases?.category || '分类'}

+
+ {:else} + + + + + + + + + + + + {#each data.categories as category (category.id || category)} - - - - - + + + + + - - - {#each data.categories as category (category.id || category)} - - - - - - - - {/each} - -
ID{$page.data.aliases?.category || '分类'}名称别名关联文章数操作
ID{$page.data.aliases?.category || '分类'}名称别名关联文章数操作{category.id} + {#if editingId === category.id} + + {:else} + {category.name} + {/if} + + {#if editingId === category.id} + + {:else} + {category.slug} + {/if} + {category.post_count} 篇文章 + {#if editingId === category.id} +
{ + // will submit naturally, just reset editingId + setTimeout(() => { + editingId = null; + }, 0); + }} + > + + +
+ + {:else} + +
{ + if ((e.target as HTMLFormElement).dataset.confirmed === 'true') { + (e.target as HTMLFormElement).removeAttribute('data-confirmed'); + return; + } + e.preventDefault(); + const form = e.target as HTMLFormElement; + const submitter = e.submitter; + const confirmed = await confirmState.show( + `确定要删除${$page.data.aliases?.category || '分类'} "${category.name}" 吗?删除后相关文章将归为未${$page.data.aliases?.category || '分类'}。` + ); + if (confirmed) { + form.dataset.confirmed = 'true'; + form.requestSubmit(submitter); + } + }} + > + + +
+ {/if} +
{category.id} - {#if editingId === category.id} - - {:else} - {category.name} - {/if} - - {#if editingId === category.id} - - {:else} - {category.slug} - {/if} - {category.post_count} 篇文章 - {#if editingId === category.id} -
{ - // will submit naturally, just reset editingId - setTimeout(() => { - editingId = null; - }, 0); - }} - > - - -
- - {:else} - -
{ - if ((e.target as HTMLFormElement).dataset.confirmed === 'true') { - (e.target as HTMLFormElement).removeAttribute('data-confirmed'); - return; - } - e.preventDefault(); - const form = e.target as HTMLFormElement; - const submitter = e.submitter; - const confirmed = await confirmState.show( - `确定要删除${$page.data.aliases?.category || '分类'} "${category.name}" 吗?删除后相关文章将归为未${$page.data.aliases?.category || '分类'}。` - ); - if (confirmed) { - form.dataset.confirmed = 'true'; - form.requestSubmit(submitter); - } - }} - > - - -
- {/if} -
- {/if} -
+ {/each} + + + {/if}