Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a8ef8222c8 | |||
| 374ab1c606 | |||
| 5adb6eaec3 | |||
| 0f0aebe3a4 | |||
| b1c5610f23 | |||
| 1d045b7770 | |||
| a07ba77c5a | |||
| c4ea05ee0b | |||
| 781a735559 |
@@ -128,3 +128,7 @@ pnpm start:prod
|
|||||||
- `src/app/api/digital/[...path]/route.ts`:白名单 BFF,只转发前台接口,禁止访问后台实验管理,写入校验同源。
|
- `src/app/api/digital/[...path]/route.ts`:白名单 BFF,只转发前台接口,禁止访问后台实验管理,写入校验同源。
|
||||||
- 实验控制仅在 role-admin。前台没有切换实验或分组入口。
|
- 实验控制仅在 role-admin。前台没有切换实验或分组入口。
|
||||||
- `DEEPSEEK_API_KEY` 仅在业务后端配置,前端不读取、不保存。
|
- `DEEPSEEK_API_KEY` 仅在业务后端配置,前端不读取、不保存。
|
||||||
|
|
||||||
|
标签页图标采用 `public/stellar-icon-v2.svg`,同时提供多尺寸 `favicon.ico`、180/192/512 PNG,覆盖浏览器、Apple 主屏幕和 PWA。版本化资源路径用于刷新旧图标缓存。
|
||||||
|
|
||||||
|
通用实验消费者可经 `GET /api/digital/decisions/:key` 读取本人类型决策的 `data.value`,沿用 HttpOnly 会话与不缓存策略。类型、测试方案和用户分组全部在后台管理;新类型需要应用真实使用返回值并完成后台接入验收后才可启动。
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
packages:
|
||||||
|
- '.'
|
||||||
|
|
||||||
|
allowBuilds:
|
||||||
|
sharp: true
|
||||||
|
unrs-resolver: true
|
||||||
|
After Width: | Height: | Size: 5.3 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="17" fill="#171219"/><defs><linearGradient id="a" x2="1" y2="1"><stop stop-color="#e0b888"/><stop offset="1" stop-color="#fcaee4"/></linearGradient></defs><path d="M32 8C35 24 40 29 56 32 40 35 35 40 32 56 29 40 24 35 8 32 24 29 29 24 32 8Z" fill="url(#a)"/><circle cx="50" cy="13" r="3" fill="#fcaee4"/></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><linearGradient id="stellar" x1="12" y1="13" x2="49" y2="49" gradientUnits="userSpaceOnUse"><stop stop-color="#F4D5A3"/><stop offset="1" stop-color="#F5A8D9"/></linearGradient></defs><rect x="2" y="2" width="60" height="60" rx="18" fill="#211628"/><path d="M24 14h16c9 0 15 6 15 15v4c0 9-6 15-15 15H27L14 54l3-13c-4-3-6-7-6-12 0-9 5-15 13-15Z" fill="url(#stellar)"/><path d="M33 20c2.2 6.5 4.5 8.8 11 11-6.5 2.2-8.8 4.5-11 11-2.2-6.5-4.5-8.8-11-11 6.5-2.2 8.8-4.5 11-11Z" fill="#211628"/><circle cx="51" cy="13" r="5" fill="#F7B7DD" stroke="#211628" stroke-width="3"/></svg>
|
||||||
|
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 640 B |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><linearGradient id="stellar" x1="12" y1="13" x2="49" y2="49" gradientUnits="userSpaceOnUse"><stop stop-color="#F4D5A3"/><stop offset="1" stop-color="#F5A8D9"/></linearGradient></defs><rect x="2" y="2" width="60" height="60" rx="18" fill="#211628"/><path d="M24 14h16c9 0 15 6 15 15v4c0 9-6 15-15 15H27L14 54l3-13c-4-3-6-7-6-12 0-9 5-15 13-15Z" fill="url(#stellar)"/><path d="M33 20c2.2 6.5 4.5 8.8 11 11-6.5 2.2-8.8 4.5-11 11-2.2-6.5-4.5-8.8-11-11 6.5-2.2 8.8-4.5 11-11Z" fill="#211628"/><circle cx="51" cy="13" r="5" fill="#F7B7DD" stroke="#211628" stroke-width="3"/></svg>
|
||||||
|
After Width: | Height: | Size: 640 B |
@@ -33,11 +33,13 @@ async function proxy(
|
|||||||
const { path } = await context.params;
|
const { path } = await context.params;
|
||||||
const joined = path.join("/");
|
const joined = path.join("/");
|
||||||
if (
|
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|messages\/[a-zA-Z0-9_-]+))?)?)$/.test(
|
||||||
joined,
|
joined,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return Response.json({ message: "接口不存在" }, { status: 404 });
|
return Response.json({ message: "接口不存在" }, { status: 404 });
|
||||||
|
if (joined.startsWith("decisions/") && request.method !== "GET")
|
||||||
|
return Response.json({ message: "仅支持读取决策" }, {status:405,headers:{Allow:"GET"}});
|
||||||
if (request.method !== "GET") {
|
if (request.method !== "GET") {
|
||||||
const origin = request.headers.get("origin");
|
const origin = request.headers.get("origin");
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ export const metadata: Metadata = {
|
|||||||
description: "与有故事的人相遇,让每一段对话继续生长",
|
description: "与有故事的人相遇,让每一段对话继续生长",
|
||||||
manifest: "/manifest.webmanifest",
|
manifest: "/manifest.webmanifest",
|
||||||
icons: {
|
icons: {
|
||||||
icon: "/icon.svg",
|
icon: [
|
||||||
apple: "/icon.svg",
|
{ url: "/stellar-icon-v2.svg", type: "image/svg+xml" },
|
||||||
|
{ url: "/favicon.ico?v=stellar-2", sizes: "any" },
|
||||||
|
],
|
||||||
|
apple: "/stellar-icon-180-v2.png",
|
||||||
},
|
},
|
||||||
appleWebApp: {
|
appleWebApp: {
|
||||||
capable: true,
|
capable: true,
|
||||||
|
|||||||
@@ -12,8 +12,10 @@ export default function manifest(): MetadataRoute.Manifest {
|
|||||||
background_color: "#141218",
|
background_color: "#141218",
|
||||||
theme_color: "#141218",
|
theme_color: "#141218",
|
||||||
icons: [
|
icons: [
|
||||||
|
{ src: "/stellar-icon-192-v2.png", sizes: "192x192", type: "image/png" },
|
||||||
|
{ src: "/stellar-icon-512-v2.png", sizes: "512x512", type: "image/png" },
|
||||||
{
|
{
|
||||||
src: "/icon.svg",
|
src: "/stellar-icon-v2.svg",
|
||||||
sizes: "any",
|
sizes: "any",
|
||||||
type: "image/svg+xml",
|
type: "image/svg+xml",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import {
|
|||||||
RefreshCw,
|
RefreshCw,
|
||||||
Download,
|
Download,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
|
ChevronRight,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import {
|
import {
|
||||||
digital,
|
digital,
|
||||||
@@ -130,6 +131,14 @@ export function DigitalHome({
|
|||||||
const [profileDraft, setProfileDraft] = useState<Profile | null>(
|
const [profileDraft, setProfileDraft] = useState<Profile | null>(
|
||||||
initial.profile,
|
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 favoritePending = useRef(false);
|
const favoritePending = useRef(false);
|
||||||
const [activeMessage, setActiveMessage] = useState<string | null>(null),
|
const [activeMessage, setActiveMessage] = useState<string | null>(null),
|
||||||
[showJump, setShowJump] = useState(false),
|
[showJump, setShowJump] = useState(false),
|
||||||
@@ -258,13 +267,20 @@ export function DigitalHome({
|
|||||||
);
|
);
|
||||||
const controls = () =>
|
const controls = () =>
|
||||||
Array.from(
|
Array.from(
|
||||||
dialog?.querySelectorAll<HTMLElement>(
|
(
|
||||||
|
document.querySelector<HTMLElement>(".dh-selection-sheet") ?? dialog
|
||||||
|
)?.querySelectorAll<HTMLElement>(
|
||||||
'button:not([disabled]),input,textarea,select,[tabindex="0"]',
|
'button:not([disabled]),input,textarea,select,[tabindex="0"]',
|
||||||
) ?? [],
|
) ?? [],
|
||||||
);
|
);
|
||||||
const frame = requestAnimationFrame(() => controls()[0]?.focus());
|
const frame = requestAnimationFrame(() => controls()[0]?.focus());
|
||||||
const onKey = (event: globalThis.KeyboardEvent) => {
|
const onKey = (event: globalThis.KeyboardEvent) => {
|
||||||
if (event.key === "Escape") {
|
if (event.key === "Escape") {
|
||||||
|
event.preventDefault();
|
||||||
|
if (document.querySelector(".dh-selection-sheet")) {
|
||||||
|
setSelectionSheet(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setDetail(null);
|
setDetail(null);
|
||||||
setShowSettings(false);
|
setShowSettings(false);
|
||||||
}
|
}
|
||||||
@@ -288,6 +304,35 @@ export function DigitalHome({
|
|||||||
previous?.focus();
|
previous?.focus();
|
||||||
};
|
};
|
||||||
}, [detail, showSettings]);
|
}, [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(() => {
|
useEffect(() => {
|
||||||
const id = boot?.decision.decisionId;
|
const id = boot?.decision.decisionId;
|
||||||
if (!id || document.hidden) return;
|
if (!id || document.hidden) return;
|
||||||
@@ -586,6 +631,26 @@ export function DigitalHome({
|
|||||||
reportError(e);
|
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) {
|
async function saveSettings(event: FormEvent) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!conversation || !settings) return;
|
if (!conversation || !settings) return;
|
||||||
@@ -662,6 +727,97 @@ export function DigitalHome({
|
|||||||
(tag === "全部" || c.tags.includes(tag)) &&
|
(tag === "全部" || c.tags.includes(tag)) &&
|
||||||
(!onlyFavorites || profile?.favorites.includes(c.id)),
|
(!onlyFavorites || profile?.favorites.includes(c.id)),
|
||||||
);
|
);
|
||||||
|
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">为这段故事选一种氛围</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>
|
||||||
|
);
|
||||||
const modern = boot?.decision.variant === "B";
|
const modern = boot?.decision.variant === "B";
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -1384,12 +1540,14 @@ export function DigitalHome({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{showSettings && settings && (
|
{showSettings && settings && (
|
||||||
<div className="dh-overlay">
|
<div className={`dh-overlay ${selectionSheet ? "dh-sheet-open" : ""}`}>
|
||||||
<form
|
<form
|
||||||
className="dh-settings"
|
className="dh-settings"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-label="对话设定"
|
aria-label="对话设定"
|
||||||
|
aria-hidden={selectionSheet ? true : undefined}
|
||||||
|
inert={selectionSheet ? true : undefined}
|
||||||
onSubmit={saveSettings}
|
onSubmit={saveSettings}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
@@ -1406,101 +1564,188 @@ export function DigitalHome({
|
|||||||
<X />
|
<X />
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
<label>
|
<div className="dh-settings-body">
|
||||||
你的称呼
|
<label>
|
||||||
<input
|
你的称呼
|
||||||
maxLength={60}
|
<input
|
||||||
value={settings.userName}
|
maxLength={60}
|
||||||
onChange={(e) =>
|
value={settings.userName}
|
||||||
setSettings({ ...settings, userName: e.target.value })
|
onChange={(e) =>
|
||||||
}
|
setSettings({ ...settings, userName: e.target.value })
|
||||||
/>
|
}
|
||||||
</label>
|
/>
|
||||||
<label>
|
</label>
|
||||||
本次身份
|
<label>
|
||||||
<textarea
|
本次身份
|
||||||
rows={3}
|
<textarea
|
||||||
maxLength={2000}
|
rows={3}
|
||||||
value={settings.persona}
|
maxLength={2000}
|
||||||
onChange={(e) =>
|
value={settings.persona}
|
||||||
setSettings({ ...settings, persona: e.target.value })
|
onChange={(e) =>
|
||||||
}
|
setSettings({ ...settings, persona: e.target.value })
|
||||||
/>
|
}
|
||||||
</label>
|
/>
|
||||||
<button
|
</label>
|
||||||
className="dh-text-button"
|
<button
|
||||||
type="button"
|
className="dh-text-button"
|
||||||
onClick={() =>
|
type="button"
|
||||||
setSettings({
|
onClick={() =>
|
||||||
...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) =>
|
|
||||||
setSettings({
|
setSettings({
|
||||||
...settings,
|
...settings,
|
||||||
presetId: e.target.value || undefined,
|
userName: profile?.userName ?? "旅人",
|
||||||
|
persona: profile?.persona ?? "",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<option value="">角色默认风格</option>
|
使用我的身份资料
|
||||||
{presets.map((p) => (
|
</button>
|
||||||
<option key={p.id} value={p.id}>
|
<label>
|
||||||
{p.name}
|
固定记忆
|
||||||
</option>
|
<textarea
|
||||||
))}
|
rows={3}
|
||||||
</select>
|
maxLength={3000}
|
||||||
</label>
|
value={settings.memory}
|
||||||
<fieldset>
|
placeholder="记录你们共同经历的重要事实…"
|
||||||
<legend>加入世界书</legend>
|
onChange={(e) =>
|
||||||
{books.map((b) => (
|
setSettings({ ...settings, memory: e.target.value })
|
||||||
<label className="dh-checkbox" key={b.id}>
|
}
|
||||||
<input
|
/>
|
||||||
type="checkbox"
|
</label>
|
||||||
checked={settings.bookIds.includes(b.id)}
|
<div className="dh-mobile-choices">
|
||||||
onChange={(e) =>
|
<button
|
||||||
setSettings({
|
type="button"
|
||||||
...settings,
|
className="dh-choice-trigger"
|
||||||
bookIds: e.target.checked
|
aria-label="选择叙事风格"
|
||||||
? [...settings.bookIds, b.id]
|
onClick={() => openSelection("style")}
|
||||||
: settings.bookIds.filter((v) => v !== b.id),
|
>
|
||||||
})
|
<WandSparkles aria-hidden="true" />
|
||||||
}
|
|
||||||
/>
|
|
||||||
<span>
|
<span>
|
||||||
{b.name}
|
<strong>叙事风格</strong>
|
||||||
<small>{b.description}</small>
|
<small>
|
||||||
|
{presets.find((p) => p.id === settings.presetId)?.name ??
|
||||||
|
(settings.presetId ? "当前会话风格" : "角色默认风格")}
|
||||||
|
</small>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
<ChevronRight aria-hidden="true" />
|
||||||
))}
|
</button>
|
||||||
</fieldset>
|
<button
|
||||||
<p className="dh-form-note">
|
type="button"
|
||||||
保存后从下一次回复生效。可以固定单条消息,将它加入对话记忆。
|
className="dh-choice-trigger"
|
||||||
</p>
|
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 className="dh-primary" type="submit">
|
||||||
保存设定
|
保存设定
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</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>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -699,7 +699,7 @@
|
|||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
}
|
}
|
||||||
.dh-profile-form > label,
|
.dh-profile-form > label,
|
||||||
.dh-settings > label {
|
.dh-settings-body > label {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 9px;
|
gap: 9px;
|
||||||
@@ -858,9 +858,11 @@
|
|||||||
background: #ffffff0b;
|
background: #ffffff0b;
|
||||||
}
|
}
|
||||||
.dh-settings {
|
.dh-settings {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
width: min(520px, 100%);
|
width: min(520px, 100%);
|
||||||
max-height: 90dvh;
|
max-height: 90dvh;
|
||||||
overflow: auto;
|
overflow: hidden;
|
||||||
padding: 28px;
|
padding: 28px;
|
||||||
background: var(--dh-panel);
|
background: var(--dh-panel);
|
||||||
border: 1px solid #ffffff1a;
|
border: 1px solid #ffffff1a;
|
||||||
@@ -868,6 +870,7 @@
|
|||||||
}
|
}
|
||||||
.dh-settings > header {
|
.dh-settings > header {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: none;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 26px;
|
margin-bottom: 26px;
|
||||||
}
|
}
|
||||||
@@ -886,6 +889,323 @@
|
|||||||
color: var(--dh-muted);
|
color: var(--dh-muted);
|
||||||
padding: 0 6px;
|
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 {
|
.dh-checkbox {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
@@ -910,7 +1230,16 @@
|
|||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
margin: -6px 0 22px;
|
margin: -6px 0 22px;
|
||||||
}
|
}
|
||||||
|
.dh-settings-body {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 4px;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
}
|
||||||
.dh-settings > .dh-primary {
|
.dh-settings > .dh-primary {
|
||||||
|
flex: none;
|
||||||
|
margin-top: 16px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
/* 聊天固定在动态视口内;消息区独立滚动,输入框不会盖住底部消息。 */
|
/* 聊天固定在动态视口内;消息区独立滚动,输入框不会盖住底部消息。 */
|
||||||
|
|||||||