+
{environmentLabel}
{children}
diff --git a/src/app/manifest.ts b/src/app/manifest.ts
index 3f882b1..3b55cc0 100644
--- a/src/app/manifest.ts
+++ b/src/app/manifest.ts
@@ -1,21 +1,22 @@
+/** 数字人空间 PWA 元数据,保留原有安装机制。 */
import type { MetadataRoute } from "next";
export default function manifest(): MetadataRoute.Manifest {
return {
- name: "role-user 员工工作台",
- short_name: "员工工作台",
- description: "门店员工任务、公告、排班和个人中心",
- start_url: "/dashboard",
+ name: "星港 · 数字人空间",
+ short_name: "星港",
+ description: "你的私人数字人空间",
+ start_url: "/discover",
scope: "/",
display: "standalone",
- background_color: "#f4f4f6",
- theme_color: "#ffffff",
+ background_color: "#141218",
+ theme_color: "#141218",
icons: [
{
src: "/icon.svg",
sizes: "any",
- type: "image/svg+xml"
- }
- ]
+ type: "image/svg+xml",
+ },
+ ],
};
}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 9ef1235..c2d286d 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,5 +1,6 @@
+/** 默认入口进入数字人空间,登录由目标页统一校验。 */
import { redirect } from "next/navigation";
-
+/** 私有站点首页。 */
export default function HomePage() {
- redirect("/dashboard");
+ redirect("/discover");
}
diff --git a/src/components/digital-home.tsx b/src/components/digital-home.tsx
new file mode 100644
index 0000000..d7554d3
--- /dev/null
+++ b/src/components/digital-home.tsx
@@ -0,0 +1,1508 @@
+"use client";
+/* eslint-disable @next/next/no-img-element -- 本地封面直接读取,避免在小型服务器上运行图片转换。 */
+/** 星港数字人空间:探索、会话、世界书和身份资料的响应式入口。 */
+import Link from "next/link";
+import {
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+ type FormEvent,
+ type KeyboardEvent,
+} from "react";
+import {
+ ArrowLeft,
+ ArrowUp,
+ BookOpen,
+ Check,
+ Copy,
+ GitBranch,
+ Heart,
+ LoaderCircle,
+ LogOut,
+ MessageCircle,
+ MoreHorizontal,
+ Pin,
+ Plus,
+ Search,
+ Settings2,
+ Sparkles,
+ Square,
+ Trash2,
+ UserRound,
+ WandSparkles,
+ X,
+ RefreshCw,
+ Download,
+ ChevronDown,
+} from "lucide-react";
+import {
+ digital,
+ readStream,
+ type Card,
+ type Profile,
+ type Message,
+ type Settings,
+ type Conversation,
+ type Summary,
+ type Bootstrap,
+} from "@/lib/digital";
+import "./digital.css";
+type Tab = "discover" | "chats" | "library" | "me";
+/** 接收文本与视觉打字分离;减少动画设置下直接呈现完整文本。 */
+function TypedText({ text, animate }: { text: string; animate: boolean }) {
+ const [shown, setShown] = useState(animate ? "" : text);
+ const latest = useRef(text);
+ useEffect(() => {
+ latest.current = text;
+ }, [text]);
+ useEffect(() => {
+ if (!animate) return;
+ const instant = window.matchMedia(
+ "(prefers-reduced-motion: reduce)",
+ ).matches;
+ const timer = setInterval(
+ () =>
+ setShown((current) => {
+ const target = latest.current;
+ if (instant || !target.startsWith(current)) return target;
+ const rest = Array.from(target.slice(current.length));
+ return (
+ current +
+ rest
+ .slice(0, Math.max(1, Math.min(10, Math.ceil(rest.length / 15))))
+ .join("")
+ );
+ }),
+ 24,
+ );
+ return () => clearInterval(timer);
+ }, [animate]);
+ return <>{animate ? shown : text}>;
+}
+/** 内容完全作为文本渲染,角色对白不允许注入 HTML。 */
+function MessageText({
+ message,
+ animate,
+}: {
+ message: Message;
+ animate: boolean;
+}) {
+ return (
+
+
+ {message.status === "generating" && (
+
+ )}
+
+ );
+}
+/** 前台无分组按钮、调试开关或实验配置。 */
+export function DigitalHome({
+ initial,
+ initialSummaries,
+}: {
+ initial: Bootstrap;
+ initialSummaries: Summary[];
+}) {
+ const [tab, setTab] = useState
("discover"),
+ [boot, setBoot] = useState(initial),
+ [summaries, setSummaries] = useState(initialSummaries);
+ const [query, setQuery] = useState(""),
+ [tag, setTag] = useState("全部"),
+ [onlyFavorites, setOnlyFavorites] = useState(false);
+ const [detail, setDetail] = useState(null),
+ [conversation, setConversation] = useState(null);
+ const [draft, setDraft] = useState(""),
+ [busy, setBusy] = useState(false),
+ [opening, setOpening] = useState(false),
+ [error, setError] = useState(""),
+ [notice, setNotice] = useState("");
+ const [showSettings, setShowSettings] = useState(false),
+ [settings, setSettings] = useState(null),
+ [profile, setProfile] = useState(initial.profile);
+ const [profileDraft, setProfileDraft] = useState(
+ initial.profile,
+ );
+ const favoritePending = useRef(false);
+ const [activeMessage, setActiveMessage] = useState(null),
+ [showJump, setShowJump] = useState(false),
+ [showMenu, setShowMenu] = useState(false);
+ const decisionReceived = useRef(0);
+ const stream = useRef(null),
+ streamingId = useRef(null),
+ viewport = useRef(null),
+ messagesElement = useRef(null),
+ textarea = useRef(null),
+ atBottom = useRef(true),
+ currentId = useRef(null),
+ openSequence = useRef(0);
+ const cards = boot?.catalog.filter((c) => c.kind === "character") ?? [],
+ books = boot?.catalog.filter((c) => c.kind === "worldbook") ?? [],
+ presets = boot?.catalog.filter((c) => c.kind === "preset") ?? [];
+ const conversationId = conversation?.id;
+ const decisionExpiresAt = boot?.decision.expiresAt,
+ decisionServerNow = boot?.serverNow;
+ const currentCard = cards.find((c) => c.id === conversation?.characterId);
+ const reportError = useCallback(
+ (e: unknown) =>
+ setError(e instanceof Error ? e.message : "请求失败,请重试"),
+ [],
+ );
+ const refreshSummaries = useCallback(
+ async () => setSummaries(await digital("conversations")),
+ [],
+ );
+ const reloadBootstrap = useCallback(async () => {
+ const data = await digital("bootstrap");
+ decisionReceived.current = performance.now();
+ setBoot(data);
+ setProfile(data.profile);
+ }, []);
+ useEffect(() => {
+ decisionReceived.current = performance.now();
+ }, [initial]);
+ useEffect(() => {
+ const timer = setInterval(() => {
+ if (!document.hidden && !streamingId.current)
+ reloadBootstrap().catch(() => {});
+ }, 45000);
+ const onVisible = () => {
+ if (!document.hidden && !streamingId.current)
+ reloadBootstrap().catch(() => {});
+ };
+ document.addEventListener("visibilitychange", onVisible);
+ return () => {
+ clearInterval(timer);
+ document.removeEventListener("visibilitychange", onVisible);
+ stream.current?.abort();
+ };
+ }, [reloadBootstrap]);
+ useEffect(() => {
+ if (!decisionExpiresAt || !decisionServerNow) return;
+ const lifetime = Math.max(
+ 0,
+ Math.min(60000, decisionExpiresAt - decisionServerNow),
+ );
+ const remaining = Math.max(
+ 0,
+ lifetime - (performance.now() - decisionReceived.current),
+ );
+ const timer = setTimeout(
+ () =>
+ setBoot((current) =>
+ current
+ ? {
+ ...current,
+ decision: {
+ ...current.decision,
+ variant: current.decision.fallbackVariant,
+ decisionId: null,
+ },
+ }
+ : current,
+ ),
+ remaining,
+ );
+ return () => clearTimeout(timer);
+ }, [decisionExpiresAt, decisionServerNow]);
+ useEffect(() => {
+ if (!notice) return;
+ const timer = setTimeout(() => setNotice(""), 3500);
+ return () => clearTimeout(timer);
+ }, [notice]);
+ useEffect(() => {
+ const el = messagesElement.current;
+ if (!el) return;
+ const observer = new ResizeObserver(() => {
+ if (atBottom.current)
+ viewport.current?.scrollTo({
+ top: viewport.current.scrollHeight,
+ behavior: "instant",
+ });
+ });
+ observer.observe(el);
+ return () => observer.disconnect();
+ }, [conversationId]);
+ useEffect(() => {
+ if (!conversationId) return;
+ const resize = () =>
+ document.documentElement.style.setProperty(
+ "--dh-viewport",
+ `${window.visualViewport?.height ?? window.innerHeight}px`,
+ );
+ resize();
+ window.visualViewport?.addEventListener("resize", resize);
+ return () => {
+ window.visualViewport?.removeEventListener("resize", resize);
+ document.documentElement.style.removeProperty("--dh-viewport");
+ };
+ }, [conversationId]);
+ useEffect(() => {
+ if (!conversationId) return;
+ try {
+ sessionStorage.setItem(`dh-draft:${conversationId}`, draft);
+ } catch {}
+ }, [draft, conversationId]);
+ useEffect(() => {
+ if (!detail && !showSettings) return;
+ const previous = document.activeElement as HTMLElement | null;
+ const dialog = document.querySelector(
+ '.dh-overlay [role="dialog"]',
+ );
+ const controls = () =>
+ Array.from(
+ 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") {
+ setDetail(null);
+ setShowSettings(false);
+ }
+ if (event.key === "Tab") {
+ const items = controls(),
+ first = items[0],
+ last = items.at(-1);
+ if (event.shiftKey && document.activeElement === first) {
+ event.preventDefault();
+ last?.focus();
+ } else if (!event.shiftKey && document.activeElement === last) {
+ event.preventDefault();
+ first?.focus();
+ }
+ }
+ };
+ document.addEventListener("keydown", onKey);
+ return () => {
+ cancelAnimationFrame(frame);
+ document.removeEventListener("keydown", onKey);
+ previous?.focus();
+ };
+ }, [detail, showSettings]);
+ useEffect(() => {
+ const id = boot?.decision.decisionId;
+ if (!id || document.hidden) return;
+ const frame = requestAnimationFrame(() =>
+ digital("exposure", "POST", { decisionId: id }).catch(() => {}),
+ );
+ return () => cancelAnimationFrame(frame);
+ }, [boot?.decision.decisionId]);
+ useEffect(() => {
+ if (!busy || !conversationId || streamingId.current) return;
+ let cancelled = false;
+ const timer = setInterval(async () => {
+ if (document.hidden) return;
+ try {
+ const saved = await digital(
+ `conversations/${conversationId}`,
+ );
+ if (!cancelled && currentId.current === conversationId) {
+ setConversation(saved);
+ setBusy(saved.busy);
+ }
+ } catch {}
+ }, 2000);
+ return () => {
+ cancelled = true;
+ clearInterval(timer);
+ };
+ }, [busy, conversationId]);
+ async function openConversation(id: string) {
+ if (streamingId.current && streamingId.current !== id) {
+ setNotice("请先停止当前回复,再切换会话");
+ return;
+ }
+ const sequence = ++openSequence.current;
+ setOpening(true);
+ setError("");
+ try {
+ const c = await digital(`conversations/${id}`);
+ if (sequence !== openSequence.current) return;
+ setConversation(c);
+ currentId.current = id;
+ setSettings(c.settings);
+ setBusy(c.busy);
+ setActiveMessage(null);
+ setShowMenu(false);
+ atBottom.current = true;
+ try {
+ setDraft(sessionStorage.getItem(`dh-draft:${id}`) ?? "");
+ } catch {
+ setDraft("");
+ }
+ setTab("chats");
+ setDetail(null);
+ } catch (e) {
+ reportError(e);
+ } finally {
+ if (sequence === openSequence.current) setOpening(false);
+ }
+ }
+ async function start(card: Card, index = 0) {
+ if (opening) return;
+ setOpening(true);
+ setError("");
+ try {
+ const c = await digital<{ id: string }>("conversations", "POST", {
+ characterId: card.id,
+ greetingIndex: index,
+ uiDecisionId: boot?.decision.decisionId ?? undefined,
+ });
+ await openConversation(c.id);
+ await refreshSummaries();
+ } catch (e) {
+ reportError(e);
+ } finally {
+ setOpening(false);
+ }
+ }
+ async function favorite(card: Card) {
+ if (!profile || favoritePending.current) return;
+ favoritePending.current = true;
+ const next = {
+ ...profile,
+ favorites: profile.favorites.includes(card.id)
+ ? profile.favorites.filter((v) => v !== card.id)
+ : [...profile.favorites, card.id],
+ };
+ try {
+ await digital("profile", "PUT", next);
+ setProfile(next);
+ } catch (e) {
+ reportError(e);
+ } finally {
+ favoritePending.current = false;
+ }
+ }
+ async function send(mode: "send" | "regenerate" = "send") {
+ if (
+ !conversation ||
+ busy ||
+ streamingId.current ||
+ (mode === "send" && !draft.trim())
+ )
+ return;
+ const id = conversation.id,
+ content = draft.trim(),
+ requestId = crypto.randomUUID();
+ let assistantId = `pending-${requestId}`;
+ setBusy(true);
+ setError("");
+ setNotice("");
+ atBottom.current = true;
+ streamingId.current = id;
+ if (mode === "send") setDraft("");
+ const local: Message[] = [
+ ...(mode === "send"
+ ? [
+ {
+ id: `user-${requestId}`,
+ role: "user" as const,
+ content,
+ status: "complete",
+ pinned: false,
+ },
+ ]
+ : []),
+ {
+ id: assistantId,
+ role: "assistant",
+ content: "",
+ status: "generating",
+ pinned: false,
+ },
+ ];
+ setConversation((c) =>
+ c && c.id === id ? { ...c, messages: [...c.messages, ...local] } : c,
+ );
+ setActiveMessage(assistantId);
+ const controller = new AbortController();
+ stream.current = controller;
+ let accepted = false;
+ try {
+ const response = await fetch(`/api/digital/conversations/${id}/stream`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ requestId,
+ content,
+ mode,
+ uiDecisionId: boot?.decision.decisionId ?? undefined,
+ }),
+ signal: controller.signal,
+ });
+ if (response.status === 401) {
+ window.location.assign("/login");
+ return;
+ }
+ accepted = response.ok;
+ await readStream(response, (event, data) => {
+ if (event === "start") {
+ const next = String(data.messageId);
+ setConversation((c) =>
+ c && c.id === id
+ ? {
+ ...c,
+ messages: c.messages.map((m) =>
+ m.id === assistantId ? { ...m, id: next } : m,
+ ),
+ }
+ : c,
+ );
+ assistantId = next;
+ setActiveMessage(next);
+ }
+ if (event === "delta")
+ setConversation((c) =>
+ c && c.id === id
+ ? {
+ ...c,
+ messages: c.messages.map((m) =>
+ m.id === assistantId
+ ? { ...m, content: m.content + String(data.text ?? "") }
+ : m,
+ ),
+ }
+ : c,
+ );
+ if (event === "done")
+ setConversation((c) =>
+ c && c.id === id
+ ? {
+ ...c,
+ messages: c.messages.map((m) =>
+ m.id === assistantId
+ ? { ...m, status: String(data.status) }
+ : m,
+ ),
+ }
+ : c,
+ );
+ if (event === "notice" || event === "error")
+ setNotice(String(data.message ?? ""));
+ });
+ } catch (e) {
+ if (!controller.signal.aborted) reportError(e);
+ if (!accepted && mode === "send") setDraft(content);
+ } finally {
+ streamingId.current = null;
+ stream.current = null;
+ setBusy(false);
+ // 从数据库收敛临时消息和最终状态;取消后服务端可能仍在提交,延后一帧刷新。
+ await new Promise((resolve) => setTimeout(resolve, 200));
+ if (currentId.current === id)
+ try {
+ const saved = await digital(`conversations/${id}`);
+ setConversation(saved);
+ setBusy(saved.busy);
+ } catch (e) {
+ reportError(e);
+ }
+ refreshSummaries().catch(() => {});
+ }
+ }
+ async function stop() {
+ if (!conversation) return;
+ try {
+ await digital(`conversations/${conversation.id}/stop`, "POST", {});
+ if (!stream.current) {
+ await openConversation(conversation.id);
+ }
+ } catch (e) {
+ reportError(e);
+ }
+ }
+ function onKey(event: KeyboardEvent) {
+ if (
+ event.key === "Enter" &&
+ !event.shiftKey &&
+ !event.nativeEvent.isComposing &&
+ window.matchMedia("(min-width: 768px)").matches
+ ) {
+ event.preventDefault();
+ void send();
+ }
+ }
+ async function pin(message: Message) {
+ if (!conversation) return;
+ try {
+ await digital(
+ `conversations/${conversation.id}/messages/${message.id}`,
+ "PATCH",
+ { pinned: !message.pinned },
+ );
+ setConversation((c) =>
+ c
+ ? {
+ ...c,
+ messages: c.messages.map((m) =>
+ m.id === message.id ? { ...m, pinned: !m.pinned } : m,
+ ),
+ }
+ : c,
+ );
+ setNotice(message.pinned ? "已取消固定" : "已加入固定记忆");
+ } catch (e) {
+ reportError(e);
+ }
+ }
+ async function branch(message: Message) {
+ if (!conversation || busy) return;
+ try {
+ const result = await digital<{ id: string }>(
+ `conversations/${conversation.id}/branch`,
+ "POST",
+ { messageId: message.id },
+ );
+ await openConversation(result.id);
+ await refreshSummaries();
+ setNotice("已从这里开启新分支,原会话仍然保留");
+ } catch (e) {
+ reportError(e);
+ }
+ }
+ async function removeConversation() {
+ if (
+ !conversation ||
+ busy ||
+ !window.confirm("删除此会话和全部消息?此操作无法撤销。")
+ )
+ return;
+ try {
+ await digital(`conversations/${conversation.id}`, "DELETE");
+ setConversation(null);
+ currentId.current = null;
+ await refreshSummaries();
+ } catch (e) {
+ reportError(e);
+ }
+ }
+ async function saveSettings(event: FormEvent) {
+ event.preventDefault();
+ if (!conversation || !settings) return;
+ try {
+ await digital(`conversations/${conversation.id}`, "PATCH", { settings });
+ setConversation((c) => (c ? { ...c, settings } : c));
+ setShowSettings(false);
+ setNotice("对话设定已保存,下次回复生效");
+ } catch (e) {
+ reportError(e);
+ }
+ }
+ async function saveProfile(event: FormEvent) {
+ event.preventDefault();
+ if (!profile || !profileDraft) return;
+ const next = {
+ ...profile,
+ userName: profileDraft.userName,
+ persona: profileDraft.persona,
+ };
+ try {
+ await digital("profile", "PUT", next);
+ setProfile(next);
+ setNotice("身份资料已保存");
+ } catch (e) {
+ reportError(e);
+ }
+ }
+ async function copy(text: string) {
+ try {
+ await navigator.clipboard.writeText(text);
+ setNotice("已复制");
+ } catch {
+ setNotice("当前浏览器无法访问剪贴板");
+ }
+ }
+ function exportChat() {
+ if (!conversation) return;
+ const text = conversation.messages
+ .map(
+ (m) =>
+ `${m.role === "user" ? "我" : (currentCard?.name ?? "角色")}:\n${m.content}`,
+ )
+ .join("\n\n");
+ const url = URL.createObjectURL(
+ new Blob([text], { type: "text/plain;charset=utf-8" }),
+ );
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${conversation.title}.txt`;
+ a.click();
+ URL.revokeObjectURL(url);
+ }
+ function switchTab(value: Tab) {
+ if (conversation && busy) {
+ setNotice("请先停止当前回复,再离开会话");
+ return;
+ }
+ setConversation(null);
+ currentId.current = null;
+ setTab(value);
+ setError("");
+ }
+ const tags = [
+ "全部",
+ ...new Set(cards.flatMap((c) => c.tags).slice(0, 30)),
+ ].slice(0, 12);
+ const filtered = cards.filter(
+ (c) =>
+ (!query ||
+ `${c.name} ${c.description} ${c.tags.join(" ")}`
+ .toLowerCase()
+ .includes(query.toLowerCase())) &&
+ (tag === "全部" || c.tags.includes(tag)) &&
+ (!onlyFavorites || profile?.favorites.includes(c.id)),
+ );
+ const modern = boot?.decision.variant === "B";
+ return (
+
+
+
+ {error && (
+
+ {error}
+
+
+ )}
+ {notice && (
+
+ {notice}
+
+ )}
+ {!boot ? (
+
+
+ 正在开启你的星港…
+
+ ) : conversation ? (
+
+
+
+ {currentCard?.cover &&
}
+
+
{currentCard?.name ?? conversation.title}
+
+ {busy ? "正在回应你" : "故事由你们续写"}
+
+
+
+
+ {showMenu && (
+
+
+
+
+ )}
+
+
+ {
+ const v = viewport.current;
+ if (v) {
+ atBottom.current =
+ v.scrollHeight - v.scrollTop - v.clientHeight < 110;
+ setShowJump(!atBottom.current);
+ }
+ }}
+ >
+
+
+
✦
+
这里是你与 {currentCard?.name} 的私人故事
+
内容由 AI 生成,虚构世界中的角色可能会犯错。
+
+ {conversation.messages.map((m, index) => (
+
+ {m.role === "assistant" && (
+
+ )}
+
+
+ {m.role === "user"
+ ? conversation.settings.userName
+ : currentCard?.name}
+ {m.pinned && }
+
+
+
+ {!m.content && m.status === "generating" && (
+
+
+
+
+
+ )}
+
+ {!busy && m.content && (
+
+
+
+
+ {m.role === "assistant" &&
+ index === conversation.messages.length - 1 &&
+ conversation.messages.some(
+ (v) => v.role === "user",
+ ) && (
+
+ )}
+
+ )}
+ {!busy &&
+ !m.content &&
+ m.role === "assistant" &&
+ index === conversation.messages.length - 1 &&
+ conversation.messages.some(
+ (v) => v.role === "user",
+ ) && (
+
+ )}
+ {m.status === "failed" && (
+
+ 生成失败,可重新生成
+
+ )}
+ {m.status === "superseded" && (
+
此前回答
+ )}
+ {m.status === "stopped" && (
+
已停止
+ )}
+
+
+ ))}
+
+
+ {showJump && (
+
+ )}
+
+
+
+ {busy
+ ? "正在生成 · 点击方块随时停止"
+ : "Enter 发送 · Shift + Enter 换行"}
+
+ {draft.length > 3500
+ ? `${draft.length}/4000`
+ : "一段对白,一个新的可能"}
+
+
+
+
+ ) : (
+
+
+
+
YOUR PRIVATE UNIVERSE
+
+ {tab === "discover"
+ ? "遇见,让故事开始"
+ : tab === "chats"
+ ? "故事还在继续"
+ : tab === "library"
+ ? "为想象力,留一盏灯"
+ : "你想以谁的身份相遇?"}
+
+
+
+ ✦
+
+
+ {tab === "discover" && (
+ <>
+
+
+
今晚,有人等你开口
+
+ 不止聊天。
+
+ 走进另一个人的世界。
+
+
+ 一封未寄出的信,一次雨夜的重逢。
+
+ 挑选你心动的角色,写下只属于你们的下一章。
+
+
+
+
+ {cards.slice(0, 3).map((c) => (
+

+ ))}
+
✧
+
+
+
+
+
+
+
+ {tags.map((t) => (
+
+ ))}
+
+
+
{onlyFavorites ? "心动收藏" : "为你发现"}
+ {filtered.length} 位角色 · 全部成年
+
+
+ {filtered.map((c) => (
+
+
+
+
+ ))}
+
+ {!filtered.length && (
+
+
+
暂时没有找到
+
换一个关键词,或者看看其他故事。
+
+
+ )}
+ >
+ )}
+ {tab === "chats" && (
+ <>
+
+
最近对话
+
+
+
+ {summaries.map((s) => {
+ const c = cards.find((c) => c.id === s.characterId);
+ return (
+
+ );
+ })}
+
+ {!summaries.length && (
+
+
+
第一句话,交给你
+
每个角色都准备好了一段开场,等你接下去。
+
+
+ )}
+ >
+ )}
+ {tab === "library" && (
+ <>
+
+ 角色是灵魂,世界书是背景,预设决定叙事方式。在对话设定中组合它们,形成你自己的故事。
+
+
+
世界书
+ 按关键词触发的故事背景
+
+
+ {books.map((b) => (
+
+ ))}
+
+
+
叙事预设
+ 切换文字的节奏与温度
+
+
+ {presets.map((b) => (
+
+ ))}
+
+ >
+ )}
+ {tab === "me" && profile && profileDraft && (
+
+ )}
+
+
+ )}
+
+ {detail && (
+
{
+ if (e.target === e.currentTarget) setDetail(null);
+ }}
+ >
+
+
+ {detail.kind === "character" && (
+
+

+
+ )}
+
+
+ {detail.kind === "character"
+ ? `${detail.age} 岁 · ${detail.gender === "male" ? "男性" : "女性"}角色`
+ : detail.kind === "worldbook"
+ ? "WORLD BOOK"
+ : "STORY PRESET"}
+
+
{detail.name}
+
+ {detail.tags.map((t) => (
+ {t}
+ ))}
+
+
{detail.description}
+ {detail.greeting && (
+
+ {detail.greeting
+ .replaceAll("{{user}}", profile?.userName ?? "旅人")
+ .replaceAll("{{char}}", detail.name)}
+
+ )}
+ {detail.kind === "character" ? (
+ <>
+
+ {detail.alternateGreetings.map((g, i) => (
+
+ ))}
+ >
+ ) : (
+
+ 进入任意对话,点击右上角「对话设定」即可使用。
+
+ )}
+
{detail.source}
+
+
+
+ )}
+ {showSettings && settings && (
+
+
+
+ )}
+
+ );
+}
diff --git a/src/components/digital-login.css b/src/components/digital-login.css
new file mode 100644
index 0000000..81c7ff7
--- /dev/null
+++ b/src/components/digital-login.css
@@ -0,0 +1,180 @@
+/* 登录页与数字人前台共享深色金色基调。 */
+.stellar-login {
+ min-height: 100dvh;
+ background: #141218;
+ color: #f4eef4;
+ display: grid;
+ grid-template-columns: 1.1fr 1fr;
+ font-family: Inter, "PingFang SC", sans-serif;
+ color-scheme: dark;
+}
+.stellar-login-story {
+ padding: 45px 60px;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ background:
+ radial-gradient(ellipse at 60% 50%, #8e635644, transparent 65%),
+ linear-gradient(135deg, #281d29, #19141c);
+ border-right: 1px solid #ffffff0b;
+}
+.stellar-login-brand {
+ display: flex;
+ gap: 12px;
+ color: #e0b888;
+ text-decoration: none;
+ font-size: 38px;
+ align-items: center;
+}
+.stellar-login-brand span {
+ font-size: 26px;
+ color: #f4eef4;
+}
+.stellar-login-brand small {
+ font-size: 9px;
+ letter-spacing: 3px;
+ display: block;
+ color: #b09da9;
+}
+.stellar-login-story > div > p {
+ font-size: 10px;
+ letter-spacing: 4px;
+ color: #e0b888;
+}
+.stellar-login-story h1 {
+ font-size: 44px;
+ line-height: 1.5;
+ font-weight: 400;
+ letter-spacing: -1px;
+ margin: 22px 0;
+}
+.stellar-login-story > div > span {
+ font-size: 14px;
+ line-height: 2;
+ color: #b5a6b7;
+}
+.stellar-login-story > small {
+ font-size: 11px;
+ color: #9b879e;
+}
+.stellar-login-panel {
+ max-width: 470px;
+ width: 100%;
+ padding: 70px 40px;
+ margin: auto;
+}
+.stellar-login-panel h2 {
+ font-size: 26px;
+ font-weight: 500;
+ margin: 12px 0;
+}
+.stellar-login-panel > p {
+ font-size: 12px;
+ color: #aa9aaf;
+ margin-bottom: 32px;
+}
+.stellar-login-star {
+ font-size: 45px;
+ color: #e0b888;
+}
+.stellar-login-panel > .login-form {
+ gap: 20px;
+}
+.stellar-login-panel .login-form label {
+ color: #c5b7c9;
+ font-size: 12px;
+}
+.stellar-login-panel .input-wrap {
+ background: #211c25;
+ border: 1px solid #ffffff18;
+ border-radius: 10px;
+ color: #ac9bb2;
+}
+.stellar-login-panel .input-wrap:focus-within {
+ border-color: #e0b88888;
+}
+.stellar-login-panel input {
+ color: #f4eef4;
+ font-size: 16px;
+ background: none;
+}
+.stellar-login-panel input::placeholder {
+ color: #796d80;
+}
+.stellar-login-panel .primary-button {
+ background: #e0b888;
+ color: #2b1d11;
+ border-radius: 10px;
+ min-height: 46px;
+ font-size: 14px;
+}
+.stellar-login-panel > small {
+ display: block;
+ text-align: center;
+ color: #776a7d;
+ font-size: 10px;
+ margin-top: 28px;
+}
+.stellar-login-panel .form-error {
+ color: #ffa6a6;
+}
+.stellar-login-panel .icon-button {
+ color: #b3a1b9;
+}
+@media (max-width: 767px) {
+ .stellar-login {
+ grid-template-columns: 1fr;
+ min-height: 100dvh;
+ }
+ .stellar-login-story {
+ padding: 30px 25px 22px;
+ border: 0;
+ background: radial-gradient(ellipse at 80% 50%, #8e635638, transparent 70%);
+ }
+ .stellar-login-brand {
+ font-size: 25px;
+ }
+ .stellar-login-brand span {
+ font-size: 21px;
+ }
+ .stellar-login-brand small {
+ display: none;
+ }
+ .stellar-login-story > div {
+ padding-top: 30px;
+ }
+ .stellar-login-story h1 {
+ font-size: 29px;
+ line-height: 1.5;
+ margin: 12px 0;
+ }
+ .stellar-login-story > div > p {
+ font-size: 8px;
+ letter-spacing: 3px;
+ }
+ .stellar-login-story > div > span {
+ display: none;
+ }
+ .stellar-login-story > small {
+ display: none;
+ }
+ .stellar-login-panel {
+ padding: 12px 25px 45px;
+ max-width: 470px;
+ }
+ .stellar-login-star {
+ display: none;
+ }
+ .stellar-login-panel h2 {
+ font-size: 21px;
+ margin: 10px 0;
+ }
+ .stellar-login-panel > p {
+ font-size: 11px;
+ margin-bottom: 25px;
+ }
+}
+
+body:has(.stellar-login) .environment-badge {
+ display: none;
+}
diff --git a/src/components/digital.css b/src/components/digital.css
new file mode 100644
index 0000000..bf4e407
--- /dev/null
+++ b/src/components/digital.css
@@ -0,0 +1,1700 @@
+/* 星港双方案视觉:沿用现有项目的深色金色与深色粉色基调,独立组织响应式页面。 */
+.dh-app {
+ --dh-bg: #141218;
+ --dh-panel: #201c23;
+ --dh-soft: #2a242e;
+ --dh-line: #ffffff12;
+ --dh-text: #f4eef4;
+ --dh-muted: #ada4b0;
+ --dh-accent: #e0b888;
+ --dh-accent-ink: #2c2014;
+ --dh-card-radius: 3px;
+ color: var(--dh-text);
+ background: var(--dh-bg);
+ min-height: 100dvh;
+ font-family: Inter, "PingFang SC", sans-serif;
+ font-size: 14px;
+ line-height: 1.6;
+ color-scheme: dark;
+}
+.dh-app.dh-modern {
+ --dh-bg: #101010;
+ --dh-panel: #1b1a1c;
+ --dh-soft: #252326;
+ --dh-accent: #fcaee4;
+ --dh-accent-ink: #38162e;
+ --dh-card-radius: 12px;
+}
+.dh-app * {
+ box-sizing: border-box;
+}
+.dh-app button,
+.dh-app input,
+.dh-app textarea,
+.dh-app select {
+ font: inherit;
+}
+.dh-app button,
+.dh-app a {
+ touch-action: manipulation;
+}
+.dh-app button {
+ cursor: pointer;
+ border: 0;
+ color: inherit;
+ background: none;
+}
+.dh-app button:disabled {
+ opacity: 0.42;
+ cursor: not-allowed;
+}
+.dh-app a {
+ color: inherit;
+ text-decoration: none;
+}
+.dh-app button:focus-visible,
+.dh-app a:focus-visible,
+.dh-app input:focus-visible,
+.dh-app textarea:focus-visible,
+.dh-app select:focus-visible {
+ outline: 2px solid var(--dh-accent);
+ outline-offset: 4px;
+}
+.dh-app h1,
+.dh-app h2,
+.dh-app h3,
+.dh-app p {
+ margin: 0;
+}
+.dh-app input,
+.dh-app textarea,
+.dh-app select {
+ color: var(--dh-text);
+ background: var(--dh-panel);
+ border: 1px solid var(--dh-line);
+ border-radius: 10px;
+ padding: 12px 14px;
+ min-width: 0;
+}
+.dh-app input::placeholder,
+.dh-app textarea::placeholder {
+ color: #837985;
+}
+.dh-sidebar {
+ width: 244px;
+ position: fixed;
+ inset: 0 auto 0 0;
+ border-right: 1px solid var(--dh-line);
+ display: flex;
+ flex-direction: column;
+ padding: 34px 20px 22px;
+ background: var(--dh-bg);
+ z-index: 10;
+}
+.dh-brand {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ font-size: 24px;
+ font-weight: 700;
+ letter-spacing: 2px;
+}
+.dh-brand-mark {
+ font-size: 34px;
+ color: var(--dh-accent);
+}
+.dh-brand-en {
+ font-size: 9px;
+ font-weight: 500;
+ letter-spacing: 2.5px;
+ color: var(--dh-muted);
+ align-self: flex-end;
+ margin-bottom: 9px;
+}
+.dh-sidebar-caption {
+ font-size: 11px;
+ color: var(--dh-muted);
+ padding: 8px 2px 40px;
+}
+.dh-sidebar nav {
+ display: flex;
+ flex-direction: column;
+ gap: 9px;
+}
+.dh-sidebar nav button {
+ display: flex;
+ align-items: center;
+ gap: 14px;
+ padding: 14px 16px;
+ border-radius: 12px;
+ color: var(--dh-muted);
+ text-align: left;
+}
+.dh-sidebar nav button small {
+ margin-left: auto;
+ font-size: 11px;
+}
+.dh-sidebar nav button.is-active {
+ color: var(--dh-accent);
+ background: color-mix(in srgb, var(--dh-accent) 9%, transparent);
+}
+.dh-sidebar nav button:hover {
+ background: var(--dh-panel);
+}
+.dh-sidebar-bottom {
+ margin-top: auto;
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding-top: 24px;
+ border-top: 1px solid var(--dh-line);
+}
+.dh-avatar {
+ width: 40px;
+ height: 40px;
+ border: 1px solid color-mix(in srgb, var(--dh-accent) 30%, transparent);
+ background: color-mix(in srgb, var(--dh-accent) 9%, transparent);
+ border-radius: 50%;
+ display: grid;
+ place-items: center;
+ color: var(--dh-accent);
+ flex: none;
+}
+.dh-sidebar-bottom strong {
+ font-weight: 500;
+ font-size: 12px;
+}
+.dh-sidebar-bottom small {
+ display: block;
+ font-size: 9px;
+ color: var(--dh-muted);
+}
+.dh-sidebar-bottom a {
+ margin-left: auto;
+ color: var(--dh-muted);
+ padding: 8px;
+}
+.dh-main {
+ margin-left: 244px;
+ position: relative;
+ min-height: 100dvh;
+}
+.dh-page {
+ max-width: 1440px;
+ padding: 40px 48px 20px;
+ margin: auto;
+}
+.dh-page-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 30px;
+}
+.dh-eyebrow {
+ font-size: 9px;
+ letter-spacing: 2.3px;
+ color: var(--dh-accent);
+ font-weight: 600;
+ margin-bottom: 7px !important;
+}
+.dh-page-header h1 {
+ font-size: 27px;
+ font-weight: 600;
+ letter-spacing: -0.8px;
+}
+.dh-header-orbit {
+ font-size: 32px;
+ color: var(--dh-accent);
+ opacity: 0.7;
+}
+.dh-hero {
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ justify-content: space-between;
+ min-height: 320px;
+ border: 1px solid color-mix(in srgb, var(--dh-accent) 16%, transparent);
+ border-radius: 20px;
+ background:
+ radial-gradient(ellipse at 85% 50%, #724d424f, transparent 65%),
+ linear-gradient(110deg, #2b2027, #1c171f);
+ padding: 36px 38px;
+ margin-bottom: 30px;
+}
+.dh-modern .dh-hero {
+ background:
+ radial-gradient(ellipse at 85% 50%, #6f365346, transparent 65%),
+ linear-gradient(110deg, #2a202a, #18151a);
+}
+.dh-pill {
+ display: inline-block;
+ border: 1px solid #ffffff18;
+ border-radius: 20px;
+ padding: 4px 10px;
+ font-size: 10px;
+ color: var(--dh-accent);
+ margin-bottom: 17px;
+}
+.dh-hero h2 {
+ font-size: 32px;
+ line-height: 1.4;
+ letter-spacing: -1px;
+ font-weight: 500;
+}
+.dh-hero p {
+ font-size: 12px;
+ line-height: 1.9;
+ color: #c1b2bd;
+ margin: 14px 0 23px;
+}
+.dh-primary {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 9px;
+ background: var(--dh-accent) !important;
+ color: var(--dh-accent-ink) !important;
+ border-radius: 10px;
+ padding: 11px 20px;
+ font-weight: 600 !important;
+ min-height: 43px;
+}
+.dh-primary:hover {
+ filter: brightness(1.06);
+}
+.dh-hero-art {
+ position: relative;
+ flex: 0 0 42%;
+ min-width: 230px;
+ max-width: 470px;
+}
+.dh-hero-art img {
+ position: absolute;
+ width: 42%;
+ height: 87%;
+ object-fit: cover;
+ border-radius: 11px;
+ box-shadow: 0 15px 30px #0008;
+ border: 1px solid #ffffff22;
+ top: 8%;
+}
+.dh-hero-art img:nth-child(1) {
+ left: 0;
+ transform: rotate(-14deg);
+}
+.dh-hero-art img:nth-child(2) {
+ left: 31%;
+ z-index: 2;
+ top: 0;
+}
+.dh-hero-art img:nth-child(3) {
+ left: 60%;
+ transform: rotate(13deg);
+}
+.dh-orbit {
+ position: absolute;
+ z-index: 3;
+ right: 0;
+ bottom: 0;
+ font-size: 70px;
+ color: var(--dh-accent);
+ text-shadow: 0 2px 20px #000;
+}
+.dh-discovery-tools {
+ display: flex;
+ align-items: center;
+ gap: 14px;
+ margin-bottom: 17px;
+}
+.dh-search {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ border: 1px solid var(--dh-line);
+ background: var(--dh-panel);
+ border-radius: 11px;
+ flex: 1;
+ max-width: 540px;
+ padding: 0 14px;
+ color: var(--dh-muted);
+}
+.dh-search input {
+ border: none;
+ background: none;
+ flex: 1;
+ padding: 12px 0;
+ outline: none !important;
+}
+.dh-search button {
+ padding: 4px;
+ display: grid;
+ place-items: center;
+}
+.dh-favorite-filter {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ border: 1px solid var(--dh-line) !important;
+ padding: 11px 15px;
+ border-radius: 10px;
+ color: var(--dh-muted) !important;
+ white-space: nowrap;
+}
+.dh-favorite-filter.is-active {
+ color: var(--dh-accent) !important;
+}
+.dh-tags {
+ display: flex;
+ gap: 8px;
+ overflow: auto;
+ scrollbar-width: none;
+ padding-bottom: 8px;
+}
+.dh-tags button {
+ white-space: nowrap;
+ padding: 7px 15px;
+ border-radius: 8px;
+ color: var(--dh-muted);
+ font-size: 12px;
+}
+.dh-tags button.is-active {
+ color: var(--dh-accent);
+ background: color-mix(in srgb, var(--dh-accent) 10%, transparent);
+}
+.dh-section-heading {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin: 23px 0 18px;
+ gap: 12px;
+}
+.dh-section-heading h2 {
+ font-size: 17px;
+ font-weight: 600;
+}
+.dh-section-heading > span {
+ font-size: 11px;
+ color: var(--dh-muted);
+}
+.dh-section-heading > button {
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ color: var(--dh-accent);
+ font-size: 12px;
+}
+.dh-card-grid {
+ display: grid;
+ grid-template-columns: repeat(4, minmax(0, 1fr));
+ gap: 18px;
+}
+.dh-card {
+ position: relative;
+ overflow: hidden;
+ isolation: isolate;
+ border-radius: var(--dh-card-radius);
+ aspect-ratio: 0.605;
+ background: var(--dh-panel);
+}
+.dh-modern .dh-card {
+ aspect-ratio: 170/262;
+}
+.dh-card-open {
+ position: relative;
+ display: block;
+ width: 100%;
+ height: 100%;
+ text-align: left;
+ padding: 0 !important;
+}
+.dh-card-open > img {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ transition: transform 0.4s;
+}
+.dh-card:hover .dh-card-open > img {
+ transform: scale(1.035);
+}
+.dh-card-shade {
+ position: absolute;
+ inset: 20% 0 0;
+ background: linear-gradient(
+ transparent,
+ #17131955 30%,
+ #171319e8 70%,
+ #171319
+ );
+}
+.dh-modern .dh-card-shade {
+ background: linear-gradient(
+ transparent,
+ #13131355 30%,
+ #131313eb 75%,
+ #131313
+ );
+}
+.dh-card-content {
+ position: absolute;
+ bottom: 0;
+ padding: 17px 14px 15px;
+ left: 0;
+ right: 0;
+}
+.dh-card-kicker {
+ font-size: 9px;
+ color: #ead9e3c9;
+}
+.dh-card h3 {
+ font-size: 17px;
+ line-height: 1.4;
+ font-weight: 600;
+ margin: 4px 0 6px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.dh-card-content p {
+ font-size: 11px;
+ line-height: 1.65;
+ color: #d1c4d0;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+}
+.dh-card-tags {
+ display: flex;
+ gap: 5px;
+ flex-wrap: wrap;
+ margin-top: 10px;
+}
+.dh-card-tags span {
+ font-size: 9px;
+ padding: 2px 7px;
+ background: #ffffff10;
+ border: 1px solid #ffffff0a;
+ border-radius: 5px;
+ color: #dfd0dc;
+}
+.dh-card-favorite {
+ position: absolute;
+ top: 10px;
+ right: 10px;
+ border: 1px solid #ffffff25 !important;
+ background: #0005 !important;
+ backdrop-filter: blur(10px);
+ border-radius: 50%;
+ width: 33px;
+ height: 33px;
+ display: grid;
+ place-items: center;
+ color: white;
+}
+.dh-card-favorite.is-active {
+ color: var(--dh-accent);
+}
+.dh-footer {
+ display: flex;
+ justify-content: center;
+ gap: 12px;
+ align-items: center;
+ font-size: 10px;
+ color: #807481;
+ padding: 45px 0 20px;
+ letter-spacing: 1px;
+}
+.dh-footer span {
+ color: var(--dh-accent);
+}
+.dh-empty {
+ padding: 70px 20px;
+ text-align: center;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ color: var(--dh-muted);
+ gap: 12px;
+}
+.dh-empty > svg {
+ color: var(--dh-accent);
+ width: 32px;
+ height: 32px;
+}
+.dh-empty h3 {
+ color: var(--dh-text);
+ font-weight: 500;
+}
+.dh-empty p {
+ font-size: 13px;
+}
+.dh-empty button {
+ margin-top: 15px;
+ color: var(--dh-accent);
+}
+.dh-loading {
+ min-height: 80dvh;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 14px;
+ color: var(--dh-muted);
+}
+.dh-spin {
+ animation: dh-spin 1s linear infinite;
+}
+@keyframes dh-spin {
+ to {
+ transform: rotate(360deg);
+ }
+}
+.dh-error {
+ position: fixed;
+ z-index: 100;
+ top: 18px;
+ left: calc(244px + 5%);
+ right: 5%;
+ margin: auto;
+ max-width: 700px;
+ padding: 12px 16px;
+ color: #ffd8d8;
+ background: #48282c;
+ border: 1px solid #a55463;
+ border-radius: 10px;
+ display: flex;
+ justify-content: space-between;
+ gap: 20px;
+}
+.dh-toast {
+ position: fixed;
+ bottom: 110px;
+ left: calc(244px + 50%);
+ transform: translateX(-50%);
+ padding: 12px 20px;
+ border: 1px solid #ffffff22;
+ background: #302b34ed;
+ backdrop-filter: blur(16px);
+ box-shadow: 0 10px 35px #0006;
+ z-index: 110;
+ border-radius: 12px;
+ font-size: 12px;
+ max-width: 85vw;
+ width: max-content;
+}
+.dh-conversation-list {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+.dh-conversation-list > button {
+ border: 1px solid var(--dh-line);
+ background: var(--dh-panel);
+ border-radius: 14px;
+ padding: 16px;
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ text-align: left;
+}
+.dh-conversation-list > button:hover {
+ border-color: #ffffff25;
+}
+.dh-conversation-list img {
+ width: 64px;
+ height: 76px;
+ object-fit: cover;
+ border-radius: 9px;
+}
+.dh-conversation-list h3 {
+ font-size: 15px;
+ font-weight: 500;
+}
+.dh-conversation-list p {
+ font-size: 12px;
+ color: var(--dh-muted);
+ max-width: 550px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ margin-top: 5px;
+}
+.dh-conversation-list > button > div {
+ min-width: 0;
+ flex: 1;
+}
+.dh-conversation-list small {
+ font-size: 10px;
+ color: var(--dh-muted);
+ white-space: nowrap;
+}
+.dh-conversation-list svg {
+ color: var(--dh-accent);
+ flex: none;
+}
+.dh-page-lead {
+ max-width: 650px;
+ color: var(--dh-muted);
+ line-height: 1.9;
+ margin-bottom: 30px !important;
+}
+.dh-library-grid {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 16px;
+ margin-bottom: 30px;
+}
+.dh-library-card {
+ border: 1px solid var(--dh-line) !important;
+ background: linear-gradient(130deg, var(--dh-panel), var(--dh-bg)) !important;
+ padding: 24px !important;
+ border-radius: 14px;
+ text-align: left;
+}
+.dh-library-card > svg {
+ color: var(--dh-accent);
+}
+.dh-library-card > small {
+ float: right;
+ color: var(--dh-muted);
+ font-size: 10px;
+}
+.dh-library-card h3 {
+ font-size: 17px;
+ margin: 20px 0 10px;
+}
+.dh-library-card p {
+ font-size: 12px;
+ line-height: 1.9;
+ color: var(--dh-muted);
+ min-height: 65px;
+}
+.dh-library-card > span {
+ display: block;
+ margin-top: 20px;
+ color: var(--dh-accent);
+ font-size: 11px;
+}
+.dh-profile-form {
+ max-width: 650px;
+}
+.dh-profile-banner {
+ display: flex;
+ gap: 18px;
+ align-items: center;
+ padding: 20px 0 30px;
+}
+.dh-profile-banner .dh-avatar {
+ width: 66px;
+ height: 66px;
+ font-size: 24px;
+}
+.dh-profile-banner h2 {
+ font-size: 23px;
+}
+.dh-profile-banner p {
+ color: var(--dh-muted);
+ font-size: 12px;
+ margin-top: 6px;
+}
+.dh-profile-form > label,
+.dh-settings > label {
+ display: flex;
+ flex-direction: column;
+ gap: 9px;
+ margin-bottom: 20px;
+ color: #d4cbd5;
+ font-size: 12px;
+}
+.dh-profile-form textarea,
+.dh-settings textarea {
+ resize: vertical;
+ line-height: 1.8;
+}
+.dh-form-note {
+ color: var(--dh-muted);
+ font-size: 11px;
+ line-height: 1.9;
+ margin: 8px 0 20px !important;
+}
+.dh-profile-stats {
+ display: flex;
+ border-top: 1px solid var(--dh-line);
+ border-bottom: 1px solid var(--dh-line);
+ padding: 22px 0;
+ margin: 40px 0;
+ gap: 60px;
+}
+.dh-profile-stats strong {
+ display: block;
+ font-size: 24px;
+ font-weight: 400;
+ color: var(--dh-accent);
+}
+.dh-profile-stats span {
+ font-size: 11px;
+ color: var(--dh-muted);
+}
+.dh-logout {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--dh-muted) !important;
+ font-size: 12px;
+}
+.dh-overlay {
+ position: fixed;
+ inset: 0;
+ background: #000b;
+ backdrop-filter: blur(8px);
+ z-index: 90;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 28px;
+ overflow: auto;
+}
+.dh-detail {
+ position: relative;
+ display: flex;
+ width: min(840px, 100%);
+ max-height: 85dvh;
+ background: var(--dh-panel);
+ border: 1px solid #ffffff1a;
+ border-radius: 20px;
+ overflow: hidden;
+ box-shadow: 0 30px 100px #0009;
+}
+.dh-close {
+ position: absolute;
+ right: 15px;
+ top: 15px;
+ z-index: 3;
+ display: grid;
+ place-items: center;
+ width: 34px;
+ height: 34px;
+ border-radius: 50%;
+ background: #0007 !important;
+ backdrop-filter: blur(10px);
+}
+.dh-detail-cover {
+ width: 42%;
+ flex: none;
+ min-height: 500px;
+}
+.dh-detail-cover img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+.dh-detail-body {
+ padding: 40px 32px;
+ overflow: auto;
+ flex: 1;
+}
+.dh-detail-body h2 {
+ font-size: 30px;
+ line-height: 1.3;
+ margin-bottom: 14px;
+}
+.dh-detail-description {
+ color: #c5bbc8;
+ font-size: 13px;
+ line-height: 1.9;
+ margin: 22px 0 !important;
+ white-space: pre-wrap;
+}
+.dh-detail blockquote {
+ margin: 20px 0;
+ padding: 16px 20px;
+ border-left: 2px solid var(--dh-accent);
+ background: #ffffff05;
+ border-radius: 0 8px 8px 0;
+ color: #dbceda;
+ font-size: 12px;
+ line-height: 1.9;
+ white-space: pre-wrap;
+}
+.dh-detail .dh-primary {
+ width: 100%;
+ margin: 10px 0;
+}
+.dh-source {
+ display: block;
+ color: #8f8494;
+ font-size: 9px;
+ line-height: 1.7;
+ margin-top: 22px;
+ word-break: break-word;
+}
+.dh-alt-greeting {
+ display: block;
+ text-align: left;
+ padding: 12px !important;
+ width: 100%;
+ border: 1px solid var(--dh-line) !important;
+ border-radius: 9px;
+ margin-top: 10px;
+}
+.dh-alt-greeting small {
+ color: var(--dh-accent);
+}
+.dh-alt-greeting p {
+ font-size: 11px;
+ color: var(--dh-muted);
+ margin-top: 7px;
+}
+.dh-icon {
+ display: grid;
+ place-items: center;
+ width: 38px;
+ height: 38px;
+ flex: none;
+ border-radius: 9px;
+}
+.dh-icon:hover {
+ background: #ffffff0b;
+}
+.dh-settings {
+ width: min(520px, 100%);
+ max-height: 90dvh;
+ overflow: auto;
+ padding: 28px;
+ background: var(--dh-panel);
+ border: 1px solid #ffffff1a;
+ border-radius: 18px;
+}
+.dh-settings > header {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 26px;
+}
+.dh-settings h2 {
+ font-size: 24px;
+ font-weight: 500;
+}
+.dh-settings fieldset {
+ border: 1px solid var(--dh-line);
+ border-radius: 10px;
+ padding: 14px;
+ margin: 20px 0;
+}
+.dh-settings legend {
+ font-size: 12px;
+ color: var(--dh-muted);
+ padding: 0 6px;
+}
+.dh-checkbox {
+ display: flex;
+ gap: 12px;
+ align-items: flex-start;
+ font-size: 12px;
+ margin-bottom: 12px;
+}
+.dh-checkbox input {
+ margin-top: 5px;
+ accent-color: var(--dh-accent);
+}
+.dh-checkbox small {
+ display: block;
+ color: var(--dh-muted);
+ font-size: 10px;
+ line-height: 1.7;
+ margin-top: 4px;
+}
+.dh-text-button {
+ color: var(--dh-accent) !important;
+ font-size: 11px !important;
+ padding: 0 !important;
+ margin: -6px 0 22px;
+}
+.dh-settings > .dh-primary {
+ width: 100%;
+}
+/* 聊天固定在动态视口内;消息区独立滚动,输入框不会盖住底部消息。 */
+.dh-chat {
+ height: var(--dh-viewport, 100dvh);
+ display: flex;
+ flex-direction: column;
+ position: relative;
+ overflow: hidden;
+ background: var(--dh-bg);
+ isolation: isolate;
+}
+.dh-chat-header {
+ height: 82px;
+ padding: 0 28px;
+ display: flex;
+ align-items: center;
+ gap: 13px;
+ border-bottom: 1px solid var(--dh-line);
+ background: color-mix(in srgb, var(--dh-bg) 87%, transparent);
+ backdrop-filter: blur(20px);
+ z-index: 2;
+ flex: none;
+}
+.dh-chat-header > img {
+ width: 42px;
+ height: 48px;
+ object-fit: cover;
+ border-radius: 10px;
+}
+.dh-chat-header > div:not(.dh-chat-menu) {
+ flex: 1;
+}
+.dh-chat-header h1 {
+ font-size: 16px;
+ font-weight: 500;
+}
+.dh-chat-header small {
+ font-size: 10px;
+ color: var(--dh-muted);
+ display: flex;
+ align-items: center;
+ gap: 5px;
+}
+.dh-chat-header small i {
+ width: 5px;
+ height: 5px;
+ border-radius: 50%;
+ background: #9ac9a7;
+}
+.dh-chat-backdrop {
+ position: absolute;
+ inset: 82px 0 0;
+ background-position: center 26%;
+ background-size: cover;
+ opacity: 0.1;
+ filter: blur(4px);
+ z-index: -2;
+}
+.dh-chat:after {
+ content: "";
+ position: absolute;
+ inset: 82px 0 0;
+ z-index: -1;
+ background:
+ linear-gradient(90deg, var(--dh-bg), transparent 45%, var(--dh-bg)),
+ linear-gradient(0deg, var(--dh-bg), transparent 70%);
+}
+.dh-chat-menu {
+ position: absolute;
+ right: 25px;
+ top: 72px;
+ width: 160px;
+ padding: 7px;
+ background: var(--dh-panel);
+ border: 1px solid #ffffff20;
+ border-radius: 10px;
+ box-shadow: 0 10px 30px #0007;
+ z-index: 8;
+}
+.dh-chat-menu button {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ width: 100%;
+ padding: 10px;
+ border-radius: 6px;
+ text-align: left;
+ font-size: 12px;
+}
+.dh-chat-menu button:hover {
+ background: var(--dh-soft);
+}
+.dh-messages {
+ flex: 1;
+ min-height: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+ overscroll-behavior: contain;
+ scrollbar-width: thin;
+ scrollbar-color: #ffffff20 transparent;
+}
+.dh-messages-inner {
+ max-width: 840px;
+ padding: 16px 35px 25px;
+ margin: auto;
+}
+.dh-chat-intro {
+ text-align: center;
+ margin: 30px 0 45px;
+ color: var(--dh-muted);
+}
+.dh-chat-intro > span {
+ color: var(--dh-accent);
+ font-size: 24px;
+}
+.dh-chat-intro p {
+ font-size: 11px;
+ margin: 10px 0 4px;
+}
+.dh-chat-intro small {
+ font-size: 9px;
+ opacity: 0.7;
+}
+.dh-message {
+ display: flex;
+ gap: 12px;
+ margin: 26px 0;
+ align-items: flex-start;
+}
+.dh-message-avatar {
+ width: 34px;
+ height: 40px;
+ object-fit: cover;
+ border-radius: 8px;
+ flex: none;
+ margin-top: 3px;
+}
+.dh-message-body {
+ max-width: 86%;
+ min-width: 0;
+}
+.dh-message-name {
+ font-size: 10px;
+ color: var(--dh-muted);
+ margin-bottom: 7px;
+ display: flex;
+ align-items: center;
+ gap: 6px;
+}
+.dh-bubble {
+ background: color-mix(in srgb, var(--dh-panel) 92%, transparent);
+ border: 1px solid #ffffff0b;
+ padding: 15px 18px;
+ border-radius: 0 14px 14px 14px;
+ box-shadow: 0 4px 16px #0001;
+}
+.dh-message-text {
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ line-height: 1.95;
+ font-size: 14px;
+ color: #e6dfe7;
+}
+.dh-message-user {
+ justify-content: flex-end;
+}
+.dh-message-user .dh-message-name {
+ justify-content: flex-end;
+}
+.dh-message-user .dh-bubble {
+ border-radius: 14px 0 14px 14px;
+ background: color-mix(in srgb, var(--dh-accent) 15%, var(--dh-panel));
+ border-color: color-mix(in srgb, var(--dh-accent) 15%, transparent);
+}
+.dh-message-actions {
+ display: flex;
+ gap: 3px;
+ margin-top: 6px;
+ opacity: 0.6;
+}
+.dh-message:hover .dh-message-actions {
+ opacity: 1;
+}
+.dh-message-actions button {
+ padding: 6px;
+ min-width: 28px;
+ min-height: 28px;
+ border-radius: 5px;
+ display: grid;
+ place-items: center;
+ color: var(--dh-muted);
+}
+.dh-message-actions button:hover,
+.dh-message-actions button.is-active {
+ color: var(--dh-accent);
+ background: #ffffff08;
+}
+.dh-message-user .dh-message-actions {
+ justify-content: flex-end;
+}
+.dh-message-status {
+ font-size: 9px;
+ color: var(--dh-muted);
+}
+.dh-caret {
+ display: inline-block;
+ width: 3px;
+ height: 14px;
+ margin-left: 4px;
+ background: var(--dh-accent);
+ animation: dh-blink 1s infinite;
+ vertical-align: middle;
+}
+@keyframes dh-blink {
+ 50% {
+ opacity: 0;
+ }
+}
+.dh-thinking {
+ display: flex;
+ gap: 5px;
+ min-width: 45px;
+ padding: 6px 0;
+}
+.dh-thinking i {
+ width: 5px;
+ height: 5px;
+ background: var(--dh-accent);
+ border-radius: 50%;
+ animation: dh-think 1.3s infinite;
+}
+.dh-thinking i:nth-child(2) {
+ animation-delay: 0.2s;
+}
+.dh-thinking i:nth-child(3) {
+ animation-delay: 0.4s;
+}
+@keyframes dh-think {
+ 50% {
+ opacity: 0.2;
+ transform: translateY(-3px);
+ }
+}
+.dh-composer-wrap {
+ flex: none;
+ width: 100%;
+ max-width: 840px;
+ margin: auto;
+ padding: 10px 35px max(20px, env(safe-area-inset-bottom));
+ background: linear-gradient(
+ 0deg,
+ var(--dh-bg),
+ color-mix(in srgb, var(--dh-bg) 95%, transparent)
+ );
+ z-index: 1;
+}
+.dh-composer {
+ display: flex;
+ align-items: flex-end;
+ gap: 10px;
+ background: var(--dh-panel);
+ border: 1px solid #ffffff1a;
+ border-radius: 15px;
+ padding: 10px 11px 10px 16px;
+ box-shadow: 0 10px 40px #0003;
+}
+.dh-composer:focus-within {
+ border-color: color-mix(in srgb, var(--dh-accent) 45%, transparent);
+}
+.dh-composer textarea {
+ width: 100%;
+ resize: none;
+ min-height: 36px;
+ max-height: 160px;
+ border: 0;
+ background: none;
+ padding: 7px 0;
+ outline: none !important;
+ line-height: 1.6;
+ font-size: 14px;
+}
+.dh-send {
+ width: 36px;
+ height: 36px;
+ border-radius: 10px;
+ background: var(--dh-accent) !important;
+ color: var(--dh-accent-ink) !important;
+ display: grid;
+ place-items: center;
+ flex: none;
+}
+.dh-composer-hint {
+ font-size: 9px;
+ color: #827887;
+ display: flex;
+ justify-content: space-between;
+ margin: 9px 3px 0;
+}
+.dh-jump {
+ position: absolute;
+ bottom: 126px;
+ right: 32px;
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ border: 1px solid #ffffff22 !important;
+ border-radius: 20px;
+ background: var(--dh-panel) !important;
+ padding: 8px 12px;
+ z-index: 3;
+ font-size: 11px !important;
+ box-shadow: 0 5px 20px #0004;
+}
+@media (min-width: 1500px) {
+ .dh-card-grid {
+ grid-template-columns: repeat(5, minmax(0, 1fr));
+ }
+ .dh-page {
+ padding-left: 60px;
+ padding-right: 60px;
+ }
+ .dh-hero {
+ min-height: 340px;
+ }
+}
+@media (max-width: 1150px) {
+ .dh-sidebar {
+ width: 200px;
+ padding: 28px 15px;
+ }
+ .dh-main {
+ margin-left: 200px;
+ }
+ .dh-page {
+ padding: 30px;
+ }
+ .dh-brand-en {
+ display: none;
+ }
+ .dh-card-grid {
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 14px;
+ }
+ .dh-hero {
+ padding: 28px;
+ min-height: 300px;
+ }
+ .dh-hero h2 {
+ font-size: 27px;
+ }
+ .dh-hero-art {
+ flex-basis: 39%;
+ min-width: 170px;
+ }
+ .dh-hero-art img {
+ height: 75%;
+ top: 18%;
+ }
+ .dh-hero-art img:nth-child(2) {
+ top: 12%;
+ }
+ .dh-library-grid {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
+ .dh-error {
+ left: 220px;
+ }
+ .dh-toast {
+ left: calc(200px + 40%);
+ }
+}
+@media (max-width: 767px) {
+ .dh-app {
+ font-size: 13px;
+ padding-bottom: calc(70px + env(safe-area-inset-bottom));
+ }
+ .dh-sidebar {
+ inset: auto 0 0;
+ width: 100%;
+ height: calc(66px + env(safe-area-inset-bottom));
+ padding: 5px 10px env(safe-area-inset-bottom);
+ border: 0;
+ border-top: 1px solid #ffffff0c;
+ background: color-mix(in srgb, var(--dh-bg) 94%, transparent);
+ backdrop-filter: blur(24px);
+ }
+ .dh-brand,
+ .dh-sidebar-caption,
+ .dh-sidebar-bottom {
+ display: none;
+ }
+ .dh-sidebar nav {
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: 2px;
+ height: 100%;
+ }
+ .dh-sidebar nav button {
+ padding: 7px 3px;
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ border-radius: 10px;
+ font-size: 9px;
+ justify-content: center;
+ position: relative;
+ }
+ .dh-sidebar nav button small {
+ position: absolute;
+ top: 0;
+ right: 18px;
+ font-size: 8px;
+ background: var(--dh-soft);
+ padding: 0 5px;
+ border-radius: 9px;
+ }
+ .dh-sidebar nav button.is-active {
+ background: none;
+ }
+ .dh-sidebar nav button.is-active svg {
+ filter: drop-shadow(
+ 0 0 8px color-mix(in srgb, var(--dh-accent) 45%, transparent)
+ );
+ }
+ .dh-main {
+ margin-left: 0;
+ min-height: calc(100dvh - 70px);
+ }
+ .dh-page {
+ padding: 26px 18px 0;
+ }
+ .dh-page-header {
+ margin-bottom: 22px;
+ }
+ .dh-page-header h1 {
+ font-size: 23px;
+ letter-spacing: -0.5px;
+ }
+ .dh-eyebrow {
+ font-size: 8px;
+ letter-spacing: 1.9px;
+ }
+ .dh-header-orbit {
+ font-size: 25px;
+ }
+ .dh-hero {
+ min-height: 260px;
+ padding: 23px 20px;
+ border-radius: 15px;
+ margin-bottom: 23px;
+ }
+ .dh-hero > div:first-child {
+ position: relative;
+ z-index: 2;
+ max-width: 74%;
+ }
+ .dh-hero h2 {
+ font-size: 25px;
+ line-height: 1.45;
+ }
+ .dh-hero p {
+ font-size: 10px;
+ margin: 10px 0 17px;
+ }
+ .dh-pill {
+ font-size: 8px;
+ padding: 3px 8px;
+ margin-bottom: 12px;
+ }
+ .dh-primary {
+ font-size: 12px !important;
+ padding: 10px 15px;
+ min-height: 40px;
+ }
+ .dh-hero-art {
+ position: absolute;
+ right: -18px;
+ top: 12px;
+ width: 47%;
+ height: 90%;
+ min-width: 150px;
+ opacity: 0.68;
+ mask-image: linear-gradient(to right, transparent, #000 25%);
+ }
+ .dh-hero-art img {
+ height: 78%;
+ width: 66%;
+ top: 14%;
+ }
+ .dh-hero-art img:nth-child(1) {
+ left: 0;
+ transform: rotate(-10deg);
+ opacity: 0.5;
+ }
+ .dh-hero-art img:nth-child(2) {
+ left: 25%;
+ top: 12%;
+ }
+ .dh-hero-art img:nth-child(3) {
+ display: none;
+ }
+ .dh-orbit {
+ font-size: 45px;
+ right: 35px;
+ }
+ .dh-discovery-tools {
+ gap: 9px;
+ margin-bottom: 13px;
+ }
+ .dh-search {
+ padding: 0 10px;
+ border-radius: 9px;
+ }
+ .dh-search input {
+ font-size: 12px;
+ padding: 11px 0;
+ }
+ .dh-favorite-filter {
+ font-size: 0 !important;
+ padding: 11px !important;
+ gap: 0;
+ border-radius: 9px;
+ }
+ .dh-tags {
+ gap: 5px;
+ }
+ .dh-tags button {
+ font-size: 11px;
+ padding: 6px 12px;
+ }
+ .dh-section-heading {
+ margin: 18px 0 15px;
+ }
+ .dh-section-heading h2 {
+ font-size: 16px;
+ }
+ .dh-section-heading > span {
+ font-size: 9px;
+ }
+ .dh-card-grid {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 12px;
+ }
+ .dh-card-content {
+ padding: 12px 11px;
+ }
+ .dh-card h3 {
+ font-size: 16px;
+ }
+ .dh-card-content p {
+ font-size: 10px;
+ line-height: 1.6;
+ }
+ .dh-card-kicker {
+ font-size: 8px;
+ }
+ .dh-card-tags {
+ margin-top: 8px;
+ gap: 4px;
+ }
+ .dh-card-tags span {
+ font-size: 8px;
+ padding: 2px 6px;
+ }
+ .dh-card-favorite {
+ width: 29px;
+ height: 29px;
+ right: 8px;
+ top: 8px;
+ }
+ .dh-library-grid {
+ grid-template-columns: 1fr;
+ gap: 12px;
+ }
+ .dh-library-card {
+ padding: 20px !important;
+ }
+ .dh-library-card p {
+ min-height: 0;
+ }
+ .dh-library-card h3 {
+ margin-top: 16px;
+ }
+ .dh-conversation-list > button {
+ gap: 12px;
+ padding: 13px;
+ }
+ .dh-conversation-list img {
+ width: 48px;
+ height: 58px;
+ }
+ .dh-conversation-list h3 {
+ font-size: 14px;
+ }
+ .dh-conversation-list p {
+ font-size: 11px;
+ }
+ .dh-conversation-list > button > svg {
+ display: none;
+ }
+ .dh-profile-banner {
+ padding-top: 12px;
+ }
+ .dh-profile-stats {
+ gap: 45px;
+ }
+ .dh-overlay {
+ padding: 16px;
+ align-items: center;
+ }
+ .dh-detail {
+ flex-direction: column;
+ max-height: 92dvh;
+ border-radius: 16px;
+ }
+ .dh-detail-cover {
+ width: 100%;
+ height: 245px;
+ min-height: 0;
+ flex: none;
+ position: relative;
+ }
+ .dh-detail-cover img {
+ object-position: center 25%;
+ }
+ .dh-detail-cover:after {
+ content: "";
+ position: absolute;
+ inset: 55% 0 0;
+ background: linear-gradient(transparent, var(--dh-panel));
+ }
+ .dh-detail-body {
+ padding: 20px 23px 25px;
+ }
+ .dh-detail-body h2 {
+ font-size: 27px;
+ }
+ .dh-detail-description {
+ font-size: 12px;
+ margin: 18px 0 !important;
+ }
+ .dh-detail blockquote {
+ font-size: 11px;
+ padding: 14px 16px;
+ }
+ .dh-settings {
+ padding: 22px;
+ max-height: 90dvh;
+ }
+ .dh-toast {
+ left: 50%;
+ bottom: 100px;
+ font-size: 11px;
+ }
+ .dh-error {
+ left: 14px;
+ right: 14px;
+ top: 12px;
+ font-size: 12px;
+ }
+ .dh-in-chat {
+ padding-bottom: 0;
+ }
+ .dh-in-chat .dh-sidebar {
+ display: none;
+ }
+ .dh-chat {
+ position: fixed;
+ inset: 0;
+ width: 100%;
+ height: var(--dh-viewport, 100dvh);
+ z-index: 20;
+ }
+ .dh-chat-header {
+ height: 68px;
+ padding: 0 10px;
+ gap: 8px;
+ }
+ .dh-chat-header > img {
+ width: 34px;
+ height: 40px;
+ border-radius: 8px;
+ }
+ .dh-chat-header h1 {
+ font-size: 14px;
+ }
+ .dh-chat-header small {
+ font-size: 9px;
+ }
+ .dh-chat-header .dh-icon {
+ width: 34px;
+ }
+ .dh-chat-backdrop,
+ .dh-chat:after {
+ top: 68px;
+ }
+ .dh-messages-inner {
+ padding: 10px 15px 20px;
+ }
+ .dh-chat-intro {
+ margin: 23px 0 32px;
+ }
+ .dh-chat-intro p {
+ font-size: 10px;
+ }
+ .dh-chat-intro small {
+ font-size: 8px;
+ }
+ .dh-message {
+ gap: 9px;
+ margin: 22px 0;
+ }
+ .dh-message-avatar {
+ width: 27px;
+ height: 34px;
+ border-radius: 6px;
+ }
+ .dh-message-body {
+ max-width: 86%;
+ }
+ .dh-message-name {
+ font-size: 9px;
+ margin-bottom: 5px;
+ }
+ .dh-bubble {
+ padding: 12px 14px;
+ border-radius: 0 12px 12px 12px;
+ }
+ .dh-message-text {
+ font-size: 13px;
+ line-height: 1.9;
+ }
+ .dh-message-actions {
+ opacity: 0.8;
+ gap: 4px;
+ }
+ .dh-message-actions button {
+ min-width: 30px;
+ min-height: 30px;
+ }
+ .dh-composer-wrap {
+ padding: 8px 13px max(12px, env(safe-area-inset-bottom));
+ }
+ .dh-composer {
+ border-radius: 13px;
+ padding: 8px 9px 8px 13px;
+ }
+ .dh-composer textarea {
+ font-size: 16px;
+ line-height: 1.5;
+ padding: 5px 0;
+ min-height: 34px;
+ }
+ .dh-send {
+ width: 34px;
+ height: 34px;
+ border-radius: 9px;
+ }
+ .dh-composer-hint {
+ font-size: 8px;
+ margin-top: 7px;
+ }
+ .dh-composer-hint > span {
+ display: none;
+ }
+ .dh-jump {
+ bottom: 112px;
+ right: 16px;
+ font-size: 10px !important;
+ }
+ .dh-chat-menu {
+ right: 14px;
+ top: 60px;
+ }
+}
+@media (prefers-reduced-motion: reduce) {
+ .dh-app * {
+ animation: none !important;
+ transition: none !important;
+ scroll-behavior: auto !important;
+ }
+}
+
+body:has(.dh-app) .environment-badge {
+ display: none;
+}
diff --git a/src/components/login-form.tsx b/src/components/login-form.tsx
index 77d8bee..4bda152 100644
--- a/src/components/login-form.tsx
+++ b/src/components/login-form.tsx
@@ -1,9 +1,11 @@
"use client";
+/** 复用原有账号登录,成功后进入数字人空间。 */
import { useRouter } from "next/navigation";
import { Eye, EyeOff, LockKeyhole, Smartphone } from "lucide-react";
import { FormEvent, useState } from "react";
+/** 现有账号的登录表单,不保存明文密码。 */
export function LoginForm() {
const router = useRouter();
const [error, setError] = useState("");
@@ -16,38 +18,45 @@ export function LoginForm() {
setPending(true);
const formData = new FormData(event.currentTarget);
- const response = await fetch("/api/auth/login", {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({
- username: String(formData.get("username") || "").trim(),
- password: String(formData.get("password") || "")
- })
- });
-
- if (!response.ok) {
- const payload = (await response.json().catch(() => null)) as { message?: string } | null;
- setError(payload?.message || "登录失败,请检查手机号和密码");
+ try {
+ const response = await fetch("/api/auth/login", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ username: String(formData.get("username") || "").trim(),
+ password: String(formData.get("password") || ""),
+ }),
+ });
+ if (!response.ok) {
+ const payload = await response.json().catch(() => null);
+ throw new Error(payload?.message || "登录失败,请检查账号和密码");
+ }
+ router.replace("/discover");
+ router.refresh();
+ } catch (error) {
+ setError(
+ error instanceof TypeError
+ ? "网络连接失败,请稍后重试"
+ : error instanceof Error
+ ? error.message
+ : "登录失败,请重试",
+ );
+ } finally {
setPending(false);
- return;
}
-
- router.replace("/dashboard");
- router.refresh();
}
return (
diff --git a/src/lib/backend.ts b/src/lib/backend.ts
index 4d99481..7f02f90 100644
--- a/src/lib/backend.ts
+++ b/src/lib/backend.ts
@@ -1,3 +1,4 @@
+/** 服务端后端访问与会话错误转换,统一保留业务错误文案。 */
import "server-only";
import { redirect } from "next/navigation";
@@ -5,29 +6,42 @@ import { redirect } from "next/navigation";
import { clearSessionToken, getSessionToken } from "@/lib/session";
import type { ApiEnvelope } from "@/lib/types";
+/** 保留后端状态以便 BFF 清理失效会话。 */
export class BackendError extends Error {
constructor(
message: string,
- public status: number
+ public status: number,
) {
super(message);
}
}
+/** 后端根地址仅由服务端环境配置决定。 */
export function getBackendBaseUrl() {
return process.env.ACCESS_MANAGE_API_BASE_URL || "http://localhost:3500/api";
}
function toUrl(path: string) {
- return new URL(path.replace(/^\//, ""), `${getBackendBaseUrl().replace(/\/$/, "")}/`);
+ return new URL(
+ path.replace(/^\//, ""),
+ `${getBackendBaseUrl().replace(/\/$/, "")}/`,
+ );
}
async function parseBackendResponse