feat(digital): 打造星港响应式数字人对话空间
新增角色探索、收藏、世界书和身份资料;接入流式打字、停止重生成、固定记忆、会话分支与导出;适配手机和桌面并保持实验只由后台控制。
This commit is contained in:
+17
-4
@@ -1,13 +1,24 @@
|
||||
/** 私有页面会话路由,默认登录后进入数字人空间。 */
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
const protectedRoutes = ["/dashboard", "/tasks", "/schedule", "/announcements", "/store", "/me"];
|
||||
const protectedRoutes = [
|
||||
"/discover",
|
||||
"/dashboard",
|
||||
"/tasks",
|
||||
"/schedule",
|
||||
"/announcements",
|
||||
"/store",
|
||||
"/me",
|
||||
];
|
||||
const publicRoutes = ["/", "/login"];
|
||||
const cookieName = process.env.ROLE_USER_SESSION_COOKIE || "role_user_session";
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const path = request.nextUrl.pathname;
|
||||
const hasSession = Boolean(request.cookies.get(cookieName)?.value);
|
||||
const isProtected = protectedRoutes.some((route) => path === route || path.startsWith(`${route}/`));
|
||||
const isProtected = protectedRoutes.some(
|
||||
(route) => path === route || path.startsWith(`${route}/`),
|
||||
);
|
||||
const isPublic = publicRoutes.includes(path);
|
||||
|
||||
if (isProtected && !hasSession) {
|
||||
@@ -15,12 +26,14 @@ export function proxy(request: NextRequest) {
|
||||
}
|
||||
|
||||
if (isPublic && hasSession) {
|
||||
return NextResponse.redirect(new URL("/dashboard", request.url));
|
||||
return NextResponse.redirect(new URL("/discover", request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/((?!api|_next/static|_next/image|manifest.webmanifest|sw.js|.*\\..*).*)"]
|
||||
matcher: [
|
||||
"/((?!api|_next/static|_next/image|manifest.webmanifest|sw.js|.*\\..*).*)",
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user