From ba615e8965b07cff034ea0df09d3a54fbcf29292 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Mon, 16 Feb 2026 23:35:44 +0800 Subject: [PATCH] feat: Introduce user-editable source ID field with automatic generation and editing state handling. --- components/settings/AddSourceModal.tsx | 20 ++++++++- components/settings/hooks/useAddSourceForm.ts | 43 +++++++++++++------ package-lock.json | 4 +- package.json | 2 +- 4 files changed, 53 insertions(+), 16 deletions(-) diff --git a/components/settings/AddSourceModal.tsx b/components/settings/AddSourceModal.tsx index 6e0a021..ed70a49 100644 --- a/components/settings/AddSourceModal.tsx +++ b/components/settings/AddSourceModal.tsx @@ -14,7 +14,7 @@ interface AddSourceModalProps { } export function AddSourceModal({ isOpen, onClose, onAdd, existingIds, initialValues }: AddSourceModalProps) { - const { name, setName, url, setUrl, error, handleSubmit } = useAddSourceForm({ + const { name, setName, customId, setCustomId, url, setUrl, error, handleSubmit, isEditing } = useAddSourceForm({ isOpen, existingIds, onAdd, @@ -53,6 +53,24 @@ export function AddSourceModal({ isOpen, onClose, onAdd, existingIds, initialVal /> +
+ + setCustomId(e.target.value.toLowerCase().replace(/[^a-z0-9-]/g, ''))} + placeholder="自动生成,可手动修改" + disabled={isEditing} + className="w-full bg-[var(--glass-bg)] backdrop-blur-md border border-[var(--glass-border)] rounded-[var(--radius-2xl)] px-4 py-3 text-[var(--text-color)] placeholder:text-[var(--text-color-secondary)] focus:outline-none focus:border-[var(--accent-color)] focus:ring-4 focus:ring-[color-mix(in_srgb,var(--accent-color)_30%,transparent)] transition-all duration-[0.4s] disabled:opacity-50" + /> +

+ 用于唯一标识此源,仅支持小写字母、数字和连字符 +

+
+