Compare commits

...

26 Commits

Author SHA1 Message Date
zhanxi 16e989859c merge(nsfw): 发布登录账号成人内容偏好
合入已验证的 NSFW 账号偏好改动,游客登录限制保持不变。
2026-10-27 12:39:16 +00:00
湛兮 cb5e004eb9 feat(nsfw): 新增账号成人内容偏好并默认开启
- src/lib/digital.ts: 补充账号 NSFW 偏好协议,兼容未返回偏好的旧响应
- src/components/digital-home.tsx: 我的页支持保存开关,收藏更新保留服务端偏好
- src/components/digital.css: 增加开关样式与键盘焦点提示
- README.md: 说明默认值、游客限制与前后端配套发布要求
2026-10-27 20:18:16 +08:00
zhanxi fb46c0fdb5 Merge pull request 'feat(users): 独立 C 端账号并提供聊天记录管理' (#17) from feature/env-pipeline-split into master 2026-10-27 10:56:51 +00:00
湛兮 3530219123 feat(users): 使用独立账号并简化选择样式
- login: 改为独立 C 端账号文案与身份类型
- digital: 世界书和风格改用平面选择列表,保留键盘焦点
- README: 同步独立登录与历史迁移说明
2026-10-27 18:56:24 +08:00
zhanxi fb8be9c460 Merge pull request 'fix(chat): 修复尚未出字就停止后的继续重试' (#15) from feature/env-pipeline-split into master 2026-10-27 10:21:07 +00:00
湛兮 ae2b58e0b8 fix(chat): 恢复提前停止后的继续入口
- 以最近有效台词判断继续能力,停止前未出字时仍可重试
2026-10-27 18:20:49 +08:00
zhanxi 4638c72680 Merge pull request 'feat(chat): 新增继续按钮并修复回复滚动跟随' (#13) from feature/env-pipeline-split into master 2026-10-27 10:15:51 +00:00
湛兮 1f11112e04 feat(chat): 新增继续按钮并修复回复滚动跟随
- 继续生成保留输入草稿,不新增用户气泡,支持重复续写和停止

- 根据用户上翻意图控制跟随,修复结束后离底及思考点与光标同时出现
2026-10-27 18:15:31 +08:00
zhanxi cac56740cc Merge pull request 'fix(auth): 修复会话过期跳转内部地址' (#11) from feature/env-pipeline-split into master 2026-10-27 09:42:24 +00:00
湛兮 f75a9abecc fix(auth): 修复会话过期跳转内部地址
- logout 使用站内相对 Location,避免跳到 0.0.0.0 监听地址

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

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

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

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

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

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

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

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

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

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

- README:补充类型消费者接入路径与后台验收边界
2026-10-27 11:40:22 +08:00
zhanxi 1d045b7770 fix(ui): 发布星港图标更新
已完成双轮review与测试环境验证,沿用现有部署链路。
2026-10-27 02:46:46 +00:00
湛兮 a07ba77c5a fix(ui): 统一星港浏览器和主屏幕图标
更新对话气泡星芒标识,提供SVG、ICO与多尺寸PNG,修复标签页旧图标缓存并同步PWA元数据。
2026-10-27 10:44:45 +08:00
zhanxi c4ea05ee0b feat: 发布星港数字人项目
已完成双轮review与测试环境验证,沿用现有部署链路。
2026-10-27 02:28:19 +00:00
湛兮 781a735559 fix(ci): 补齐pnpm工作区根包声明 2026-10-27 10:26:43 +08:00
21 changed files with 1788 additions and 186 deletions
+35 -2
View File
@@ -34,7 +34,7 @@ PORT=3210
HOSTNAME=0.0.0.0 HOSTNAME=0.0.0.0
``` ```
`ACCESS_MANAGE_API_BASE_URL` 指向 `access-manage` 服务端 API 根路径。数字人登录调用后端 `POST /api/auth/digital/login`,接受现有超级管理员或员工账号,登录成功后只把 JWT 写入 Next.js 服务端 HttpOnly Cookie,不写入 `localStorage`。 `ACCESS_MANAGE_API_BASE_URL` 指向 `access-manage` 服务端 API 根路径。数字人登录调用后端 `POST /api/auth/digital/login`,仅接受后台开通的独立 C 端账号,登录成功后只把 JWT 写入 Next.js 服务端 HttpOnly Cookie,不写入 `localStorage`。
环境标识按 `APP_ENV` 区分: 环境标识按 `APP_ENV` 区分:
@@ -122,9 +122,42 @@ pnpm start:prod
## 数字人空间 ## 数字人空间
- `/discover` 为默认入口,复用原登录账户和 HttpOnly Cookie。 - `/discover` 为默认入口,使用独立 C 端账号和 HttpOnly Cookie。
- `src/components/digital-home.tsx`、`digital.css`:深色双 UI、移动/桌面适配、探索、流式对话、停止、重生成、分支、固定记忆、世界书与用户身份。 - `src/components/digital-home.tsx`、`digital.css`:深色双 UI、移动/桌面适配、探索、流式对话、停止、重生成、分支、固定记忆、世界书与用户身份。
- `src/lib/digital.ts`:前台协议、请求和 SSE 解码。 - `src/lib/digital.ts`:前台协议、请求和 SSE 解码。
- `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 会话与不缓存策略。类型、测试方案和用户分组全部在后台管理;新类型需要应用真实使用返回值并完成后台接入验收后才可启动。
`src/components/conversation-row.tsx` 提供会话列表横滑删除、桌面删除入口与模态确认。灵感回复读取本人会话上下文,选择后只加入草稿,原草稿保留;回车发送覆盖 H5/Web,支持中文输入法、Shift+Enter 与手机换行按钮。
内部滚动区域统一隐藏原生轨道,保留触摸/键盘滚动,设定表单关闭横向溢出。风格控制提示使用只读 `GET /api/digital/conversations/:id/style-policy`,打开设定不会写入实验分组、决策或曝光。
实验决策支持 A~Z 动态组;未入组时组别为 null。界面消费 `decision.value`(`new` / `true` 为新版),组名仅用于归因。决策过期使用服务端的 `fallbackValue`,不将无实验用户伪装成 A 组;旧服务未返回value时保留既有兼容路径。
## 登录跳转回归
- `src/lib/auth-redirect.ts`:登出与会话过期后使用站内相对 `Location`,避免跳到 Next.js 内部监听地址 `0.0.0.0:3210`;仅允许站内返回路径。
- `tests/auth-redirect.test.mjs`:覆盖正式域名/本地地址的登录页跳转、站内参数和外部地址拦截。
- 执行:`node --experimental-strip-types --test tests/auth-redirect.test.mjs`(Node.js 22)。
聊天滚动将“跟随最新”与当前底部距离分开:停在底部时,流式回复、结束后操作栏及软键盘导致的尺寸变化均继续贴底;主动上翻才暂停跟随,点击“回到最新”重新启用。等待首段正文仅显示思考点,收到文字后才显示打字光标,结束时移除生成提示。
聊天输入区“继续”让 NPC 基于上一段内容继续说话,不发送或清空输入框草稿,也不插入用户气泡;可连续点击生成多段,生成时沿用停止按钮。角色尚无可接续内容时按钮不可用。
NPC 尚未出字就停止或失败时,“继续”仍可接续此前已完成的角色内容,输入草稿保持不变。
### 独立 C 端登录
前台通过 `/api/auth/digital/login` 使用独立 C 端账号,由后台「用户管理」开通;不再使用管理员/员工身份。已有数字人业务账号由迁移复制密码哈希并保留会话,之后两套账号密码和状态独立。登录令牌保存在 HttpOnly Cookie,密码重置/账号停用会撤销旧登录状态。
对话设置的世界书与叙事风格使用平面列表;选中只保留轻底色和一个勾选标记,键盘焦点仍显示明确轮廓。
### NSFW 账号偏好
「我的」提供 NSFW 成人内容开关,登录账号未保存偏好时默认开启,已保存的关闭选择继续保留。保存后对已有及新会话的后续回复生效,包括发送、继续、重生成与回复灵感;游客仍须先登录。偏好由 `access-manage` 保存在本人资料中,前台不使用本地存储伪造保存结果。前后端需配套发布。
+6
View File
@@ -0,0 +1,6 @@
packages:
- '.'
allowBuilds:
sharp: true
unrs-resolver: true
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

+1 -1
View File
@@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+1
View File
@@ -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

+3 -3
View File
@@ -1,4 +1,4 @@
/** 星港登录页,沿用既有账号,无公开注册。 */ /** 星港登录页,使用独立用户账号,无公开注册。 */
import Link from "next/link"; import Link from "next/link";
import { LoginForm } from "@/components/login-form"; import { LoginForm } from "@/components/login-form";
import "@/components/digital-login.css"; import "@/components/digital-login.css";
@@ -31,9 +31,9 @@ export default function LoginPage() {
<section className="stellar-login-panel"> <section className="stellar-login-panel">
<span className="stellar-login-star">✧</span> <span className="stellar-login-star">✧</span>
<h2>欢迎回到星港</h2> <h2>欢迎回到星港</h2>
<p>使用你的现有账号,继续未完的故事。</p> <p>使用你的星港账号,继续未完的故事。</p>
<LoginForm /> <LoginForm />
<small>私人数字人空间 · 不开放公开注册</small> <small>账号由管理员开通 · 与后台账号独立</small>
</section> </section>
</main> </main>
); );
+6 -4
View File
@@ -1,15 +1,17 @@
import { NextRequest, NextResponse } from "next/server"; /** 清理会话后返回当前站点,保持反向代理域名与本地访问地址。 */
import { NextRequest } from "next/server";
import { logoutRedirect } from "@/lib/auth-redirect";
import { clearSessionToken } from "@/lib/session"; import { clearSessionToken } from "@/lib/session";
/** 客户端主动退出时仅清理 Cookie,由页面处理导航。 */
export async function POST() { export async function POST() {
await clearSessionToken(); await clearSessionToken();
return Response.json({ success: true, data: null }); return Response.json({ success: true, data: null });
} }
/** 会话过期或链接退出后跳转站内页面,不使用服务端监听地址。 */
export async function GET(request: NextRequest) { export async function GET(request: NextRequest) {
await clearSessionToken(); await clearSessionToken();
const next = request.nextUrl.searchParams.get("next") || "/login"; return logoutRedirect(request.nextUrl.searchParams.get("next"));
return NextResponse.redirect(new URL(next, request.url));
} }
+9 -1
View File
@@ -33,11 +33,19 @@ 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|suggestions|style-policy|messages\/[a-zA-Z0-9_-]+))?)?)$/.test(
joined, joined,
) )
) )
return Response.json({ message: "接口不存在" }, { status: 404 }); return Response.json({ message: "接口不存在" }, { status: 404 });
if (
(joined.startsWith("decisions/") || joined.endsWith("/style-policy")) &&
request.method !== "GET"
)
return Response.json(
{ message: "仅支持读取决策" },
{ status: 405, headers: { Allow: "GET" } },
);
if (request.method !== "GET") { if (request.method !== "GET") {
const origin = request.headers.get("origin"); const origin = request.headers.get("origin");
try { try {
+5 -2
View File
@@ -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,
+3 -1
View File
@@ -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",
}, },
+209
View File
@@ -0,0 +1,209 @@
"use client";
/** 会话列表的水平滑动操作与删除确认;纵向滑动继续交给页面滚动。 */
import { useEffect, useId, useRef, useState, type PointerEvent } from "react";
import { LoaderCircle, Trash2 } from "lucide-react";
import type { Card, Summary } from "@/lib/digital";
/** 一次只展开一条会话;拖动不会触发进入会话,桌面和键盘保留显式删除入口。 */
export function ConversationRow({
summary,
card,
revealed,
disabled,
onReveal,
onOpen,
onDelete,
}: {
summary: Summary;
card?: Card;
revealed: boolean;
disabled: boolean;
onReveal: (id: string | null) => void;
onOpen: () => void;
onDelete: () => void;
}) {
const [drag, setDrag] = useState<number | null>(null);
const gesture = useRef<{
x: number;
y: number;
base: number;
offset: number;
axis: "pending" | "x" | "y";
} | null>(null),
suppressClick = useRef(false);
const distance = 88;
function start(e: PointerEvent<HTMLButtonElement>) {
if (disabled || e.button !== 0) return;
suppressClick.current = false;
gesture.current = {
x: e.clientX,
y: e.clientY,
base: revealed ? -distance : 0,
offset: revealed ? -distance : 0,
axis: "pending",
};
e.currentTarget.setPointerCapture(e.pointerId);
}
function move(e: PointerEvent<HTMLButtonElement>) {
const g = gesture.current;
if (!g) return;
const dx = e.clientX - g.x,
dy = e.clientY - g.y;
if (g.axis === "pending" && Math.max(Math.abs(dx), Math.abs(dy)) > 8) {
g.axis = Math.abs(dx) > Math.abs(dy) * 1.2 ? "x" : "y";
if (g.axis === "x") onReveal(summary.id);
}
if (g.axis !== "x") return;
g.offset = Math.max(-distance, Math.min(0, g.base + dx));
setDrag(g.offset);
}
function finish(e: PointerEvent<HTMLButtonElement>, cancelled = false) {
const g = gesture.current;
if (!g) return;
gesture.current = null;
if (g.axis === "x") {
suppressClick.current = true;
onReveal(
(cancelled ? g.base : g.offset) < -distance / 2 ? summary.id : null,
);
}
setDrag(null);
if (e.currentTarget.hasPointerCapture(e.pointerId))
e.currentTarget.releasePointerCapture(e.pointerId);
}
const exposed = revealed || (drag !== null && drag < 0);
return (
<article className={`dh-conversation-row ${exposed ? "is-revealed" : ""}`}>
<button
className="dh-row-delete-swipe"
aria-label={`删除对话:${summary.title}`}
tabIndex={exposed ? 0 : -1}
aria-hidden={!exposed}
disabled={disabled}
onClick={onDelete}
>
<Trash2 size={18} />
<span>删除</span>
</button>
<button
className={`dh-conversation-open ${drag !== null ? "is-dragging" : ""}`}
style={{
transform: `translateX(${drag ?? (revealed ? -distance : 0)}px)`,
}}
disabled={disabled}
onPointerDown={start}
onPointerMove={move}
onPointerUp={(e) => finish(e)}
onPointerCancel={(e) => finish(e, true)}
onLostPointerCapture={() => {
if (gesture.current) {
gesture.current = null;
setDrag(null);
}
}}
onClick={(e) => {
if (suppressClick.current && e.detail !== 0) {
suppressClick.current = false;
return;
}
if (revealed) {
onReveal(null);
return;
}
onOpen();
}}
>
{/* 封面地址沿用服务端目录,不在小型服务器做图片转换。 */}
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={card?.cover || "/icon.svg"} alt="" draggable={false} />
<div>
<h3>{summary.title}</h3>
<p>{card?.description || "继续这段私人对话"}</p>
</div>
<small>
{new Date(summary.updatedAt).toLocaleDateString("zh-CN", {
month: "short",
day: "numeric",
})}
</small>
</button>
<button
className="dh-row-delete-desktop"
aria-label={`删除对话:${summary.title}`}
disabled={disabled}
onClick={onDelete}
>
<Trash2 size={17} />
</button>
</article>
);
}
/** 原生模态对话框负责焦点约束,删除成功前保留原会话,失败可在原处重试。 */
export function ConversationDeleteDialog({
title,
busy,
error,
onCancel,
onConfirm,
}: {
title: string;
busy: boolean;
error: string;
onCancel: () => void;
onConfirm: () => void;
}) {
const ref = useRef<HTMLDialogElement>(null),
id = useId();
useEffect(() => {
const dialog = ref.current;
dialog?.showModal();
return () => dialog?.close();
}, []);
return (
<dialog
ref={ref}
className="dh-delete-dialog"
role="alertdialog"
aria-labelledby={id}
aria-describedby={`${id}-description`}
onCancel={(e) => {
e.preventDefault();
if (!busy) onCancel();
}}
>
<span className="dh-delete-symbol">
<Trash2 size={24} />
</span>
<h2 id={id}>删除这段对话?</h2>
<p id={`${id}-description`}>
「{title}」的对话记录将被永久删除,无法恢复。
</p>
{error && (
<p className="dh-delete-error" role="alert">
{error}
</p>
)}
<div className="dh-delete-actions">
<button type="button" disabled={busy} onClick={onCancel}>
取消
</button>
<button
type="button"
className="is-danger"
disabled={busy}
onClick={onConfirm}
>
{busy ? (
<>
<LoaderCircle size={16} className="dh-spin" />
正在删除
</>
) : (
"删除对话"
)}
</button>
</div>
</dialog>
);
}
File diff suppressed because it is too large Load Diff
+681 -9
View File
@@ -588,7 +588,7 @@
flex-direction: column; flex-direction: column;
gap: 12px; gap: 12px;
} }
.dh-conversation-list > button { .dh-conversation-list .dh-conversation-open {
border: 1px solid var(--dh-line); border: 1px solid var(--dh-line);
background: var(--dh-panel); background: var(--dh-panel);
border-radius: 14px; border-radius: 14px;
@@ -598,7 +598,7 @@
gap: 16px; gap: 16px;
text-align: left; text-align: left;
} }
.dh-conversation-list > button:hover { .dh-conversation-list .dh-conversation-open:hover {
border-color: #ffffff25; border-color: #ffffff25;
} }
.dh-conversation-list img { .dh-conversation-list img {
@@ -620,7 +620,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
margin-top: 5px; margin-top: 5px;
} }
.dh-conversation-list > button > div { .dh-conversation-list .dh-conversation-open > div {
min-width: 0; min-width: 0;
flex: 1; flex: 1;
} }
@@ -633,6 +633,273 @@
color: var(--dh-accent); color: var(--dh-accent);
flex: none; flex: none;
} }
/* 横滑只移动会话卡片,删除在明确确认后才执行。 */
.dh-conversation-row {
position: relative;
overflow: hidden;
border-radius: 14px;
background: #9a394b;
}
.dh-conversation-list .dh-conversation-open {
position: relative;
z-index: 1;
width: 100%;
touch-action: pan-y;
transition: transform 180ms ease;
user-select: none;
}
.dh-conversation-list .dh-conversation-open.is-dragging {
transition: none;
}
.dh-app .dh-row-delete-swipe {
position: absolute;
inset: 0 0 0 auto;
display: flex;
flex-direction: column;
gap: 5px;
align-items: center;
justify-content: center;
width: 88px;
color: #fff;
background: #9a394b;
visibility: hidden;
}
.dh-conversation-row.is-revealed .dh-row-delete-swipe {
visibility: visible;
}
.dh-conversation-list .dh-row-delete-swipe svg {
color: #fff;
}
.dh-row-delete-swipe span {
font-size: 12px;
}
.dh-row-delete-desktop {
position: absolute;
z-index: 2;
top: 50%;
right: 12px;
display: grid;
place-items: center;
width: 34px;
height: 34px;
transform: translateY(-50%);
border-radius: 9px;
}
.dh-conversation-list .dh-row-delete-desktop svg {
color: var(--dh-muted);
}
.dh-app .dh-row-delete-desktop:hover {
background: #f8717120;
}
.dh-conversation-row.is-revealed .dh-row-delete-desktop {
display: none;
}
.dh-swipe-hint {
display: none;
}
.dh-delete-dialog {
width: min(420px, calc(100% - 32px));
max-height: 90dvh;
padding: 26px;
color: var(--dh-text);
background: var(--dh-panel);
border: 1px solid #ffffff1c;
border-radius: 20px;
}
.dh-delete-dialog::backdrop {
background: #000b;
backdrop-filter: blur(6px);
}
.dh-delete-symbol {
display: grid;
place-items: center;
width: 46px;
height: 46px;
margin-bottom: 18px;
color: #fda4af;
background: #fb718519;
border-radius: 14px;
}
.dh-delete-dialog h2 {
font-size: 21px;
font-weight: 600;
}
.dh-delete-dialog p {
margin-top: 12px;
color: var(--dh-muted);
font-size: 13px;
line-height: 1.8;
overflow-wrap: anywhere;
}
.dh-delete-actions {
display: flex;
gap: 12px;
margin-top: 24px;
}
.dh-app .dh-delete-actions button {
display: flex;
flex: 1;
gap: 7px;
align-items: center;
justify-content: center;
min-height: 44px;
font-size: 13px;
background: var(--dh-soft);
border: 1px solid var(--dh-line);
border-radius: 11px;
}
.dh-app .dh-delete-actions .is-danger {
color: #fff;
background: #a3374c;
border-color: #a3374c;
}
.dh-delete-dialog .dh-delete-error {
color: #fda4af;
}
.dh-compose-tools {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 4px 8px;
}
.dh-compose-actions {
display: flex;
align-items: center;
gap: 14px;
}
.dh-app .dh-compose-tools button {
display: flex;
align-items: center;
gap: 6px;
min-height: 32px;
padding: 0 4px;
color: var(--dh-accent);
font-size: 11px;
}
.dh-app .dh-compose-tools .dh-mobile-linebreak {
display: none;
}
.dh-reply-ideas {
margin: 0 0 12px;
padding: 13px;
background: var(--dh-panel);
border: 1px solid var(--dh-line);
border-radius: 15px;
}
.dh-reply-ideas header {
display: flex;
align-items: center;
justify-content: space-between;
}
.dh-reply-ideas strong {
display: flex;
gap: 7px;
align-items: center;
color: var(--dh-accent);
font-size: 12px;
font-weight: 500;
}
.dh-reply-ideas header .dh-icon {
width: 28px;
height: 28px;
}
.dh-ideas-note {
margin: 2px 0 10px !important;
color: var(--dh-muted);
font-size: 10px;
}
.dh-ideas-list {
display: flex;
flex-direction: column;
gap: 7px;
max-height: 30dvh;
overflow-y: auto;
overscroll-behavior: contain;
}
.dh-app .dh-ideas-list button {
display: flex;
gap: 10px;
align-items: flex-start;
padding: 10px;
text-align: left;
font-size: 12px;
line-height: 1.7;
background: var(--dh-soft);
border: 1px solid transparent;
border-radius: 9px;
}
.dh-app .dh-ideas-list button:hover {
border-color: var(--dh-accent);
}
.dh-ideas-list small {
flex: none;
color: var(--dh-accent);
font-size: 10px;
}
.dh-ideas-loading {
display: flex;
gap: 8px;
align-items: center;
min-height: 58px;
color: var(--dh-muted);
font-size: 12px;
}
.dh-ideas-error {
padding: 12px 0;
color: #fda4af;
font-size: 12px;
}
.dh-app .dh-ideas-refresh {
display: flex;
gap: 6px;
align-items: center;
min-height: 32px;
margin-top: 7px;
color: var(--dh-accent);
font-size: 11px;
}
.dh-spin {
animation: dh-spin 1s linear infinite;
}
@keyframes dh-spin {
to {
transform: rotate(360deg);
}
}
@media (width>600px) {
.dh-conversation-list .dh-conversation-open {
padding-right: 56px !important;
}
}
@media (width<=600px) {
.dh-row-delete-desktop {
display: none;
}
.dh-swipe-hint {
display: block;
margin: -10px 0 14px !important;
color: var(--dh-muted);
font-size: 10px;
}
.dh-delete-dialog {
width: 100%;
max-width: 100%;
margin: auto 0 0;
padding: 24px 22px calc(22px + env(safe-area-inset-bottom));
border-radius: 22px 22px 0 0;
border-bottom: 0;
}
.dh-app .dh-compose-tools .dh-mobile-linebreak {
display: flex;
}
.dh-reply-ideas {
padding: 10px;
}
.dh-ideas-list {
max-height: 28dvh;
}
}
.dh-page-lead { .dh-page-lead {
max-width: 650px; max-width: 650px;
color: var(--dh-muted); color: var(--dh-muted);
@@ -699,7 +966,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;
@@ -707,6 +974,11 @@
color: #d4cbd5; color: #d4cbd5;
font-size: 12px; font-size: 12px;
} }
.dh-settings > label small {
color: var(--dh-muted);
font-size: 11px;
line-height: 1.7;
}
.dh-profile-form textarea, .dh-profile-form textarea,
.dh-settings textarea { .dh-settings textarea {
resize: vertical; resize: vertical;
@@ -718,6 +990,53 @@
line-height: 1.9; line-height: 1.9;
margin: 8px 0 20px !important; margin: 8px 0 20px !important;
} }
.dh-profile-form > .dh-content-preference {
flex-direction: row;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 16px 0;
border-top: 1px solid var(--dh-line);
border-bottom: 1px solid var(--dh-line);
}
.dh-content-preference span {
min-width: 0;
}
.dh-content-preference small {
display: block;
margin-top: 6px;
color: var(--dh-muted);
line-height: 1.7;
}
.dh-content-preference input[type="checkbox"] {
appearance: none;
flex: none;
width: 44px;
height: 26px;
padding: 3px;
border: 1px solid var(--dh-line);
border-radius: 20px;
background: var(--dh-panel);
cursor: pointer;
}
.dh-content-preference input::before {
display: block;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
content: "";
}
.dh-content-preference input:checked {
background: var(--dh-accent);
}
.dh-content-preference input:checked::before {
transform: translateX(18px);
}
.dh-content-preference input:focus-visible {
outline: 2px solid var(--dh-accent);
outline-offset: 3px;
}
.dh-profile-stats { .dh-profile-stats {
display: flex; display: flex;
border-top: 1px solid var(--dh-line); border-top: 1px solid var(--dh-line);
@@ -858,9 +1177,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 +1189,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 +1208,302 @@
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: minmax(0, 1fr);
gap: 0;
}
.dh-style-option {
position: relative;
min-width: 0;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.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;
min-height: 72px;
padding: 14px 10px;
border: 0;
border-bottom: 1px solid var(--dh-line);
border-radius: 0;
background: transparent;
transition:
border-color 160ms,
background 160ms;
}
.dh-style-option:hover .dh-style-card {
background: #ffffff04;
}
.dh-style-option > input:checked + .dh-style-card {
background: color-mix(in srgb, var(--dh-accent) 7%, transparent);
}
.dh-style-option > input:focus-visible + .dh-style-card {
outline: 2px solid var(--dh-accent);
outline-offset: 3px;
}
.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: 0;
}
.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);
background: transparent;
}
@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: 70px;
padding: 14px 10px;
margin: 0;
border: 0;
border-bottom: 1px solid var(--dh-line);
border-radius: 0;
cursor: pointer;
}
.dh-selection-sheet .dh-checkbox.is-selected {
background: color-mix(in srgb, var(--dh-accent) 7%, transparent);
}
.dh-selection-sheet .dh-checkbox:has(input:focus-visible) {
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 +1528,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%;
} }
/* 聊天固定在动态视口内;消息区独立滚动,输入框不会盖住底部消息。 */ /* 聊天固定在动态视口内;消息区独立滚动,输入框不会盖住底部消息。 */
@@ -1010,8 +1637,7 @@
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
overscroll-behavior: contain; overscroll-behavior: contain;
scrollbar-width: thin; scrollbar-width: none;
scrollbar-color: #ffffff20 transparent;
} }
.dh-messages-inner { .dh-messages-inner {
max-width: 840px; max-width: 840px;
@@ -1495,7 +2121,7 @@
.dh-library-card h3 { .dh-library-card h3 {
margin-top: 16px; margin-top: 16px;
} }
.dh-conversation-list > button { .dh-conversation-list .dh-conversation-open {
gap: 12px; gap: 12px;
padding: 13px; padding: 13px;
} }
@@ -1509,7 +2135,7 @@
.dh-conversation-list p { .dh-conversation-list p {
font-size: 11px; font-size: 11px;
} }
.dh-conversation-list > button > svg { .dh-conversation-list .dh-conversation-open > svg {
display: none; display: none;
} }
.dh-profile-banner { .dh-profile-banner {
@@ -1698,3 +2324,49 @@
body:has(.dh-app) .environment-badge { body:has(.dh-app) .environment-badge {
display: none; display: none;
} }
/* 内部区域保留手势和键盘滚动,不显示系统轨道,也不允许设定表单横向漂移。 */
.dh-app,
.dh-app * {
scrollbar-width: none !important;
}
.dh-app::-webkit-scrollbar,
.dh-app *::-webkit-scrollbar {
display: none !important;
width: 0 !important;
height: 0 !important;
}
.dh-settings-body,
.dh-selection-body,
.dh-detail-body,
.dh-ideas-list {
min-width: 0;
max-width: 100%;
overflow-x: hidden;
}
.dh-settings-body {
width: 100%;
}
.dh-settings-body > label,
.dh-settings fieldset,
.dh-selection-sheet fieldset {
min-width: 0;
max-width: 100%;
}
.dh-app textarea {
width: 100%;
max-width: 100%;
overflow-x: hidden;
overflow-wrap: anywhere;
}
/* 世界书与风格统一使用平面列表,选中只保留轻底色和一个勾选标记。 */
.dh-settings .dh-book-picker {
border: 0;
padding: 0;
}
.dh-checkbox input {
flex: none;
width: 16px;
height: 16px;
}
+2 -2
View File
@@ -1,11 +1,11 @@
"use client"; "use client";
/** 复用原有账号登录,成功后进入数字人空间。 */ /** 独立星港用户账号登录,成功后进入数字人空间。 */
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { Eye, EyeOff, LockKeyhole, Smartphone } from "lucide-react"; import { Eye, EyeOff, LockKeyhole, Smartphone } from "lucide-react";
import { FormEvent, useState } from "react"; import { FormEvent, useState } from "react";
/** 现有账号的登录表单,不保存明文密码。 */ /** 独立用户的登录表单,不保存明文密码。 */
export function LoginForm() { export function LoginForm() {
const router = useRouter(); const router = useRouter();
const [error, setError] = useState(""); const [error, setError] = useState("");
+19
View File
@@ -0,0 +1,19 @@
/** 登出后的站内跳转,避免反向代理后的内部监听地址泄漏到浏览器。 */
/** 使用相对 Location 留在当前站点,并拒绝外部地址和 URL 控制字符。 */
export function logoutRedirect(next: string | null) {
let destination = "/login";
if (
next?.startsWith("/") &&
!/^\/[/\\]/.test(next) &&
!/[\\\u0000-\u0020\u007f]/.test(next)
) {
const local = new URL(next, "https://same-origin.invalid");
// 消除点路径后仍须禁止双斜杠,避免 /.//host 被规范化为外站地址。
if (local.origin === "https://same-origin.invalid" && !local.pathname.startsWith("//")) {
destination = local.pathname + local.search + local.hash;
}
}
// Route Handler 可直接返回相对 Location;不使用 request.url(生产中可能是 0.0.0.0)。
return new Response(null, { status: 307, headers: { Location: destination } });
}
+6 -2
View File
@@ -20,6 +20,8 @@ export type Profile = {
favorites: string[]; favorites: string[];
persona: string; persona: string;
userName: string; userName: string;
/** 登录账号的成人内容偏好;旧服务未返回时沿用默认开启。 */
nsfwEnabled?: boolean;
}; };
/** 会话消息拥有持久化 id,避免流式刷新时重复插入。 */ /** 会话消息拥有持久化 id,避免流式刷新时重复插入。 */
export type Message = { export type Message = {
@@ -123,10 +125,12 @@ export type Bootstrap = {
catalog: Card[]; catalog: Card[];
profile: Profile; profile: Profile;
decision: { decision: {
variant: "A" | "B"; variant: string | null;
value?: unknown;
fallbackValue?: unknown;
decisionId: string | null; decisionId: string | null;
expiresAt: number; expiresAt: number;
fallbackVariant: "A" | "B"; fallbackVariant: string | null;
}; };
serverNow: number; serverNow: number;
}; };
+2 -1
View File
@@ -1,4 +1,5 @@
export type AccountType = "SUPER_ADMIN" | "EMPLOYEE"; /** 前台身份与业务协议,数字人账号使用独立 DIGITAL_USER 类型。 */
export type AccountType = "SUPER_ADMIN" | "EMPLOYEE" | "DIGITAL_USER";
export type Role = { export type Role = {
id: number; id: number;
+22
View File
@@ -0,0 +1,22 @@
/** 回归登录过期后的跳转:仅返回站内路径,不把服务监听地址发送给浏览器。 */
import test from 'node:test';
import assert from 'node:assert/strict';
import { logoutRedirect } from '../src/lib/auth-redirect.ts';
test('登录过期后跳回当前站点的登录页,不依赖服务内部地址', () => {
const response = logoutRedirect(null);
assert.equal(response.status, 307);
assert.equal(response.headers.get('location'), '/login');
assert.equal(new URL(response.headers.get('location'), 'https://mrzhan.top/api/auth/logout').href, 'https://mrzhan.top/login');
assert.equal(new URL(response.headers.get('location'), 'http://localhost:3210/api/auth/logout').href, 'http://localhost:3210/login');
});
test('保留站内路径和查询参数', () => {
assert.equal(logoutRedirect('/login?reason=expired').headers.get('location'), '/login?reason=expired');
});
test('拒绝外部链接、协议相对地址及反斜杠变体', () => {
for (const next of ['https://example.com', '//example.com', '/\\example.com', 'javascript:alert(1)', '\n//example.com', '/\n/example.com', '/.//example.com', '/%2e//example.com']) {
assert.equal(logoutRedirect(next).headers.get('location'), '/login', next);
}
});