From 5adb6eaec3e02768f81a32dbf35cdc0c04c5358c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=9B=E5=85=AE?= Date: Tue, 27 Oct 2026 11:57:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(ui):=20=E5=B0=86=E5=8F=99=E4=BA=8B?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC=E4=B8=8B=E6=8B=89=E6=A1=86=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=8C=96=E9=80=89=E6=8B=A9=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 对话设定:显示风格说明、整卡选择和选中标识,保留键盘单选语义及历史风格 - 响应式样式:手机纵向排列、桌面双列布局,跟随经典金和现代粉两套主题 - 验证:ESLint、类型检查、Next 构建及42项真实浏览器交互断言通过 --- src/components/digital-home.tsx | 71 +++++++++++++----- src/components/digital.css | 126 ++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 18 deletions(-) diff --git a/src/components/digital-home.tsx b/src/components/digital-home.tsx index d7554d3..ad1fdd1 100644 --- a/src/components/digital-home.tsx +++ b/src/components/digital-home.tsx @@ -1452,25 +1452,60 @@ export function DigitalHome({ } /> - ))} - - + +
加入世界书 {books.map((b) => ( diff --git a/src/components/digital.css b/src/components/digital.css index bf4e407..18d8215 100644 --- a/src/components/digital.css +++ b/src/components/digital.css @@ -886,6 +886,132 @@ color: var(--dh-muted); padding: 0 6px; } +/* 保留原生单选的键盘与读屏语义,整张风格卡可点击且随双主题变色。 */ +.dh-settings .dh-style-picker { + min-width: 0; + padding: 0; + margin: 0 0 22px; + border: 0; +} +.dh-style-picker legend { + padding: 0; + color: #d4cbd5; +} +.dh-style-help { + margin: 5px 0 12px !important; + color: var(--dh-muted); + font-size: 11px; +} +.dh-style-options { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; +} +.dh-style-option { + position: relative; + min-width: 0; + cursor: pointer; + -webkit-tap-highlight-color: transparent; +} +.dh-style-option:first-child, +.dh-style-option:last-child:nth-child(even) { + grid-column: 1 / -1; +} +.dh-style-option > input { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: 0; + opacity: 0; + clip-path: inset(50%); +} +.dh-style-card { + display: flex; + align-items: flex-start; + gap: 10px; + height: 100%; + min-height: 88px; + padding: 15px 13px; + border: 1px solid #ffffff17; + border-radius: 13px; + background: color-mix(in srgb, var(--dh-soft) 60%, var(--dh-panel)); + transition: + border-color 160ms, + background 160ms; +} +.dh-style-option:hover .dh-style-card { + border-color: color-mix(in srgb, var(--dh-accent) 55%, transparent); +} +.dh-style-option > input:checked + .dh-style-card { + border-color: var(--dh-accent); + background: color-mix(in srgb, var(--dh-accent) 9%, var(--dh-panel)); +} +.dh-style-option > input:focus-visible + .dh-style-card { + outline: 2px solid var(--dh-accent); + outline-offset: 3px; +} +.dh-style-symbol { + display: grid; + flex: none; + place-items: center; + width: 29px; + height: 29px; + color: var(--dh-accent); + background: color-mix(in srgb, var(--dh-accent) 10%, transparent); + border-radius: 9px; +} +.dh-style-symbol svg { + width: 15px; + height: 15px; +} +.dh-style-copy { + flex: 1; + min-width: 0; + overflow-wrap: anywhere; +} +.dh-style-copy strong { + display: block; + font-size: 12px; + font-weight: 600; + line-height: 1.6; +} +.dh-style-copy small { + display: block; + margin-top: 5px; + color: var(--dh-muted); + font-size: 11px; + line-height: 1.7; +} +.dh-style-check { + display: grid; + flex: none; + place-items: center; + width: 17px; + height: 17px; + margin-top: 2px; + color: transparent; + border: 1px solid #ffffff30; + border-radius: 50%; +} +.dh-style-check svg { + width: 11px; + height: 11px; + stroke-width: 3; +} +.dh-style-option > input:checked + .dh-style-card .dh-style-check { + color: var(--dh-accent-ink); + background: var(--dh-accent); + border-color: var(--dh-accent); +} +@media (width <= 600px) { + .dh-style-options { + grid-template-columns: minmax(0, 1fr); + } + .dh-style-card { + min-height: 76px; + } +} .dh-checkbox { display: flex; gap: 12px; -- 2.52.0 From 374ab1c606c3ee6b9fcf6be927de6e6d9c6d83ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B9=9B=E5=85=AE?= Date: Tue, 27 Oct 2026 12:11:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(ui):=20H5=E9=A3=8E=E6=A0=BC=E4=B8=8E?= =?UTF-8?q?=E4=B8=96=E7=95=8C=E4=B9=A6=E4=BD=BF=E7=94=A8=E5=BA=95=E9=83=A8?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=8A=BD=E5=B1=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - H5入口:设定页只显示当前风格和已选世界书,单选与多选均从底部抽屉完成 - 交互:独立草稿、确认回填、取消还原、恢复默认、清空选择和焦点返回 - 响应式:桌面保留展开式选择,主设定页和抽屉的提交按钮固定可见 - 验证:类型检查与构建通过,90项浏览器断言覆盖小屏、双主题、键盘和真实保存 --- src/components/digital-home.tsx | 460 +++++++++++++++++++++++--------- src/components/digital.css | 207 +++++++++++++- 2 files changed, 540 insertions(+), 127 deletions(-) diff --git a/src/components/digital-home.tsx b/src/components/digital-home.tsx index ad1fdd1..0c6362b 100644 --- a/src/components/digital-home.tsx +++ b/src/components/digital-home.tsx @@ -35,6 +35,7 @@ import { RefreshCw, Download, ChevronDown, + ChevronRight, } from "lucide-react"; import { digital, @@ -130,6 +131,14 @@ export function DigitalHome({ const [profileDraft, setProfileDraft] = useState( initial.profile, ); + const [selectionSheet, setSelectionSheet] = useState< + "style" | "books" | null + >(null); + const [choiceDraft, setChoiceDraft] = useState<{ + presetId?: string; + bookIds: string[]; + }>({ bookIds: [] }); + const selectionTrigger = useRef(null); const favoritePending = useRef(false); const [activeMessage, setActiveMessage] = useState(null), [showJump, setShowJump] = useState(false), @@ -258,13 +267,20 @@ export function DigitalHome({ ); const controls = () => Array.from( - dialog?.querySelectorAll( + ( + document.querySelector(".dh-selection-sheet") ?? dialog + )?.querySelectorAll( 'button:not([disabled]),input,textarea,select,[tabindex="0"]', ) ?? [], ); const frame = requestAnimationFrame(() => controls()[0]?.focus()); const onKey = (event: globalThis.KeyboardEvent) => { if (event.key === "Escape") { + event.preventDefault(); + if (document.querySelector(".dh-selection-sheet")) { + setSelectionSheet(null); + return; + } setDetail(null); setShowSettings(false); } @@ -288,6 +304,35 @@ export function DigitalHome({ previous?.focus(); }; }, [detail, showSettings]); + /** 抽屉聚焦当前选项并限制滚动;取消、确认及切回桌面后恢复入口焦点。 */ + useEffect(() => { + if (!selectionSheet) return; + const previous = selectionTrigger.current; + const media = window.matchMedia("(max-width: 600px)"); + const resize = () => { + if (!media.matches) setSelectionSheet(null); + }; + resize(); + media.addEventListener("change", resize); + const frame = requestAnimationFrame(() => { + const panel = document.querySelector(".dh-selection-sheet"); + ( + panel?.querySelector("input:checked") ?? + panel?.querySelector("input") ?? + panel?.querySelector("button") + )?.focus(); + }); + return () => { + cancelAnimationFrame(frame); + media.removeEventListener("change", resize); + if (previous?.isConnected && previous.getClientRects().length) + previous.focus(); + else + document + .querySelector(".dh-desktop-choices input:checked") + ?.focus(); + }; + }, [selectionSheet]); useEffect(() => { const id = boot?.decision.decisionId; if (!id || document.hidden) return; @@ -586,6 +631,26 @@ export function DigitalHome({ reportError(e); } } + /** 抽屉仅编辑临时值;确认后回填设定,取消不改动已有选择。 */ + function openSelection(kind: "style" | "books") { + if (!settings) return; + selectionTrigger.current = document.activeElement as HTMLElement; + setChoiceDraft({ + presetId: settings.presetId, + bookIds: [...settings.bookIds], + }); + setSelectionSheet(kind); + } + function confirmSelection() { + if (settings) + setSettings({ + ...settings, + ...(selectionSheet === "style" + ? { presetId: choiceDraft.presetId } + : { bookIds: choiceDraft.bookIds }), + }); + setSelectionSheet(null); + } async function saveSettings(event: FormEvent) { event.preventDefault(); if (!conversation || !settings) return; @@ -662,6 +727,97 @@ export function DigitalHome({ (tag === "全部" || c.tags.includes(tag)) && (!onlyFavorites || profile?.favorites.includes(c.id)), ); + const styleChoices = ( + value: string | undefined, + onChange: (value: string | undefined) => void, + inSheet = false, + ) => ( +
+ + 叙事风格 + +

为这段故事选一种氛围

+
+ {[ + { + id: "", + name: "角色默认风格", + description: "沿用角色原有的语气与叙事节奏。", + }, + ...presets, + ...(value && !presets.some((p) => p.id === value) + ? [ + { + id: value, + name: "当前会话风格", + description: + "此风格暂不在可选列表中,可以保留或选择其他风格。", + }, + ] + : []), + ].map((p) => ( + + ))} +
+
+ ); + const bookChoices = ( + value: string[], + onChange: (value: string[]) => void, + inSheet = false, + ) => ( +
+ + 加入世界书 + + {books.map((b) => ( + + ))} +
+ ); const modern = boot?.decision.variant === "B"; return (
)} {showSettings && settings && ( -
+
@@ -1406,136 +1564,188 @@ export function DigitalHome({
-