feat(navigation): 为数字人前台拆分独立页面路由

- 新增对话列表、聊天、角色详情、书架详情及个人资料独立路由
- 导航使用真实链接,补齐历史返回、登录深链与会话草稿恢复
- 搜索筛选由 URL 驱动,修复浏览器返回时丢失筛选的问题
- 补齐路由校验回归、页面加载与异常入口,并同步 README
This commit is contained in:
湛兮
2026-10-28 17:07:34 +08:00
parent caa54c9b34
commit 4132b80ee0
25 changed files with 801 additions and 192 deletions
+7 -2
View File
@@ -2,6 +2,7 @@
import "server-only";
import { redirect } from "next/navigation";
import { expiredDigitalSessionPath } from "@/lib/digital-routes";
import { clearSessionToken, getSessionToken } from "@/lib/session";
import type { ApiEnvelope } from "@/lib/types";
@@ -77,12 +78,16 @@ export async function backendRequest<T>(
}
/** 页面数据要求登录,失效时通过登出路由清理 Cookie。 */
export async function requireBackendData<T>(path: string) {
export async function requireBackendData<T>(path: string, returnTo?: string) {
try {
return await backendRequest<T>(path);
} catch (error) {
if (error instanceof BackendError && error.status === 401) {
redirect("/api/auth/logout?next=/login");
redirect(
returnTo
? expiredDigitalSessionPath(returnTo)
: "/api/auth/logout?next=/login",
);
}
throw error;