Compare commits

..

13 Commits

Author SHA1 Message Date
zhanxi d3fe1b21ed Merge pull request 'chore: 同步多组实验发布到测试分支' (#10) from master into develop 2026-10-27 07:16:32 +00:00
zhanxi afc474b0c4 Merge pull request 'fix(experiments): 发布多组决策消费支持' (#9) from feature/env-pipeline-split into master 2026-10-27 07:15:54 +00:00
湛兮 a963bec3f3 fix(experiments): 按决策返回值消费多组界面实验
- 用户端支持动态组别和未入组状态,不再固定使用B组判断新版界面
- 决策过期使用服务端返回的默认值,保留旧响应兼容
2026-10-27 15:15:21 +08:00
zhanxi 81079c7364 fix(ui): 隐藏内部滚动轨道并修正风格状态提示
已完成三端构建、规则与真实浏览器链路验收,统一按同一版本发布。
2026-10-27 05:08:33 +00:00
湛兮 4079397625 fix(ui): 隐藏内部滚动轨道并整合叙事风格提示
- 滚动区域:隐藏原生横竖轨道,保留触摸滚动,约束表单和文本域横向溢出

- Grok业务改动:纳入个人风格与统一方案的提示和不可用预设说明

- 状态查询:通过会话只读接口显示控制状态,取消离开页面后的请求
2026-10-27 12:54:51 +08:00
zhanxi 9b2f7fc7cf feat(chat): 滑动删除灵感回复与H5回车发送
已完成类型检查、构建、规则与真实浏览器验收,沿用既有流水线发布。
2026-10-27 04:38:05 +00:00
湛兮 981eab9dcf fix(ui): 保持滑动会话卡片的主题背景与边框 2026-10-27 12:30:54 +08:00
湛兮 d0442f5bb9 feat(chat): 支持滑动删除灵感回复与H5回车发送
- 会话列表:水平滑动展开删除、桌面快捷入口、模态确认及失败重试

- 灵感回复:按上下文生成建议,仅加入草稿,保留原输入并取消过期请求

- 输入交互:移除回车发送的屏宽限制,保护中文输入法,支持Shift换行与手机换行按钮
2026-10-27 12:29:48 +08:00
zhanxi a8ef8222c8 feat(ui): 发布H5选择抽屉与桌面风格卡片
已完成代码检查、构建和浏览器交互验收,沿用原有前台部署链路。
2026-10-27 04:14:11 +00:00
湛兮 374ab1c606 feat(ui): H5风格与世界书使用底部选择抽屉
- H5入口:设定页只显示当前风格和已选世界书,单选与多选均从底部抽屉完成

- 交互:独立草稿、确认回填、取消还原、恢复默认、清空选择和焦点返回

- 响应式:桌面保留展开式选择,主设定页和抽屉的提交按钮固定可见

- 验证:类型检查与构建通过,90项浏览器断言覆盖小屏、双主题、键盘和真实保存
2026-10-27 12:11:32 +08:00
湛兮 5adb6eaec3 feat(ui): 将叙事风格下拉框改为主题化选择卡片
- 对话设定:显示风格说明、整卡选择和选中标识,保留键盘单选语义及历史风格

- 响应式样式:手机纵向排列、桌面双列布局,跟随经典金和现代粉两套主题

- 验证:ESLint、类型检查、Next 构建及42项真实浏览器交互断言通过
2026-10-27 11:57:31 +08:00
zhanxi 0f0aebe3a4 feat(experiments): 发布实验类型与用户管理拆分
已完成双轮review与测试环境验证,沿用现有部署链路。
2026-10-27 03:47:09 +00:00
湛兮 b1c5610f23 feat(experiments): 开放本人通用类型决策读取接口
- BFF:允许已登录用户按类型读取决策,拒绝对决策入口写操作

- README:补充类型消费者接入路径与后台验收边界
2026-10-27 11:40:22 +08:00
6 changed files with 1510 additions and 140 deletions
+8
View File
@@ -130,3 +130,11 @@ pnpm start:prod
- `DEEPSEEK_API_KEY` 仅在业务后端配置,前端不读取、不保存。
标签页图标采用 `public/stellar-icon-v2.svg`,同时提供多尺寸 `favicon.ico`、180/192/512 PNG,覆盖浏览器、Apple 主屏幕和 PWA。版本化资源路径用于刷新旧图标缓存。
通用实验消费者可经 `GET /api/digital/decisions/:key` 读取本人类型决策的 `data.value`,沿用 HttpOnly 会话与不缓存策略。类型、测试方案和用户分组全部在后台管理;新类型需要应用真实使用返回值并完成后台接入验收后才可启动。
`src/components/conversation-row.tsx` 提供会话列表横滑删除、桌面删除入口与模态确认。灵感回复读取本人会话上下文,选择后只加入草稿,原草稿保留;回车发送覆盖 H5/Web,支持中文输入法、Shift+Enter 与手机换行按钮。
内部滚动区域统一隐藏原生轨道,保留触摸/键盘滚动,设定表单关闭横向溢出。风格控制提示使用只读 `GET /api/digital/conversations/:id/style-policy`,打开设定不会写入实验分组、决策或曝光。
实验决策支持 A~Z 动态组;未入组时组别为 null。界面消费 `decision.value`(`new` / `true` 为新版),组名仅用于归因。决策过期使用服务端的 `fallbackValue`,不将无实验用户伪装成 A 组;旧服务未返回value时保留既有兼容路径。
+9 -1
View File
@@ -33,11 +33,19 @@ async function proxy(
const { path } = await context.params;
const joined = path.join("/");
if (
!/^(bootstrap|profile|exposure|conversations(?:\/[a-zA-Z0-9_-]+(?:\/(?:stream|stop|branch|messages\/[a-zA-Z0-9_-]+))?)?)$/.test(
!/^(bootstrap|profile|exposure|decisions\/[a-zA-Z0-9_-]+|conversations(?:\/[a-zA-Z0-9_-]+(?:\/(?:stream|stop|branch|suggestions|style-policy|messages\/[a-zA-Z0-9_-]+))?)?)$/.test(
joined,
)
)
return Response.json({ message: "接口不存在" }, { status: 404 });
if (
(joined.startsWith("decisions/") || joined.endsWith("/style-policy")) &&
request.method !== "GET"
)
return Response.json(
{ message: "仅支持读取决策" },
{ status: 405, headers: { Allow: "GET" } },
);
if (request.method !== "GET") {
const origin = request.headers.get("origin");
try {
+209
View File
@@ -0,0 +1,209 @@
"use client";
/** 会话列表的水平滑动操作与删除确认;纵向滑动继续交给页面滚动。 */
import { useEffect, useId, useRef, useState, type PointerEvent } from "react";
import { LoaderCircle, Trash2 } from "lucide-react";
import type { Card, Summary } from "@/lib/digital";
/** 一次只展开一条会话;拖动不会触发进入会话,桌面和键盘保留显式删除入口。 */
export function ConversationRow({
summary,
card,
revealed,
disabled,
onReveal,
onOpen,
onDelete,
}: {
summary: Summary;
card?: Card;
revealed: boolean;
disabled: boolean;
onReveal: (id: string | null) => void;
onOpen: () => void;
onDelete: () => void;
}) {
const [drag, setDrag] = useState<number | null>(null);
const gesture = useRef<{
x: number;
y: number;
base: number;
offset: number;
axis: "pending" | "x" | "y";
} | null>(null),
suppressClick = useRef(false);
const distance = 88;
function start(e: PointerEvent<HTMLButtonElement>) {
if (disabled || e.button !== 0) return;
suppressClick.current = false;
gesture.current = {
x: e.clientX,
y: e.clientY,
base: revealed ? -distance : 0,
offset: revealed ? -distance : 0,
axis: "pending",
};
e.currentTarget.setPointerCapture(e.pointerId);
}
function move(e: PointerEvent<HTMLButtonElement>) {
const g = gesture.current;
if (!g) return;
const dx = e.clientX - g.x,
dy = e.clientY - g.y;
if (g.axis === "pending" && Math.max(Math.abs(dx), Math.abs(dy)) > 8) {
g.axis = Math.abs(dx) > Math.abs(dy) * 1.2 ? "x" : "y";
if (g.axis === "x") onReveal(summary.id);
}
if (g.axis !== "x") return;
g.offset = Math.max(-distance, Math.min(0, g.base + dx));
setDrag(g.offset);
}
function finish(e: PointerEvent<HTMLButtonElement>, cancelled = false) {
const g = gesture.current;
if (!g) return;
gesture.current = null;
if (g.axis === "x") {
suppressClick.current = true;
onReveal(
(cancelled ? g.base : g.offset) < -distance / 2 ? summary.id : null,
);
}
setDrag(null);
if (e.currentTarget.hasPointerCapture(e.pointerId))
e.currentTarget.releasePointerCapture(e.pointerId);
}
const exposed = revealed || (drag !== null && drag < 0);
return (
<article className={`dh-conversation-row ${exposed ? "is-revealed" : ""}`}>
<button
className="dh-row-delete-swipe"
aria-label={`删除对话:${summary.title}`}
tabIndex={exposed ? 0 : -1}
aria-hidden={!exposed}
disabled={disabled}
onClick={onDelete}
>
<Trash2 size={18} />
<span>删除</span>
</button>
<button
className={`dh-conversation-open ${drag !== null ? "is-dragging" : ""}`}
style={{
transform: `translateX(${drag ?? (revealed ? -distance : 0)}px)`,
}}
disabled={disabled}
onPointerDown={start}
onPointerMove={move}
onPointerUp={(e) => finish(e)}
onPointerCancel={(e) => finish(e, true)}
onLostPointerCapture={() => {
if (gesture.current) {
gesture.current = null;
setDrag(null);
}
}}
onClick={(e) => {
if (suppressClick.current && e.detail !== 0) {
suppressClick.current = false;
return;
}
if (revealed) {
onReveal(null);
return;
}
onOpen();
}}
>
{/* 封面地址沿用服务端目录,不在小型服务器做图片转换。 */}
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={card?.cover || "/icon.svg"} alt="" draggable={false} />
<div>
<h3>{summary.title}</h3>
<p>{card?.description || "继续这段私人对话"}</p>
</div>
<small>
{new Date(summary.updatedAt).toLocaleDateString("zh-CN", {
month: "short",
day: "numeric",
})}
</small>
</button>
<button
className="dh-row-delete-desktop"
aria-label={`删除对话:${summary.title}`}
disabled={disabled}
onClick={onDelete}
>
<Trash2 size={17} />
</button>
</article>
);
}
/** 原生模态对话框负责焦点约束,删除成功前保留原会话,失败可在原处重试。 */
export function ConversationDeleteDialog({
title,
busy,
error,
onCancel,
onConfirm,
}: {
title: string;
busy: boolean;
error: string;
onCancel: () => void;
onConfirm: () => void;
}) {
const ref = useRef<HTMLDialogElement>(null),
id = useId();
useEffect(() => {
const dialog = ref.current;
dialog?.showModal();
return () => dialog?.close();
}, []);
return (
<dialog
ref={ref}
className="dh-delete-dialog"
role="alertdialog"
aria-labelledby={id}
aria-describedby={`${id}-description`}
onCancel={(e) => {
e.preventDefault();
if (!busy) onCancel();
}}
>
<span className="dh-delete-symbol">
<Trash2 size={24} />
</span>
<h2 id={id}>删除这段对话?</h2>
<p id={`${id}-description`}>
「{title}」的对话记录将被永久删除,无法恢复。
</p>
{error && (
<p className="dh-delete-error" role="alert">
{error}
</p>
)}
<div className="dh-delete-actions">
<button type="button" disabled={busy} onClick={onCancel}>
取消
</button>
<button
type="button"
className="is-danger"
disabled={busy}
onClick={onConfirm}
>
{busy ? (
<>
<LoaderCircle size={16} className="dh-spin" />
正在删除
</>
) : (
"删除对话"
)}
</button>
</div>
</dialog>
);
}
+641 -128
View File
@@ -35,6 +35,7 @@ import {
RefreshCw,
Download,
ChevronDown,
ChevronRight,
} from "lucide-react";
import {
digital,
@@ -47,6 +48,7 @@ import {
type Summary,
type Bootstrap,
} from "@/lib/digital";
import { ConversationRow, ConversationDeleteDialog } from "./conversation-row";
import "./digital.css";
type Tab = "discover" | "chats" | "library" | "me";
/** 接收文本与视觉打字分离;减少动画设置下直接呈现完整文本。 */
@@ -103,7 +105,7 @@ function MessageText({
</div>
);
}
/** 前台无分组按钮、调试开关或实验配置。 */
/** 前台管理个人会话偏好;后台方案仅展示覆盖提示,不开放实验操作。 */
export function DigitalHome({
initial,
initialSummaries,
@@ -124,12 +126,36 @@ export function DigitalHome({
[opening, setOpening] = useState(false),
[error, setError] = useState(""),
[notice, setNotice] = useState("");
const [stylePolicy, setStylePolicy] = useState<
"loading" | "personal" | "managed" | "unknown"
>("loading");
const [showSettings, setShowSettings] = useState(false),
[settings, setSettings] = useState<Settings | null>(null),
[profile, setProfile] = useState<Profile | null>(initial.profile);
const [profileDraft, setProfileDraft] = useState<Profile | null>(
initial.profile,
);
const [selectionSheet, setSelectionSheet] = useState<
"style" | "books" | null
>(null);
const [choiceDraft, setChoiceDraft] = useState<{
presetId?: string;
bookIds: string[];
}>({ bookIds: [] });
const selectionTrigger = useRef<HTMLElement | null>(null);
const [swipedConversation, setSwipedConversation] = useState<string | null>(
null,
);
const [deleteTarget, setDeleteTarget] = useState<Summary | null>(null),
[deleting, setDeleting] = useState(false),
[deleteError, setDeleteError] = useState("");
const [ideasOpen, setIdeasOpen] = useState(false),
[ideasLoading, setIdeasLoading] = useState(false),
[ideas, setIdeas] = useState<string[]>([]),
[ideasError, setIdeasError] = useState("");
const ideasRequest = useRef<AbortController | null>(null),
imeComposing = useRef(false),
deleteLock = useRef(false);
const favoritePending = useRef(false);
const [activeMessage, setActiveMessage] = useState<string | null>(null),
[showJump, setShowJump] = useState(false),
@@ -147,6 +173,25 @@ export function DigitalHome({
books = boot?.catalog.filter((c) => c.kind === "worldbook") ?? [],
presets = boot?.catalog.filter((c) => c.kind === "preset") ?? [];
const conversationId = conversation?.id;
// 状态提示走只读接口,打开设定不应写入实验分组、决策或曝光。
useEffect(() => {
if (!showSettings || !conversationId) return;
const controller = new AbortController();
digital<{ managed: boolean }>(
`conversations/${conversationId}/style-policy`,
"GET",
undefined,
controller.signal,
)
.then((policy) => {
if (!controller.signal.aborted)
setStylePolicy(policy.managed ? "managed" : "personal");
})
.catch(() => {
if (!controller.signal.aborted) setStylePolicy("unknown");
});
return () => controller.abort();
}, [showSettings, conversationId]);
const decisionExpiresAt = boot?.decision.expiresAt,
decisionServerNow = boot?.serverNow;
const currentCard = cards.find((c) => c.id === conversation?.characterId);
@@ -203,6 +248,7 @@ export function DigitalHome({
decision: {
...current.decision,
variant: current.decision.fallbackVariant,
value: current.decision.fallbackValue,
decisionId: null,
},
}
@@ -258,13 +304,20 @@ export function DigitalHome({
);
const controls = () =>
Array.from(
dialog?.querySelectorAll<HTMLElement>(
(
document.querySelector<HTMLElement>(".dh-selection-sheet") ?? dialog
)?.querySelectorAll<HTMLElement>(
'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 +341,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<HTMLElement>(".dh-selection-sheet");
(
panel?.querySelector<HTMLElement>("input:checked") ??
panel?.querySelector<HTMLElement>("input") ??
panel?.querySelector<HTMLElement>("button")
)?.focus();
});
return () => {
cancelAnimationFrame(frame);
media.removeEventListener("change", resize);
if (previous?.isConnected && previous.getClientRects().length)
previous.focus();
else
document
.querySelector<HTMLElement>(".dh-desktop-choices input:checked")
?.focus();
};
}, [selectionSheet]);
useEffect(() => {
const id = boot?.decision.decisionId;
if (!id || document.hidden) return;
@@ -317,6 +399,9 @@ export function DigitalHome({
};
}, [busy, conversationId]);
async function openConversation(id: string) {
closeIdeas();
imeComposing.current = false;
setSwipedConversation(null);
if (streamingId.current && streamingId.current !== id) {
setNotice("请先停止当前回复,再切换会话");
return;
@@ -391,6 +476,7 @@ export function DigitalHome({
(mode === "send" && !draft.trim())
)
return;
closeIdeas();
const id = conversation.id,
content = draft.trim(),
requestId = crypto.randomUUID();
@@ -400,7 +486,10 @@ export function DigitalHome({
setNotice("");
atBottom.current = true;
streamingId.current = id;
if (mode === "send") setDraft("");
if (mode === "send") {
setDraft("");
if (textarea.current) textarea.current.style.height = "auto";
}
const local: Message[] = [
...(mode === "send"
? [
@@ -525,11 +614,12 @@ export function DigitalHome({
if (
event.key === "Enter" &&
!event.shiftKey &&
!imeComposing.current &&
!event.nativeEvent.isComposing &&
window.matchMedia("(min-width: 768px)").matches
event.nativeEvent.keyCode !== 229
) {
event.preventDefault();
void send();
if (!event.repeat) void send();
}
}
async function pin(message: Message) {
@@ -570,21 +660,153 @@ export function DigitalHome({
reportError(e);
}
}
async function removeConversation() {
if (
!conversation ||
busy ||
!window.confirm("删除此会话和全部消息?此操作无法撤销。")
)
function requestDelete(target: Summary) {
if (target.id === conversation?.id && busy) {
setNotice("请先停止当前回复,再删除对话");
return;
try {
await digital(`conversations/${conversation.id}`, "DELETE");
setConversation(null);
currentId.current = null;
await refreshSummaries();
} catch (e) {
reportError(e);
}
setDeleteError("");
setDeleteTarget(target);
setShowMenu(false);
}
function removeConversation() {
if (conversation)
requestDelete({
id: conversation.id,
title: conversation.title,
characterId: conversation.characterId,
updatedAt: "",
});
}
async function confirmDelete() {
if (!deleteTarget || deleteLock.current) return;
const id = deleteTarget.id;
deleteLock.current = true;
setDeleting(true);
setDeleteError("");
try {
await digital(`conversations/${id}`, "DELETE");
setSummaries((current) => current.filter((s) => s.id !== id));
setSwipedConversation(null);
if (currentId.current === id) {
closeIdeas();
setConversation(null);
currentId.current = null;
setDraft("");
}
try {
sessionStorage.removeItem(`dh-draft:${id}`);
} catch {}
setDeleteTarget(null);
setNotice("对话已删除");
} catch (e) {
setDeleteError(e instanceof Error ? e.message : "删除失败,请重试");
} finally {
deleteLock.current = false;
setDeleting(false);
}
}
/** 灵感建议只填入草稿,旧请求和已离开的会话不能覆盖当前输入。 */
function closeIdeas() {
ideasRequest.current?.abort();
ideasRequest.current = null;
setIdeasOpen(false);
setIdeasLoading(false);
setIdeasError("");
setIdeas([]);
}
async function generateIdeas() {
if (!conversation || busy || streamingId.current || ideasRequest.current)
return;
const id = conversation.id,
anchor = conversation.messages.at(-1)?.id ?? null,
controller = new AbortController();
ideasRequest.current = controller;
setIdeasOpen(true);
setIdeasLoading(true);
setIdeasError("");
setIdeas([]);
try {
const result = await digital<{
suggestions: string[];
anchorId: string | null;
}>(
`conversations/${id}/suggestions`,
"POST",
{ draft: draft.slice(0, 1000) },
controller.signal,
);
if (ideasRequest.current !== controller || currentId.current !== id)
return;
if (result.anchorId !== anchor) {
setIdeasError("对话已更新,请重新打开会话后再试");
return;
}
setIdeas(result.suggestions);
} catch (e) {
if (!controller.signal.aborted && currentId.current === id)
setIdeasError(e instanceof Error ? e.message : "灵感生成失败,请重试");
} finally {
if (ideasRequest.current === controller) {
ideasRequest.current = null;
setIdeasLoading(false);
}
}
}
function chooseIdea(value: string) {
const next = draft
? `${draft}${draft.endsWith("\n") ? "" : "\n"}${value}`
: value;
if (next.length > 4000) {
setIdeasError("草稿已接近字数上限,请先缩短内容");
return;
}
setDraft(next);
closeIdeas();
setNotice("已加入草稿,可修改后发送");
requestAnimationFrame(() => {
const input = textarea.current;
if (input) {
input.focus();
input.style.height = "auto";
input.style.height = `${Math.min(input.scrollHeight, 160)}px`;
input.setSelectionRange(next.length, next.length);
}
});
}
function insertLineBreak() {
const input = textarea.current;
if (!input || draft.length >= 4000) return;
const start = input.selectionStart,
end = input.selectionEnd,
next = draft.slice(0, start) + "\n" + draft.slice(end);
setDraft(next);
requestAnimationFrame(() => {
input.focus();
input.setSelectionRange(start + 1, start + 1);
input.style.height = "auto";
input.style.height = `${Math.min(input.scrollHeight, 160)}px`;
});
}
/** 抽屉仅编辑临时值;确认后回填设定,取消不改动已有选择。 */
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();
@@ -593,7 +815,11 @@ export function DigitalHome({
await digital(`conversations/${conversation.id}`, "PATCH", { settings });
setConversation((c) => (c ? { ...c, settings } : c));
setShowSettings(false);
setNotice("对话设定已保存,下次回复生效");
setNotice(
stylePolicy === "managed"
? "设定已保存;当前叙事风格仍由统一方案控制"
: "对话设定已保存,下次回复生效",
);
} catch (e) {
reportError(e);
}
@@ -640,6 +866,8 @@ export function DigitalHome({
URL.revokeObjectURL(url);
}
function switchTab(value: Tab) {
closeIdeas();
setSwipedConversation(null);
if (conversation && busy) {
setNotice("请先停止当前回复,再离开会话");
return;
@@ -662,7 +890,115 @@ export function DigitalHome({
(tag === "全部" || c.tags.includes(tag)) &&
(!onlyFavorites || profile?.favorites.includes(c.id)),
);
const modern = boot?.decision.variant === "B";
const styleChoices = (
value: string | undefined,
onChange: (value: string | undefined) => void,
inSheet = false,
) => (
<fieldset className="dh-style-picker">
<legend className={inSheet ? "dh-visually-hidden" : undefined}>
叙事风格
</legend>
<p className="dh-style-help" role="status">
{stylePolicy === "loading"
? "正在确认风格设置…"
: stylePolicy === "managed"
? "当前使用统一叙事风格。可以保存个人偏好,统一风格解除后采用。"
: stylePolicy === "unknown"
? "暂时无法确认当前风格,可以先保存个人偏好。"
: "为这段故事选一种氛围,也可以跟随角色默认风格。"}
</p>
<div className="dh-style-options">
{[
{
id: "",
name: "角色默认风格",
description: "沿用角色原有的语气与叙事节奏。",
},
...presets,
...(value && !presets.some((p) => p.id === value)
? [
{
id: value,
name: "当前会话风格",
description: "这个风格暂不可用,回复时会采用可用的默认风格。",
},
]
: []),
].map((p) => (
<label className="dh-style-option" key={p.id}>
<input
type="radio"
name={
inSheet
? "conversation-preset-sheet"
: "conversation-preset-inline"
}
value={p.id}
checked={(value ?? "") === p.id}
onChange={() => onChange(p.id || undefined)}
/>
<span className="dh-style-card">
<span className="dh-style-symbol" aria-hidden="true">
{p.id ? <WandSparkles /> : <Sparkles />}
</span>
<span className="dh-style-copy">
<strong>{p.name}</strong>
<small>{p.description || "以这套风格继续你们的故事。"}</small>
</span>
<span className="dh-style-check" aria-hidden="true">
<Check />
</span>
</span>
</label>
))}
</div>
</fieldset>
);
const bookChoices = (
value: string[],
onChange: (value: string[]) => void,
inSheet = false,
) => (
<fieldset className="dh-book-picker">
<legend className={inSheet ? "dh-visually-hidden" : undefined}>
加入世界书
</legend>
{books.map((b) => (
<label
className={`dh-checkbox ${value.includes(b.id) ? "is-selected" : ""}`}
key={b.id}
>
<input
type="checkbox"
checked={value.includes(b.id)}
onChange={(e) =>
onChange(
e.target.checked
? [...value, b.id]
: value.filter((v) => v !== b.id),
)
}
/>
<span>
{b.name}
<small>{b.description}</small>
</span>
</label>
))}
</fieldset>
);
useEffect(
() => () => {
ideasRequest.current?.abort();
},
[],
);
// UI按消费者返回值决定,组名仅用于归因;C到Z同样可以返回新版UI。
// 缺少value时兼容尚未升级的服务响应。
const modern = boot?.decision.value !== undefined
? boot.decision.value === "new" || boot.decision.value === true
: boot?.decision.variant === "B";
return (
<div
className={`dh-app ${modern ? "dh-modern" : "dh-classic"} ${conversation ? "dh-in-chat" : ""}`}
@@ -753,6 +1089,7 @@ export function DigitalHome({
aria-label="对话设定"
onClick={() => {
setSettings(conversation.settings);
setStylePolicy("loading");
setShowSettings(true);
}}
>
@@ -927,6 +1264,83 @@ export function DigitalHome({
</button>
)}
<div className="dh-composer-wrap">
{ideasOpen && (
<section
className="dh-reply-ideas"
aria-label="灵感回复"
aria-busy={ideasLoading}
>
<header>
<strong>
<Sparkles size={14} />
灵感回复
</strong>
<button
type="button"
className="dh-icon"
aria-label="关闭灵感回复"
onClick={closeIdeas}
>
<X size={16} />
</button>
</header>
<p className="dh-ideas-note">
{draft
? "选择后追加到现有草稿,不会自动发送。"
: "根据当前对话生成,选择后可编辑再发送。"}
</p>
{ideasLoading ? (
<p className="dh-ideas-loading" role="status">
<LoaderCircle size={16} className="dh-spin" />
正在寻找合适的接话方式…
</p>
) : ideasError ? (
<p className="dh-ideas-error" role="alert">
{ideasError}
</p>
) : (
<div className="dh-ideas-list">
{ideas.map((idea, i) => (
<button
type="button"
key={i}
onClick={() => chooseIdea(idea)}
>
<small>{i + 1}</small>
<span>{idea}</span>
</button>
))}
</div>
)}
{!ideasLoading && (
<button
type="button"
className="dh-ideas-refresh"
onClick={generateIdeas}
>
<RefreshCw size={13} />
{ideasError ? "重新生成" : "换一组"}
</button>
)}
</section>
)}
<div className="dh-compose-tools">
<button
type="button"
disabled={busy || ideasLoading}
onClick={generateIdeas}
>
<Sparkles size={14} />
{ideasLoading ? "灵感生成中…" : "灵感回复"}
</button>
<button
type="button"
className="dh-mobile-linebreak"
onClick={insertLineBreak}
>
换行
</button>
</div>
<div className="dh-composer">
<textarea
ref={textarea}
@@ -940,6 +1354,13 @@ export function DigitalHome({
e.target.style.height = "auto";
e.target.style.height = `${Math.min(e.target.scrollHeight, 160)}px`;
}}
enterKeyHint="send"
onCompositionStart={() => {
imeComposing.current = true;
}}
onCompositionEnd={() => {
imeComposing.current = false;
}}
onKeyDown={onKey}
/>
{busy ? (
@@ -1142,30 +1563,22 @@ export function DigitalHome({
开启新故事
</button>
</div>
{summaries.length > 0 && (
<p className="dh-swipe-hint">向左滑动对话可删除</p>
)}
<div className="dh-conversation-list">
{summaries.map((s) => {
const c = cards.find((c) => c.id === s.characterId);
return (
<button
key={s.id}
onClick={() => openConversation(s.id)}
disabled={opening}
>
<img src={c?.cover || "/icon.svg"} alt="" />
<div>
<h3>{s.title}</h3>
<p>{c?.description || "继续这段私人对话"}</p>
</div>
<small>
{new Date(s.updatedAt).toLocaleDateString("zh-CN", {
month: "short",
day: "numeric",
})}
</small>
<MessageCircle size={18} />
</button>
);
})}
{summaries.map((s) => (
<ConversationRow
key={s.id}
summary={s}
card={cards.find((c) => c.id === s.characterId)}
revealed={swipedConversation === s.id}
disabled={opening || deleting}
onReveal={setSwipedConversation}
onOpen={() => openConversation(s.id)}
onDelete={() => requestDelete(s)}
/>
))}
</div>
{!summaries.length && (
<div className="dh-empty">
@@ -1384,12 +1797,14 @@ export function DigitalHome({
</div>
)}
{showSettings && settings && (
<div className="dh-overlay">
<div className={`dh-overlay ${selectionSheet ? "dh-sheet-open" : ""}`}>
<form
className="dh-settings"
role="dialog"
aria-modal="true"
aria-label="对话设定"
aria-hidden={selectionSheet ? true : undefined}
inert={selectionSheet ? true : undefined}
onSubmit={saveSettings}
>
<header>
@@ -1406,103 +1821,201 @@ export function DigitalHome({
<X />
</button>
</header>
<label>
你的称呼
<input
maxLength={60}
value={settings.userName}
onChange={(e) =>
setSettings({ ...settings, userName: e.target.value })
}
/>
</label>
<label>
本次身份
<textarea
rows={3}
maxLength={2000}
value={settings.persona}
onChange={(e) =>
setSettings({ ...settings, persona: e.target.value })
}
/>
</label>
<button
className="dh-text-button"
type="button"
onClick={() =>
setSettings({
...settings,
userName: profile?.userName ?? "旅人",
persona: profile?.persona ?? "",
})
}
>
使用我的身份资料
</button>
<label>
固定记忆
<textarea
rows={3}
maxLength={3000}
value={settings.memory}
placeholder="记录你们共同经历的重要事实…"
onChange={(e) =>
setSettings({ ...settings, memory: e.target.value })
}
/>
</label>
<label>
叙事风格
<select
value={settings.presetId ?? ""}
onChange={(e) =>
<div className="dh-settings-body">
<label>
你的称呼
<input
maxLength={60}
value={settings.userName}
onChange={(e) =>
setSettings({ ...settings, userName: e.target.value })
}
/>
</label>
<label>
本次身份
<textarea
rows={3}
maxLength={2000}
value={settings.persona}
onChange={(e) =>
setSettings({ ...settings, persona: e.target.value })
}
/>
</label>
<button
className="dh-text-button"
type="button"
onClick={() =>
setSettings({
...settings,
presetId: e.target.value || undefined,
userName: profile?.userName ?? "旅人",
persona: profile?.persona ?? "",
})
}
>
<option value="">角色默认风格</option>
{presets.map((p) => (
<option key={p.id} value={p.id}>
{p.name}
</option>
))}
</select>
</label>
<fieldset>
<legend>加入世界书</legend>
{books.map((b) => (
<label className="dh-checkbox" key={b.id}>
<input
type="checkbox"
checked={settings.bookIds.includes(b.id)}
onChange={(e) =>
setSettings({
...settings,
bookIds: e.target.checked
? [...settings.bookIds, b.id]
: settings.bookIds.filter((v) => v !== b.id),
})
}
/>
使用我的身份资料
</button>
<label>
固定记忆
<textarea
rows={3}
maxLength={3000}
value={settings.memory}
placeholder="记录你们共同经历的重要事实…"
onChange={(e) =>
setSettings({ ...settings, memory: e.target.value })
}
/>
</label>
<div className="dh-mobile-choices">
<button
type="button"
className="dh-choice-trigger"
aria-label="选择叙事风格"
onClick={() => openSelection("style")}
>
<WandSparkles aria-hidden="true" />
<span>
{b.name}
<small>{b.description}</small>
<strong>叙事风格</strong>
<small>
{presets.find((p) => p.id === settings.presetId)?.name ??
(settings.presetId ? "当前会话风格" : "角色默认风格")}
</small>
</span>
</label>
))}
</fieldset>
<p className="dh-form-note">
保存后从下一次回复生效。可以固定单条消息,将它加入对话记忆。
</p>
<ChevronRight aria-hidden="true" />
</button>
<button
type="button"
className="dh-choice-trigger"
aria-label="选择世界书"
onClick={() => openSelection("books")}
>
<BookOpen aria-hidden="true" />
<span>
<strong>加入世界书</strong>
<small>
{settings.bookIds.length
? `已选 ${settings.bookIds.length} 本 · ${books
.filter((b) => settings.bookIds.includes(b.id))
.map((b) => b.name)
.join("、")}`
: "未加入世界书"}
</small>
</span>
<ChevronRight aria-hidden="true" />
</button>
</div>
<div className="dh-desktop-choices">
{styleChoices(settings.presetId, (value) =>
setSettings({ ...settings, presetId: value }),
)}
{bookChoices(settings.bookIds, (value) =>
setSettings({ ...settings, bookIds: value }),
)}
</div>
<p className="dh-form-note">
保存后用于接下来的回复。固定单条消息,可将它加入对话记忆。
</p>
</div>
<button className="dh-primary" type="submit">
保存设定
</button>
</form>
{selectionSheet && (
<div className="dh-selection-layer">
<button
type="button"
className="dh-selection-backdrop"
aria-label="取消选择"
tabIndex={-1}
onClick={() => setSelectionSheet(null)}
/>
<section
className="dh-selection-sheet"
role="dialog"
aria-modal="true"
aria-label={
selectionSheet === "style" ? "选择叙事风格" : "选择世界书"
}
>
<div className="dh-sheet-handle" aria-hidden="true" />
<header>
<div>
<h2>
{selectionSheet === "style" ? "叙事风格" : "加入世界书"}
</h2>
<p>
{selectionSheet === "style"
? "选择你喜欢的故事氛围"
: "可选择多本,丰富角色的故事背景"}
</p>
</div>
<button
type="button"
className="dh-icon"
aria-label="关闭选择抽屉"
onClick={() => setSelectionSheet(null)}
>
<X />
</button>
</header>
<div className="dh-selection-body">
{selectionSheet === "style"
? styleChoices(
choiceDraft.presetId,
(value) =>
setChoiceDraft({ ...choiceDraft, presetId: value }),
true,
)
: bookChoices(
choiceDraft.bookIds,
(value) =>
setChoiceDraft({ ...choiceDraft, bookIds: value }),
true,
)}
</div>
<footer>
<button
type="button"
className="dh-sheet-reset"
onClick={() =>
setChoiceDraft(
selectionSheet === "style"
? { ...choiceDraft, presetId: undefined }
: { ...choiceDraft, bookIds: [] },
)
}
>
{selectionSheet === "style" ? "恢复默认" : "清空选择"}
</button>
<button
type="button"
className="dh-primary"
onClick={confirmSelection}
>
确认选择
{selectionSheet === "books"
? `(${choiceDraft.bookIds.length})`
: ""}
</button>
</footer>
</section>
</div>
)}
</div>
)}
{deleteTarget && (
<ConversationDeleteDialog
title={deleteTarget.title}
busy={deleting}
error={deleteError}
onCancel={() => {
if (!deleting) setDeleteTarget(null);
}}
onConfirm={confirmDelete}
/>
)}
</div>
);
}
+639 -9
View File
@@ -588,7 +588,7 @@
flex-direction: column;
gap: 12px;
}
.dh-conversation-list > button {
.dh-conversation-list .dh-conversation-open {
border: 1px solid var(--dh-line);
background: var(--dh-panel);
border-radius: 14px;
@@ -598,7 +598,7 @@
gap: 16px;
text-align: left;
}
.dh-conversation-list > button:hover {
.dh-conversation-list .dh-conversation-open:hover {
border-color: #ffffff25;
}
.dh-conversation-list img {
@@ -620,7 +620,7 @@
text-overflow: ellipsis;
margin-top: 5px;
}
.dh-conversation-list > button > div {
.dh-conversation-list .dh-conversation-open > div {
min-width: 0;
flex: 1;
}
@@ -633,6 +633,268 @@
color: var(--dh-accent);
flex: none;
}
/* 横滑只移动会话卡片,删除在明确确认后才执行。 */
.dh-conversation-row {
position: relative;
overflow: hidden;
border-radius: 14px;
background: #9a394b;
}
.dh-conversation-list .dh-conversation-open {
position: relative;
z-index: 1;
width: 100%;
touch-action: pan-y;
transition: transform 180ms ease;
user-select: none;
}
.dh-conversation-list .dh-conversation-open.is-dragging {
transition: none;
}
.dh-app .dh-row-delete-swipe {
position: absolute;
inset: 0 0 0 auto;
display: flex;
flex-direction: column;
gap: 5px;
align-items: center;
justify-content: center;
width: 88px;
color: #fff;
background: #9a394b;
visibility: hidden;
}
.dh-conversation-row.is-revealed .dh-row-delete-swipe {
visibility: visible;
}
.dh-conversation-list .dh-row-delete-swipe svg {
color: #fff;
}
.dh-row-delete-swipe span {
font-size: 12px;
}
.dh-row-delete-desktop {
position: absolute;
z-index: 2;
top: 50%;
right: 12px;
display: grid;
place-items: center;
width: 34px;
height: 34px;
transform: translateY(-50%);
border-radius: 9px;
}
.dh-conversation-list .dh-row-delete-desktop svg {
color: var(--dh-muted);
}
.dh-app .dh-row-delete-desktop:hover {
background: #f8717120;
}
.dh-conversation-row.is-revealed .dh-row-delete-desktop {
display: none;
}
.dh-swipe-hint {
display: none;
}
.dh-delete-dialog {
width: min(420px, calc(100% - 32px));
max-height: 90dvh;
padding: 26px;
color: var(--dh-text);
background: var(--dh-panel);
border: 1px solid #ffffff1c;
border-radius: 20px;
}
.dh-delete-dialog::backdrop {
background: #000b;
backdrop-filter: blur(6px);
}
.dh-delete-symbol {
display: grid;
place-items: center;
width: 46px;
height: 46px;
margin-bottom: 18px;
color: #fda4af;
background: #fb718519;
border-radius: 14px;
}
.dh-delete-dialog h2 {
font-size: 21px;
font-weight: 600;
}
.dh-delete-dialog p {
margin-top: 12px;
color: var(--dh-muted);
font-size: 13px;
line-height: 1.8;
overflow-wrap: anywhere;
}
.dh-delete-actions {
display: flex;
gap: 12px;
margin-top: 24px;
}
.dh-app .dh-delete-actions button {
display: flex;
flex: 1;
gap: 7px;
align-items: center;
justify-content: center;
min-height: 44px;
font-size: 13px;
background: var(--dh-soft);
border: 1px solid var(--dh-line);
border-radius: 11px;
}
.dh-app .dh-delete-actions .is-danger {
color: #fff;
background: #a3374c;
border-color: #a3374c;
}
.dh-delete-dialog .dh-delete-error {
color: #fda4af;
}
.dh-compose-tools {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 4px 8px;
}
.dh-app .dh-compose-tools button {
display: flex;
align-items: center;
gap: 6px;
min-height: 32px;
padding: 0 4px;
color: var(--dh-accent);
font-size: 11px;
}
.dh-app .dh-compose-tools .dh-mobile-linebreak {
display: none;
}
.dh-reply-ideas {
margin: 0 0 12px;
padding: 13px;
background: var(--dh-panel);
border: 1px solid var(--dh-line);
border-radius: 15px;
}
.dh-reply-ideas header {
display: flex;
align-items: center;
justify-content: space-between;
}
.dh-reply-ideas strong {
display: flex;
gap: 7px;
align-items: center;
color: var(--dh-accent);
font-size: 12px;
font-weight: 500;
}
.dh-reply-ideas header .dh-icon {
width: 28px;
height: 28px;
}
.dh-ideas-note {
margin: 2px 0 10px !important;
color: var(--dh-muted);
font-size: 10px;
}
.dh-ideas-list {
display: flex;
flex-direction: column;
gap: 7px;
max-height: 30dvh;
overflow-y: auto;
overscroll-behavior: contain;
}
.dh-app .dh-ideas-list button {
display: flex;
gap: 10px;
align-items: flex-start;
padding: 10px;
text-align: left;
font-size: 12px;
line-height: 1.7;
background: var(--dh-soft);
border: 1px solid transparent;
border-radius: 9px;
}
.dh-app .dh-ideas-list button:hover {
border-color: var(--dh-accent);
}
.dh-ideas-list small {
flex: none;
color: var(--dh-accent);
font-size: 10px;
}
.dh-ideas-loading {
display: flex;
gap: 8px;
align-items: center;
min-height: 58px;
color: var(--dh-muted);
font-size: 12px;
}
.dh-ideas-error {
padding: 12px 0;
color: #fda4af;
font-size: 12px;
}
.dh-app .dh-ideas-refresh {
display: flex;
gap: 6px;
align-items: center;
min-height: 32px;
margin-top: 7px;
color: var(--dh-accent);
font-size: 11px;
}
.dh-spin {
animation: dh-spin 1s linear infinite;
}
@keyframes dh-spin {
to {
transform: rotate(360deg);
}
}
@media (width>600px) {
.dh-conversation-list .dh-conversation-open {
padding-right: 56px !important;
}
}
@media (width<=600px) {
.dh-row-delete-desktop {
display: none;
}
.dh-swipe-hint {
display: block;
margin: -10px 0 14px !important;
color: var(--dh-muted);
font-size: 10px;
}
.dh-delete-dialog {
width: 100%;
max-width: 100%;
margin: auto 0 0;
padding: 24px 22px calc(22px + env(safe-area-inset-bottom));
border-radius: 22px 22px 0 0;
border-bottom: 0;
}
.dh-app .dh-compose-tools .dh-mobile-linebreak {
display: flex;
}
.dh-reply-ideas {
padding: 10px;
}
.dh-ideas-list {
max-height: 28dvh;
}
}
.dh-page-lead {
max-width: 650px;
color: var(--dh-muted);
@@ -699,7 +961,7 @@
margin-top: 6px;
}
.dh-profile-form > label,
.dh-settings > label {
.dh-settings-body > label {
display: flex;
flex-direction: column;
gap: 9px;
@@ -707,6 +969,11 @@
color: #d4cbd5;
font-size: 12px;
}
.dh-settings > label small {
color: var(--dh-muted);
font-size: 11px;
line-height: 1.7;
}
.dh-profile-form textarea,
.dh-settings textarea {
resize: vertical;
@@ -858,9 +1125,11 @@
background: #ffffff0b;
}
.dh-settings {
display: flex;
flex-direction: column;
width: min(520px, 100%);
max-height: 90dvh;
overflow: auto;
overflow: hidden;
padding: 28px;
background: var(--dh-panel);
border: 1px solid #ffffff1a;
@@ -868,6 +1137,7 @@
}
.dh-settings > header {
display: flex;
flex: none;
justify-content: space-between;
margin-bottom: 26px;
}
@@ -886,6 +1156,323 @@
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;
}
}
/* H5 选择项以底部抽屉编辑草稿,确认后才回填到对话设定。 */
.dh-mobile-choices {
display: none;
}
.dh-overlay.dh-sheet-open {
overflow: hidden;
}
.dh-app .dh-selection-backdrop {
touch-action: none;
}
.dh-selection-layer {
position: fixed;
inset: 0;
z-index: 2;
display: flex;
align-items: flex-end;
justify-content: center;
overscroll-behavior: contain;
}
.dh-selection-backdrop {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
background: #0009 !important;
}
.dh-selection-sheet {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
max-height: 86dvh;
min-height: 0;
overflow: hidden;
background: var(--dh-panel);
border: 1px solid #ffffff1c;
border-bottom: 0;
border-radius: 24px 24px 0 0;
box-shadow: 0 -16px 60px #0005;
animation: dh-sheet-enter 180ms ease-out;
}
.dh-sheet-handle {
flex: none;
width: 34px;
height: 4px;
margin: 10px auto 7px;
background: #ffffff35;
border-radius: 4px;
}
.dh-selection-sheet > header {
display: flex;
flex: none;
align-items: center;
justify-content: space-between;
padding: 10px 20px 18px;
}
.dh-selection-sheet h2 {
font-size: 20px;
font-weight: 600;
}
.dh-selection-sheet header p {
margin-top: 4px;
color: var(--dh-muted);
font-size: 11px;
}
.dh-selection-body {
flex: 1;
min-height: 0;
padding: 0 20px 20px;
overflow-y: auto;
overscroll-behavior: contain;
}
.dh-selection-sheet .dh-style-picker,
.dh-selection-sheet .dh-book-picker {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
.dh-selection-sheet .dh-checkbox {
min-height: 74px;
padding: 14px;
margin: 0 0 10px;
border: 1px solid #ffffff17;
border-radius: 13px;
cursor: pointer;
}
.dh-selection-sheet .dh-checkbox.is-selected {
background: color-mix(in srgb, var(--dh-accent) 9%, var(--dh-panel));
border-color: var(--dh-accent);
}
.dh-selection-sheet .dh-checkbox:focus-within {
outline: 2px solid var(--dh-accent);
outline-offset: 2px;
}
.dh-selection-sheet .dh-checkbox small {
font-size: 11px;
}
.dh-selection-sheet > footer {
display: flex;
flex: none;
gap: 12px;
padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
border-top: 1px solid var(--dh-line);
}
.dh-selection-sheet footer > button {
min-height: 46px;
}
.dh-selection-sheet footer > .dh-primary {
flex: 1;
justify-content: center;
}
.dh-sheet-reset {
min-width: 84px;
color: var(--dh-muted) !important;
font-size: 12px !important;
}
.dh-visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0 !important;
margin: -1px;
overflow: hidden;
white-space: nowrap;
clip-path: inset(50%);
}
@keyframes dh-sheet-enter {
from {
transform: translateY(100%);
}
to {
transform: translateY(0);
}
}
@media (width > 600px) {
.dh-selection-layer {
display: none;
}
}
@media (width <= 600px) {
.dh-desktop-choices {
display: none;
}
.dh-mobile-choices {
display: grid;
gap: 10px;
margin: 0 0 22px;
}
.dh-choice-trigger {
display: flex;
gap: 12px;
align-items: center;
width: 100%;
min-height: 78px;
padding: 15px 14px !important;
text-align: left;
border: 1px solid #ffffff17 !important;
border-radius: 13px;
background: var(--dh-soft) !important;
}
.dh-choice-trigger > svg {
flex: none;
width: 18px;
height: 18px;
color: var(--dh-accent);
}
.dh-choice-trigger > svg:last-child {
width: 16px;
color: var(--dh-muted);
}
.dh-choice-trigger > span {
flex: 1;
min-width: 0;
}
.dh-choice-trigger strong {
display: block;
font-size: 12px;
font-weight: 500;
}
.dh-choice-trigger small {
display: block;
margin-top: 5px;
overflow: hidden;
color: var(--dh-muted);
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.dh-checkbox {
display: flex;
gap: 12px;
@@ -910,7 +1497,16 @@
padding: 0 !important;
margin: -6px 0 22px;
}
.dh-settings-body {
flex: 1;
min-height: 0;
padding: 4px;
overflow-y: auto;
overscroll-behavior: contain;
}
.dh-settings > .dh-primary {
flex: none;
margin-top: 16px;
width: 100%;
}
/* 聊天固定在动态视口内;消息区独立滚动,输入框不会盖住底部消息。 */
@@ -1010,8 +1606,7 @@
overflow-y: auto;
overflow-x: hidden;
overscroll-behavior: contain;
scrollbar-width: thin;
scrollbar-color: #ffffff20 transparent;
scrollbar-width: none;
}
.dh-messages-inner {
max-width: 840px;
@@ -1495,7 +2090,7 @@
.dh-library-card h3 {
margin-top: 16px;
}
.dh-conversation-list > button {
.dh-conversation-list .dh-conversation-open {
gap: 12px;
padding: 13px;
}
@@ -1509,7 +2104,7 @@
.dh-conversation-list p {
font-size: 11px;
}
.dh-conversation-list > button > svg {
.dh-conversation-list .dh-conversation-open > svg {
display: none;
}
.dh-profile-banner {
@@ -1698,3 +2293,38 @@
body:has(.dh-app) .environment-badge {
display: none;
}
/* 内部区域保留手势和键盘滚动,不显示系统轨道,也不允许设定表单横向漂移。 */
.dh-app,
.dh-app * {
scrollbar-width: none !important;
}
.dh-app::-webkit-scrollbar,
.dh-app *::-webkit-scrollbar {
display: none !important;
width: 0 !important;
height: 0 !important;
}
.dh-settings-body,
.dh-selection-body,
.dh-detail-body,
.dh-ideas-list {
min-width: 0;
max-width: 100%;
overflow-x: hidden;
}
.dh-settings-body {
width: 100%;
}
.dh-settings-body > label,
.dh-settings fieldset,
.dh-selection-sheet fieldset {
min-width: 0;
max-width: 100%;
}
.dh-app textarea {
width: 100%;
max-width: 100%;
overflow-x: hidden;
overflow-wrap: anywhere;
}
+4 -2
View File
@@ -123,10 +123,12 @@ export type Bootstrap = {
catalog: Card[];
profile: Profile;
decision: {
variant: "A" | "B";
variant: string | null;
value?: unknown;
fallbackValue?: unknown;
decisionId: string | null;
expiresAt: number;
fallbackVariant: "A" | "B";
fallbackVariant: string | null;
};
serverNow: number;
};