Compare commits
34 Commits
main
..
f921204dc8
| Author | SHA1 | Date | |
|---|---|---|---|
| f921204dc8 | |||
| fb8be9c460 | |||
| ae2b58e0b8 | |||
| c45fb9c941 | |||
| 4638c72680 | |||
| 1f11112e04 | |||
| 6a40040573 | |||
| cac56740cc | |||
| f75a9abecc | |||
| d3fe1b21ed | |||
| afc474b0c4 | |||
| a963bec3f3 | |||
| 81079c7364 | |||
| 4079397625 | |||
| 9b2f7fc7cf | |||
| 981eab9dcf | |||
| d0442f5bb9 | |||
| a8ef8222c8 | |||
| 374ab1c606 | |||
| 5adb6eaec3 | |||
| 0f0aebe3a4 | |||
| b1c5610f23 | |||
| 1d045b7770 | |||
| a07ba77c5a | |||
| c4ea05ee0b | |||
| 781a735559 | |||
| b7433acba4 | |||
| 6b0dd6ea67 | |||
| 8415291772 | |||
| f8386d7b02 | |||
| 5fe2e2c75c | |||
| 3e1789e124 | |||
| 3efb2182b2 | |||
| 6953f48344 |
@@ -0,0 +1,21 @@
|
|||||||
|
# role-user Agent Skills
|
||||||
|
|
||||||
|
本目录存放 `role-user` 的项目级 Agent skill。规则参考 SeaCloud 项目的 agent skill 组织方式,并按当前员工端 Next.js、TypeScript、移动端工作台场景保留最小必要规范。
|
||||||
|
|
||||||
|
## 使用入口
|
||||||
|
|
||||||
|
1. 进入仓库后先读 `AGENTS.md` 和 `RTK.md`。
|
||||||
|
2. 创建或修改代码文件时,使用 `header-comment-sync` 保持中文文件头、导出声明和复杂逻辑注释同步。
|
||||||
|
3. 提交或推送代码时,使用 `chinese-commit-message` 生成英文 type 前缀加中文摘要的 commit message。
|
||||||
|
4. 所有 skill 的触达文件补齐规则只处理本次任务相关文件,不要求为了单次任务全仓扫描。
|
||||||
|
|
||||||
|
## 当前项目事实
|
||||||
|
|
||||||
|
- 应用类型:员工端 C 端移动优先工作台。
|
||||||
|
- 技术栈:Next.js App Router、React、TypeScript。
|
||||||
|
- 关键边界:BFF Route Handlers 负责会话与后端转发,前端不持久化 JWT 或明文密码。
|
||||||
|
|
||||||
|
## Skill 索引
|
||||||
|
|
||||||
|
- `header-comment-sync`:中文文件头、导出声明、复杂逻辑和风险边界注释。
|
||||||
|
- `chinese-commit-message`:中文提交信息格式。
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
name: chinese-commit-message
|
||||||
|
description: 在本仓库执行 git commit、整理提交说明或准备推送时使用,保持提交信息使用英文类型前缀加中文描述。
|
||||||
|
---
|
||||||
|
|
||||||
|
# 中文提交信息
|
||||||
|
|
||||||
|
## 何时使用
|
||||||
|
|
||||||
|
- 用户要求提交、推送或整理 commit message。
|
||||||
|
- 你准备执行 `git commit`。
|
||||||
|
- 需要总结当前 diff 的提交说明。
|
||||||
|
|
||||||
|
## 核心要求
|
||||||
|
|
||||||
|
1. 提交信息必须使用英文 type 加中文摘要,例如 `feat: 补齐员工端 agent skill 规范`。
|
||||||
|
2. 常用 type 优先使用 `feat`、`fix`、`refactor`、`docs`、`chore`。
|
||||||
|
3. 不强制 scope;只有模块边界非常清楚时才使用 `feat(auth): ...`。
|
||||||
|
4. 标题部分使用简洁中文,直接说明改动,不写“修改一下”“更新代码”这类空泛描述。
|
||||||
|
5. 非 trivial 改动建议补中文正文,用扁平 bullet 按文件或内容块说明关键动作。
|
||||||
|
6. 正文与标题之间空一行;正文每条 bullet 对应一个独立文件或明确内容块。
|
||||||
|
7. 如果用户指定提交信息,优先尊重用户原意,只做必要格式整理。
|
||||||
|
|
||||||
|
## 触达文件补齐
|
||||||
|
|
||||||
|
- 不要求为了提交信息单独全仓扫描。
|
||||||
|
- 提交前如果 diff 中的触达文件明显违反对应 skill 的触达补齐要求,应先修正当前相关链路,再整理 commit message。
|
||||||
|
- commit 正文应概括本次触达补齐,例如“补齐触达文件注释”“同步 README 目录说明”。
|
||||||
|
|
||||||
|
## 推荐结构
|
||||||
|
|
||||||
|
```text
|
||||||
|
feat: 补齐员工端 agent skill 规范
|
||||||
|
|
||||||
|
- .agents/README.md: 新增项目级 skill 索引和使用入口
|
||||||
|
- .agents/skills: 补充中文提交与注释同步规则
|
||||||
|
- AGENTS.md: 增加本地 skill 入口
|
||||||
|
```
|
||||||
|
|
||||||
|
## 不推荐写法
|
||||||
|
|
||||||
|
- `新增规则`
|
||||||
|
- `feat: add skills`
|
||||||
|
- `fix bug`
|
||||||
|
- `update`
|
||||||
|
- 复杂改动只有标题没有正文。
|
||||||
|
- 正文写成长段流水账或嵌套列表。
|
||||||
|
|
||||||
|
## 落地检查
|
||||||
|
|
||||||
|
- type 是否合理。
|
||||||
|
- 中文摘要是否覆盖主改动。
|
||||||
|
- 是否需要正文。
|
||||||
|
- 正文是否按文件或内容块归纳。
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
---
|
||||||
|
name: header-comment-sync
|
||||||
|
description: 在本仓库创建或修改 ts、tsx、js、jsx、mjs、cjs、vue、astro 文件时使用,保持中文文件头、导出声明、复杂逻辑和风险边界注释准确。
|
||||||
|
---
|
||||||
|
|
||||||
|
# 注释规范与同步
|
||||||
|
|
||||||
|
## 目标
|
||||||
|
|
||||||
|
让下一次进入文件的维护者能快速理解当前职责、关键约束和风险边界。注释解释“为什么”和“边界”,不复述代码表面行为。
|
||||||
|
|
||||||
|
## 适用场景
|
||||||
|
|
||||||
|
- 新增或修改页面、组件、Hook、store、service、utils、类型、配置或脚本文件。
|
||||||
|
- 修改 BFF Route Handler、鉴权、Cookie、权限、后端协议转换、缓存或错误兜底逻辑。
|
||||||
|
- 发现旧注释与当前代码行为不一致。
|
||||||
|
|
||||||
|
## 核心原则
|
||||||
|
|
||||||
|
- 注释使用中文,描述当前事实。
|
||||||
|
- 简单局部变量不强行注释。
|
||||||
|
- 文件头说明文件当前职责,1 到 2 行即可。
|
||||||
|
- 导出的函数、组件、Hook、类型、配置对象、service method 应有用途说明。
|
||||||
|
- 复杂兼容逻辑、后端协议、竞态锁、缓存、权限映射和会话安全边界需要短注释。
|
||||||
|
- TODO/FIXME 必须说明触发条件、剩余动作和可删除条件。
|
||||||
|
|
||||||
|
## 文件头规则
|
||||||
|
|
||||||
|
- 每个适用文件都要有准确文件头。
|
||||||
|
- 如果文件必须以 `"use client"` 或 `"use server"` 开头,文件头注释放在指令之后、导入之前。
|
||||||
|
- Vue 文件不为了补头注释重排模板结构;在 `<script>` 或 `<script setup>` 顶部补当前职责说明。
|
||||||
|
- 文件头不要写“本文件用于...”这类空话,直接说明业务角色。
|
||||||
|
|
||||||
|
```ts
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工端任务详情页,负责加载任务、发起流转动作并展示备注时间线。
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
## JSDoc 与局部注释
|
||||||
|
|
||||||
|
- 导出的函数、类、组件、Hook、类型、常量和配置对象优先使用 JSDoc。
|
||||||
|
- 非导出但复杂的解析、格式化、请求构造、状态派生、回调工厂也要补。
|
||||||
|
- 只在局部逻辑确实有约束时使用行内注释,例如竞态锁、兼容字段、后端协议和临时迁移。
|
||||||
|
- 不要在每一行、每个 JSX 片段、每个短生命周期变量上堆注释。
|
||||||
|
|
||||||
|
## 触达文件补齐
|
||||||
|
|
||||||
|
- 不要求为了注释规范单独全仓扫描。
|
||||||
|
- 只要本次任务修改了适用文件,就顺手补齐明显缺失或过时的文件头、导出声明、共享类型、复杂回调和协议注释。
|
||||||
|
- 大文件可按触达区域优先,但同文件内裸露的顶层导出和共享类型应一起补。
|
||||||
|
- 如果一次补齐整个大文件会明显超出需求范围,至少补齐当前需求链路和顶层声明,并在交付说明里说明剩余范围。
|
||||||
|
|
||||||
|
## 不推荐的写法
|
||||||
|
|
||||||
|
- 注释只写“处理数据”“点击事件”这种无信息内容。
|
||||||
|
- 注释描述旧方案,和当前代码矛盾。
|
||||||
|
- 为每个 JSX 片段、简单赋值、短生命周期变量写注释。
|
||||||
|
- 用英文口号、emoji 或情绪化标记替代项目内中文说明。
|
||||||
|
|
||||||
|
## 落地检查
|
||||||
|
|
||||||
|
- 修改后的文件头是否准确。
|
||||||
|
- 新增/修改的导出声明是否有必要说明。
|
||||||
|
- 复杂逻辑是否解释了约束而不是复述代码。
|
||||||
|
- 旧注释是否仍然可信。
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3501/api
|
||||||
|
ROLE_USER_SESSION_COOKIE=role_user_session_develop
|
||||||
|
APP_ENV=develop
|
||||||
|
APP_ENV_LABEL=测试环境
|
||||||
|
PORT=3211
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
@@ -1,2 +1,6 @@
|
|||||||
ACCESS_MANAGE_API_BASE_URL=http://localhost:3500/api
|
ACCESS_MANAGE_API_BASE_URL=http://localhost:3500/api
|
||||||
ROLE_USER_SESSION_COOKIE=role_user_session
|
ROLE_USER_SESSION_COOKIE=role_user_session_local
|
||||||
|
APP_ENV=local
|
||||||
|
APP_ENV_LABEL=本地环境
|
||||||
|
PORT=3210
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3500/api
|
||||||
|
ROLE_USER_SESSION_COOKIE=role_user_session
|
||||||
|
APP_ENV=production
|
||||||
|
APP_ENV_LABEL=生产环境
|
||||||
|
PORT=3210
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3501/api
|
||||||
|
ROLE_USER_SESSION_COOKIE=role_user_session_develop
|
||||||
|
APP_ENV=develop
|
||||||
|
APP_ENV_LABEL=测试环境
|
||||||
|
PORT=3211
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
@RTK.md
|
||||||
|
|
||||||
|
# role-user Agent 入口
|
||||||
|
|
||||||
|
## 必用 Skill
|
||||||
|
|
||||||
|
- 创建或修改 `ts`、`tsx`、`js`、`jsx`、`mjs`、`cjs`、`vue`、`astro` 文件时,使用 `./.agents/skills/header-comment-sync/SKILL.md`。
|
||||||
|
- 执行 `git commit`、整理提交说明或准备推送时,使用 `./.agents/skills/chinese-commit-message/SKILL.md`。
|
||||||
|
|
||||||
|
## 本地规则
|
||||||
|
|
||||||
|
- 先读 `RTK.md`,再按任务读取 `.agents/README.md` 中匹配的 skill。
|
||||||
|
- skill 的触达文件补齐只处理本次修改相关文件,不为单次任务全仓扫描。
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# role-user
|
# role-user
|
||||||
|
|
||||||
员工端 C 端工作台,基于 `access-manage` 后端和 `role-admin` 管理后台建设。
|
星港 H5/Web 数字人空间,基于现有 `access-manage` 后端和 `role-admin` 管理后台改造。
|
||||||
|
|
||||||
当前已搭建 React + Next.js App Router + TypeScript 前端骨架,采用移动优先、PWA 友好的工作台形态。
|
采用 React + Next.js App Router + TypeScript,移动优先并适配桌面,保留原工作台兼容路由。
|
||||||
|
|
||||||
## 启动
|
## 启动
|
||||||
|
|
||||||
@@ -15,7 +15,8 @@ pnpm dev
|
|||||||
默认访问:
|
默认访问:
|
||||||
|
|
||||||
- 登录页:http://localhost:3210/login
|
- 登录页:http://localhost:3210/login
|
||||||
- 工作台:http://localhost:3210/dashboard
|
- 数字人空间:http://localhost:3210/discover
|
||||||
|
- 原工作台兼容入口:http://localhost:3210/dashboard
|
||||||
- 任务:http://localhost:3210/tasks
|
- 任务:http://localhost:3210/tasks
|
||||||
- 排班:http://localhost:3210/schedule
|
- 排班:http://localhost:3210/schedule
|
||||||
- 公告:http://localhost:3210/announcements
|
- 公告:http://localhost:3210/announcements
|
||||||
@@ -26,10 +27,22 @@ pnpm dev
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
ACCESS_MANAGE_API_BASE_URL=http://localhost:3500/api
|
ACCESS_MANAGE_API_BASE_URL=http://localhost:3500/api
|
||||||
ROLE_USER_SESSION_COOKIE=role_user_session
|
ROLE_USER_SESSION_COOKIE=role_user_session_local
|
||||||
|
APP_ENV=local
|
||||||
|
APP_ENV_LABEL=本地环境
|
||||||
|
PORT=3210
|
||||||
|
HOSTNAME=0.0.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
`ACCESS_MANAGE_API_BASE_URL` 指向 `access-manage` 服务端 API 根路径。员工登录会调用后端 `POST /api/auth/employee/login`,登录成功后只把 JWT 写入 Next.js 服务端 HttpOnly Cookie,不写入 `localStorage`。
|
`ACCESS_MANAGE_API_BASE_URL` 指向 `access-manage` 服务端 API 根路径。数字人登录调用后端 `POST /api/auth/digital/login`,接受现有超级管理员或员工账号,登录成功后只把 JWT 写入 Next.js 服务端 HttpOnly Cookie,不写入 `localStorage`。
|
||||||
|
|
||||||
|
环境标识按 `APP_ENV` 区分:
|
||||||
|
|
||||||
|
- `local`: 本地环境,默认使用 `.env.example` 复制出的 `.env.local`。
|
||||||
|
- `develop`: 测试环境,参考 `.env.develop.example`;`.env.test.example` 保留为兼容入口。
|
||||||
|
- `production`: 生产环境,参考 `.env.production.example`。
|
||||||
|
|
||||||
|
`APP_ENV_LABEL` 可覆盖页面右上角显示文案;未配置时会按 `APP_ENV` 自动显示“本地环境”“测试环境”或“生产环境”。Cookie 只在 `APP_ENV=production` 时设置 `Secure`,避免测试环境 HTTP 访问时登录后被浏览器丢弃 Cookie。
|
||||||
|
|
||||||
## 可用命令
|
## 可用命令
|
||||||
|
|
||||||
@@ -38,6 +51,10 @@ pnpm dev
|
|||||||
pnpm typecheck
|
pnpm typecheck
|
||||||
pnpm lint
|
pnpm lint
|
||||||
pnpm build
|
pnpm build
|
||||||
|
pnpm build:develop
|
||||||
|
pnpm build:prod
|
||||||
|
pnpm start:develop
|
||||||
|
pnpm start:prod
|
||||||
```
|
```
|
||||||
|
|
||||||
## 当前实现范围
|
## 当前实现范围
|
||||||
@@ -83,8 +100,12 @@ pnpm build
|
|||||||
|
|
||||||
## 文档
|
## 文档
|
||||||
|
|
||||||
|
- `.agents/README.md`: 本项目 Agent skill 索引和使用入口。
|
||||||
|
- `.agents/skills/chinese-commit-message/SKILL.md`: 中文提交信息规范。
|
||||||
|
- `.agents/skills/header-comment-sync/SKILL.md`: 中文文件头和注释同步规范。
|
||||||
- `docs/C_EMPLOYEE_APP_REQUIREMENTS.md`: C 端员工工作台需求文档。
|
- `docs/C_EMPLOYEE_APP_REQUIREMENTS.md`: C 端员工工作台需求文档。
|
||||||
- `docs/FULLSTACK_BACKEND_GAP_ANALYSIS.md`: C 端员工工作台三端缺口与改动范围分析。
|
- `docs/FULLSTACK_BACKEND_GAP_ANALYSIS.md`: C 端员工工作台三端缺口与改动范围分析。
|
||||||
|
- `AGENTS.md`: Codex/Agent 入口规则,转到 `RTK.md` 并登记本地 skill。
|
||||||
- `RTK.md`: 本项目 Codex/Agent 协作规则。
|
- `RTK.md`: 本项目 Codex/Agent 协作规则。
|
||||||
|
|
||||||
## 关联项目
|
## 关联项目
|
||||||
@@ -98,3 +119,34 @@ pnpm build
|
|||||||
- 不把密码、JWT 或权限 token 持久化到前端存储。
|
- 不把密码、JWT 或权限 token 持久化到前端存储。
|
||||||
- 员工端修改密码已通过 BFF 接入后端 `PATCH /api/auth/me/password`。
|
- 员工端修改密码已通过 BFF 接入后端 `PATCH /api/auth/me/password`。
|
||||||
- 公告、任务、排班已按正式后端接口接入列表、筛选、详情和员工端操作;后端临时不可用时页面保留业务空态。
|
- 公告、任务、排班已按正式后端接口接入列表、筛选、详情和员工端操作;后端临时不可用时页面保留业务空态。
|
||||||
|
|
||||||
|
## 数字人空间
|
||||||
|
|
||||||
|
- `/discover` 为默认入口,复用原登录账户和 HttpOnly Cookie。
|
||||||
|
- `src/components/digital-home.tsx`、`digital.css`:深色双 UI、移动/桌面适配、探索、流式对话、停止、重生成、分支、固定记忆、世界书与用户身份。
|
||||||
|
- `src/lib/digital.ts`:前台协议、请求和 SSE 解码。
|
||||||
|
- `src/app/api/digital/[...path]/route.ts`:白名单 BFF,只转发前台接口,禁止访问后台实验管理,写入校验同源。
|
||||||
|
- 实验控制仅在 role-admin。前台没有切换实验或分组入口。
|
||||||
|
- `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 尚未出字就停止或失败时,“继续”仍可接续此前已完成的角色内容,输入草稿保持不变。
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3210",
|
"dev": "APP_ENV=local APP_ENV_LABEL=本地环境 ACCESS_MANAGE_API_BASE_URL=http://localhost:3500/api ROLE_USER_SESSION_COOKIE=role_user_session_local next dev -p 3210",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
"build:develop": "APP_ENV=develop APP_ENV_LABEL=测试环境 ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3501/api ROLE_USER_SESSION_COOKIE=role_user_session_develop next build",
|
||||||
|
"build:test": "pnpm build:develop",
|
||||||
|
"build:prod": "APP_ENV=production APP_ENV_LABEL=生产环境 ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3500/api ROLE_USER_SESSION_COOKIE=role_user_session next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
"start:develop": "APP_ENV=develop APP_ENV_LABEL=测试环境 ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3501/api ROLE_USER_SESSION_COOKIE=role_user_session_develop next start -p 3211",
|
||||||
|
"start:prod": "APP_ENV=production APP_ENV_LABEL=生产环境 ACCESS_MANAGE_API_BASE_URL=http://127.0.0.1:3500/api ROLE_USER_SESSION_COOKIE=role_user_session next start -p 3210",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"typecheck": "tsc --noEmit --incremental false"
|
"typecheck": "tsc --noEmit --incremental false"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
packages:
|
||||||
|
- '.'
|
||||||
|
|
||||||
|
allowBuilds:
|
||||||
|
sharp: true
|
||||||
|
unrs-resolver: true
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
{
|
||||||
|
"note": "角色设定由星港项目原创,封面沿用用户授权参考的现有 SeaChat公开角色资源,私人体验。",
|
||||||
|
"female": [
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"id": "ee061032-332b-4f65-b312-b4a488d49ef0",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/dc9c91be-cc40-4426-9733-918d630a6644",
|
||||||
|
"title": "Dahlia-Single mother"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 1,
|
||||||
|
"id": "8683dd96-b3ca-41bb-aa4d-3888fb246db8",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/6a2ade59-d048-45fc-8488-9c6e9da2c54c",
|
||||||
|
"title": "Morgan"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 2,
|
||||||
|
"id": "9a2afe98-884b-45d4-a88f-5b785437b4c2",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/dd157230-e605-4c1b-b091-d4fc59f735be",
|
||||||
|
"title": "Sillia (Arrogant Elf Princess)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 3,
|
||||||
|
"id": "c7147e4c-cb1c-40ca-9791-2ff5c84c3afc",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/aff51642-cbc7-46f0-b483-3a42f6de910f",
|
||||||
|
"title": "Kiara │ Betrayed Childhood Friend"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 4,
|
||||||
|
"id": "c3989993-1cc5-4ed1-9c8a-675f85cc0a1e",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/4608cfea-0df0-4b72-b7f0-54efbfea18d2",
|
||||||
|
"title": "Dragon Princess Kirin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 5,
|
||||||
|
"id": "36cd7214-eb33-4bcd-b6b2-29e0c45df6dd",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/d67b8d7c-e25e-4aa4-b456-41139177e091",
|
||||||
|
"title": "Natalia \"Still Your Sitter\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 6,
|
||||||
|
"id": "2880d71c-4988-497b-874f-0c25569f0bdb",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/6085d595-46f0-4fbe-845a-b23652e007d0",
|
||||||
|
"title": "Roxanne"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 7,
|
||||||
|
"id": "b9a62845-014e-4faa-a96e-f428f1120ec8",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/f3432df4-52fc-423e-a0bf-3c31593766d3",
|
||||||
|
"title": "Selina Ellison"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 8,
|
||||||
|
"id": "9dfbcdd7-d132-41a9-a399-81b4d77d9df5",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/9c6758c6-9aeb-42bc-9c21-de6e65fa68f8",
|
||||||
|
"title": "Orelia"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 9,
|
||||||
|
"id": "35f2df7b-f7f1-4a7b-b048-323bd316e445",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/0b5b615b-2efb-4cec-aa80-369a8bb3bed8",
|
||||||
|
"title": "You are a Rich Girl's Bodyguard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 10,
|
||||||
|
"id": "0084a3eb-203a-4064-8982-4aeecfc05e42",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/568add55-df11-4105-943f-e2edb8be7909",
|
||||||
|
"title": "Grace"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 11,
|
||||||
|
"id": "3424d41f-56c5-4a61-bbd0-ff45d4480822",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/abbf0b7c-9dc8-4e56-8c19-bc0d72f5c795",
|
||||||
|
"title": "The Colonel's Doomed Empire"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 12,
|
||||||
|
"id": "5f9b6411-b487-4f7d-9951-1eba794d4565",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/5638a2cc-0d8c-42d0-b5d0-2b482a605ea8",
|
||||||
|
"title": "Ursula & Fiona"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 13,
|
||||||
|
"id": "9be1233a-30bf-409a-b66e-3d0752b960a5",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/b7480b45-edb5-4a54-8f42-fcad1f854f65",
|
||||||
|
"title": "Ena"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 14,
|
||||||
|
"id": "9aa3b4a8-c065-41a9-b3c7-7eff8dd63101",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/b30edd5d-0b67-402b-bdb1-b4ce4eddb905",
|
||||||
|
"title": "🦝🗑 Luna | The Hungry Raccoon Girl"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 15,
|
||||||
|
"id": "9910bceb-dec2-4cf5-926c-6efd83def7a9",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/78306f70-aa69-4d21-8837-3a7d149be75f",
|
||||||
|
"title": "Lilith \"Sorry... You're Mine Now\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 16,
|
||||||
|
"id": "fbbd76b0-40f9-43e0-9e93-fdd6528eb1a3",
|
||||||
|
"source": "https://resource.seachat.ai/by-id/d6e9bc09-3d31-4899-84e1-ef6d4de1be78",
|
||||||
|
"title": "Mitsuri Kanroji"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"male": [
|
||||||
|
{
|
||||||
|
"id": "c85f0f30-6883-4d48-b858-dd8734677e83",
|
||||||
|
"name": "Simon Riley AKA Ghost"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "7f61d36c-78b7-406b-8147-69df810eb978",
|
||||||
|
"name": "Alistair | Vampire hunter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6bda6248-1cf0-4a5b-9403-8b72019d0bae",
|
||||||
|
"name": "Riot Sorel | Before the Curtains Close"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 266 KiB |
|
After Width: | Height: | Size: 868 KiB |
|
After Width: | Height: | Size: 188 KiB |
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 272 KiB |
|
After Width: | Height: | Size: 121 KiB |
|
After Width: | Height: | Size: 283 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 2.8 MiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 183 KiB |
|
After Width: | Height: | Size: 585 KiB |
|
After Width: | Height: | Size: 101 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 318 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
@@ -1,13 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
<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>
|
||||||
<rect width="512" height="512" rx="96" fill="#ffffff"/>
|
|
||||||
<rect x="32" y="32" width="448" height="448" rx="72" fill="#f4f4f6"/>
|
|
||||||
<path d="M346 90 238 238l5 9 44 58c26-22 18-56 34-58 16-1 56 2 79-49 23-51-30-94-54-108Z" fill="#ffffff"/>
|
|
||||||
<path d="M164 86c31-2 59 12 75 36l70 86c17 22 44 35 74 33 29-2 54-18 68-42l-90 163c-1 3-3 5-5 8l-1 1c-14 22-38 38-66 40-28 2-54-10-71-30l-73-89c-17-24-45-39-76-37-29 2-54 18-68 42l92-166c13-25 39-43 70-45Z" fill="#131313"/>
|
|
||||||
<path d="M346 90 238 238l5 9 44 58c26-22 18-56 34-58 16-1 56 2 79-49 23-51-30-94-54-108Z" fill="url(#shine)"/>
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="shine" x1="441" x2="201" y1="58" y2="236" gradientUnits="userSpaceOnUse">
|
|
||||||
<stop stop-color="#ffffff"/>
|
|
||||||
<stop offset="1" stop-color="#000000"/>
|
|
||||||
</linearGradient>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 868 B After Width: | Height: | Size: 640 B |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><linearGradient id="stellar" x1="12" y1="13" x2="49" y2="49" gradientUnits="userSpaceOnUse"><stop stop-color="#F4D5A3"/><stop offset="1" stop-color="#F5A8D9"/></linearGradient></defs><rect x="2" y="2" width="60" height="60" rx="18" fill="#211628"/><path d="M24 14h16c9 0 15 6 15 15v4c0 9-6 15-15 15H27L14 54l3-13c-4-3-6-7-6-12 0-9 5-15 13-15Z" fill="url(#stellar)"/><path d="M33 20c2.2 6.5 4.5 8.8 11 11-6.5 2.2-8.8 4.5-11 11-2.2-6.5-4.5-8.8-11-11 6.5-2.2 8.8-4.5 11-11Z" fill="#211628"/><circle cx="51" cy="13" r="5" fill="#F7B7DD" stroke="#211628" stroke-width="3"/></svg>
|
||||||
|
After Width: | Height: | Size: 640 B |
@@ -1,38 +1,39 @@
|
|||||||
|
/** 星港登录页,沿用既有账号,无公开注册。 */
|
||||||
|
import Link from "next/link";
|
||||||
import { LoginForm } from "@/components/login-form";
|
import { LoginForm } from "@/components/login-form";
|
||||||
|
import "@/components/digital-login.css";
|
||||||
|
/** 登录前展示独立品牌与简洁表单。 */
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
return (
|
return (
|
||||||
<main className="login-page">
|
<main className="stellar-login">
|
||||||
<section className="login-hero">
|
<section className="stellar-login-story">
|
||||||
<div className="login-brand-line">
|
<Link href="/" className="stellar-login-brand">
|
||||||
<span className="brand-mark" aria-hidden />
|
✦{" "}
|
||||||
<span>Role User</span>
|
<span>
|
||||||
</div>
|
星港 <small>STELLAR</small>
|
||||||
<p className="hero-kicker">Employee Console</p>
|
</span>
|
||||||
<h1>门店工作,清晰处理</h1>
|
</Link>
|
||||||
<p>排班、任务、公告和账号安全集中在同一个移动端工作区。</p>
|
<div>
|
||||||
<div className="login-preview" aria-hidden>
|
<p>YOUR PRIVATE UNIVERSE</p>
|
||||||
<div className="login-preview__top">
|
<h1>
|
||||||
<span />
|
每一段相遇,
|
||||||
<span />
|
<br />
|
||||||
</div>
|
都有下一章。
|
||||||
<div className="login-preview__body">
|
</h1>
|
||||||
<strong>08:30</strong>
|
<span>
|
||||||
<span>早班 · 正常</span>
|
与你心动的角色对话,
|
||||||
</div>
|
<br />
|
||||||
<div className="login-preview__grid">
|
在世界的另一端,写下属于你的故事。
|
||||||
<span />
|
</span>
|
||||||
<span />
|
|
||||||
<span />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<small>虚构相遇,真实灵感。</small>
|
||||||
</section>
|
</section>
|
||||||
<section className="login-panel" aria-label="员工登录">
|
<section className="stellar-login-panel">
|
||||||
<div className="login-panel__header">
|
<span className="stellar-login-star">✧</span>
|
||||||
<h2>员工登录</h2>
|
<h2>欢迎回到星港</h2>
|
||||||
<p>使用手机号和临时密码进入工作台。</p>
|
<p>使用你的现有账号,继续未完的故事。</p>
|
||||||
</div>
|
|
||||||
<LoginForm />
|
<LoginForm />
|
||||||
|
<small>私人数字人空间 · 不开放公开注册</small>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/** 数字人登录 BFF,令牌仅写入 HttpOnly Cookie,不返回浏览器。 */
|
||||||
import { setSessionToken } from "@/lib/session";
|
import { setSessionToken } from "@/lib/session";
|
||||||
import { BackendError, backendRequest } from "@/lib/backend";
|
import { BackendError, backendRequest } from "@/lib/backend";
|
||||||
import type { LoginResponse } from "@/lib/types";
|
import type { LoginResponse } from "@/lib/types";
|
||||||
@@ -5,13 +6,13 @@ import type { LoginResponse } from "@/lib/types";
|
|||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
try {
|
try {
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const result = await backendRequest<LoginResponse>("/auth/employee/login", {
|
const result = await backendRequest<LoginResponse>("/auth/digital/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: body.username,
|
username: body.username,
|
||||||
password: body.password
|
password: body.password,
|
||||||
}),
|
}),
|
||||||
token: ""
|
token: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
await setSessionToken(result.token);
|
await setSessionToken(result.token);
|
||||||
@@ -21,8 +22,8 @@ export async function POST(request: Request) {
|
|||||||
data: {
|
data: {
|
||||||
user: result.user,
|
user: result.user,
|
||||||
tokenType: result.tokenType,
|
tokenType: result.tokenType,
|
||||||
expiresIn: result.expiresIn
|
expiresIn: result.expiresIn,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const status = error instanceof BackendError ? error.status : 500;
|
const status = error instanceof BackendError ? error.status : 500;
|
||||||
|
|||||||
@@ -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));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
/** 数字人 BFF:HttpOnly 会话只在服务端转发,白名单阻止前台访问实验管理。 */
|
||||||
|
import { getBackendBaseUrl } from "@/lib/backend";
|
||||||
|
import { getSessionToken } from "@/lib/session";
|
||||||
|
|
||||||
|
/** 限制 BFF 接收体积,后端校验之前也不会无界缓存请求。 */
|
||||||
|
async function readBody(request: Request) {
|
||||||
|
if (!request.body) return undefined;
|
||||||
|
const reader = request.body.getReader(),
|
||||||
|
decoder = new TextDecoder();
|
||||||
|
let bytes = 0,
|
||||||
|
body = "";
|
||||||
|
try {
|
||||||
|
for (;;) {
|
||||||
|
const { value, done } = await reader.read();
|
||||||
|
if (done) break;
|
||||||
|
bytes += value.byteLength;
|
||||||
|
if (bytes > 65536) {
|
||||||
|
await reader.cancel();
|
||||||
|
throw new RangeError("请求内容过长");
|
||||||
|
}
|
||||||
|
body += decoder.decode(value, { stream: true });
|
||||||
|
}
|
||||||
|
return body + decoder.decode();
|
||||||
|
} finally {
|
||||||
|
reader.releaseLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 私有会话不缓存;取消下游请求会中断上游 SSE。 */
|
||||||
|
async function proxy(
|
||||||
|
request: Request,
|
||||||
|
context: { params: Promise<{ path: string[] }> },
|
||||||
|
) {
|
||||||
|
const { path } = await context.params;
|
||||||
|
const joined = path.join("/");
|
||||||
|
if (
|
||||||
|
!/^(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,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
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") {
|
||||||
|
const origin = request.headers.get("origin");
|
||||||
|
try {
|
||||||
|
if (!origin || new URL(origin).host !== request.headers.get("host"))
|
||||||
|
return Response.json({ message: "请求来源不合法" }, { status: 403 });
|
||||||
|
} catch {
|
||||||
|
return Response.json({ message: "请求来源不合法" }, { status: 403 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const token = await getSessionToken();
|
||||||
|
if (!token) return Response.json({ message: "请先登录" }, { status: 401 });
|
||||||
|
const headers = new Headers({
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${getBackendBaseUrl().replace(/\/$/, "")}/digital/${joined}`,
|
||||||
|
{
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.method === "GET" ? undefined : await readBody(request),
|
||||||
|
cache: "no-store",
|
||||||
|
signal: request.signal,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
headers: {
|
||||||
|
"Content-Type":
|
||||||
|
response.headers.get("content-type") ?? "application/json",
|
||||||
|
"Cache-Control": "no-store, no-transform",
|
||||||
|
"X-Accel-Buffering": "no",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof RangeError)
|
||||||
|
return Response.json({ message: error.message }, { status: 413 });
|
||||||
|
return Response.json(
|
||||||
|
{ message: "连接暂时不可用,请稍后重试" },
|
||||||
|
{ status: 502 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 转发前台读取。 */
|
||||||
|
export const GET = proxy;
|
||||||
|
/** 转发创建与生成。 */
|
||||||
|
export const POST = proxy;
|
||||||
|
/** 转发用户资料保存。 */
|
||||||
|
export const PUT = proxy;
|
||||||
|
/** 转发会话偏好和固定记忆。 */
|
||||||
|
export const PATCH = proxy;
|
||||||
|
/** 转发用户自己的会话删除。 */
|
||||||
|
export const DELETE = proxy;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/** 数字人前台首屏,服务端并行读取私有数据,避免浏览器加载瀑布。 */
|
||||||
|
import { requireBackendData } from "@/lib/backend";
|
||||||
|
import type { Bootstrap, Summary } from "@/lib/digital";
|
||||||
|
import { DigitalHome } from "@/components/digital-home";
|
||||||
|
/** 私有入口,后端鉴权失败时由统一助手返回登录。 */
|
||||||
|
export default async function DiscoverPage() {
|
||||||
|
const [initial, initialSummaries] = await Promise.all([
|
||||||
|
requireBackendData<Bootstrap>("/digital/bootstrap"),
|
||||||
|
requireBackendData<Summary[]>("/digital/conversations"),
|
||||||
|
]);
|
||||||
|
return <DigitalHome initial={initial} initialSummaries={initialSummaries} />;
|
||||||
|
}
|
||||||
@@ -1029,6 +1029,22 @@ textarea:focus-visible {
|
|||||||
color: var(--accent-ink);
|
color: var(--accent-ink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.environment-badge {
|
||||||
|
background: rgba(20, 20, 24, 0.86);
|
||||||
|
border-radius: 999px;
|
||||||
|
box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 750;
|
||||||
|
letter-spacing: 0;
|
||||||
|
line-height: 1;
|
||||||
|
padding: 8px 10px;
|
||||||
|
position: fixed;
|
||||||
|
right: 12px;
|
||||||
|
top: 12px;
|
||||||
|
z-index: 60;
|
||||||
|
}
|
||||||
|
|
||||||
.skeleton {
|
.skeleton {
|
||||||
animation: pulse 1.2s ease-in-out infinite;
|
animation: pulse 1.2s ease-in-out infinite;
|
||||||
background: linear-gradient(90deg, #ececef, #fafafa, #ececef);
|
background: linear-gradient(90deg, #ececef, #fafafa, #ececef);
|
||||||
|
|||||||
@@ -1,33 +1,57 @@
|
|||||||
|
/** 站点元信息与视口配置,保留系统缩放以支持可访问性。 */
|
||||||
import type { Metadata, Viewport } from "next";
|
import type { Metadata, Viewport } from "next";
|
||||||
|
import { connection } from "next/server";
|
||||||
|
|
||||||
|
import { getAppEnvLabel } from "@/lib/environment";
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
|
/** 星港品牌与安装元数据。 */
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "员工工作台",
|
title: "星港 · 数字人空间",
|
||||||
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,
|
||||||
title: "员工工作台",
|
title: "星港 · 数字人空间",
|
||||||
statusBarStyle: "default"
|
statusBarStyle: "default",
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** 允许缩放并覆盖安全区,由页面布局补齐系统边距。 */
|
||||||
export const viewport: Viewport = {
|
export const viewport: Viewport = {
|
||||||
width: "device-width",
|
width: "device-width",
|
||||||
initialScale: 1,
|
initialScale: 1,
|
||||||
maximumScale: 1,
|
viewportFit: "cover",
|
||||||
themeColor: "#ffffff"
|
|
||||||
|
themeColor: "#101010",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
/** 全站根布局,私有数字人页面自行负责业务鉴权。 */
|
||||||
|
export default async function RootLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{ children: React.ReactNode }>) {
|
||||||
|
await connection();
|
||||||
|
|
||||||
|
const environmentLabel = getAppEnvLabel();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<body>{children}</body>
|
<body>
|
||||||
|
<div
|
||||||
|
className="environment-badge"
|
||||||
|
aria-label={`当前环境:${environmentLabel}`}
|
||||||
|
>
|
||||||
|
{environmentLabel}
|
||||||
|
</div>
|
||||||
|
{children}
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
|
/** 数字人空间 PWA 元数据,保留原有安装机制。 */
|
||||||
import type { MetadataRoute } from "next";
|
import type { MetadataRoute } from "next";
|
||||||
|
|
||||||
export default function manifest(): MetadataRoute.Manifest {
|
export default function manifest(): MetadataRoute.Manifest {
|
||||||
return {
|
return {
|
||||||
name: "role-user 员工工作台",
|
name: "星港 · 数字人空间",
|
||||||
short_name: "员工工作台",
|
short_name: "星港",
|
||||||
description: "门店员工任务、公告、排班和个人中心",
|
description: "你的私人数字人空间",
|
||||||
start_url: "/dashboard",
|
start_url: "/discover",
|
||||||
scope: "/",
|
scope: "/",
|
||||||
display: "standalone",
|
display: "standalone",
|
||||||
background_color: "#f4f4f6",
|
background_color: "#141218",
|
||||||
theme_color: "#ffffff",
|
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",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
/** 默认入口进入数字人空间,登录由目标页统一校验。 */
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
/** 私有站点首页。 */
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
redirect("/dashboard");
|
redirect("/discover");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,9 +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("");
|
||||||
@@ -16,38 +18,45 @@ export function LoginForm() {
|
|||||||
setPending(true);
|
setPending(true);
|
||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
|
try {
|
||||||
const response = await fetch("/api/auth/login", {
|
const response = await fetch("/api/auth/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
username: String(formData.get("username") || "").trim(),
|
username: String(formData.get("username") || "").trim(),
|
||||||
password: String(formData.get("password") || "")
|
password: String(formData.get("password") || ""),
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const payload = (await response.json().catch(() => null)) as { message?: string } | null;
|
const payload = await response.json().catch(() => null);
|
||||||
setError(payload?.message || "登录失败,请检查手机号和密码");
|
throw new Error(payload?.message || "登录失败,请检查账号和密码");
|
||||||
setPending(false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
router.replace("/discover");
|
||||||
router.replace("/dashboard");
|
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
} catch (error) {
|
||||||
|
setError(
|
||||||
|
error instanceof TypeError
|
||||||
|
? "网络连接失败,请稍后重试"
|
||||||
|
: error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: "登录失败,请重试",
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
setPending(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="login-form" onSubmit={handleSubmit}>
|
<form className="login-form" onSubmit={handleSubmit}>
|
||||||
<label>
|
<label>
|
||||||
<span>手机号</span>
|
<span>登录账号</span>
|
||||||
<div className="input-wrap">
|
<div className="input-wrap">
|
||||||
<Smartphone aria-hidden size={18} />
|
<Smartphone aria-hidden size={18} />
|
||||||
<input
|
<input
|
||||||
autoComplete="username"
|
autoComplete="username"
|
||||||
defaultValue="13211111111"
|
inputMode="text"
|
||||||
inputMode="tel"
|
|
||||||
name="username"
|
name="username"
|
||||||
placeholder="请输入员工手机号"
|
placeholder="请输入账号"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -58,7 +67,6 @@ export function LoginForm() {
|
|||||||
<LockKeyhole aria-hidden size={18} />
|
<LockKeyhole aria-hidden size={18} />
|
||||||
<input
|
<input
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
defaultValue="pw111111"
|
|
||||||
name="password"
|
name="password"
|
||||||
placeholder="请输入登录密码"
|
placeholder="请输入登录密码"
|
||||||
required
|
required
|
||||||
@@ -70,7 +78,11 @@ export function LoginForm() {
|
|||||||
onClick={() => setPasswordVisible((visible) => !visible)}
|
onClick={() => setPasswordVisible((visible) => !visible)}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
{passwordVisible ? <EyeOff aria-hidden size={18} /> : <Eye aria-hidden size={18} />}
|
{passwordVisible ? (
|
||||||
|
<EyeOff aria-hidden size={18} />
|
||||||
|
) : (
|
||||||
|
<Eye aria-hidden size={18} />
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -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 } });
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/** 服务端后端访问与会话错误转换,统一保留业务错误文案。 */
|
||||||
import "server-only";
|
import "server-only";
|
||||||
|
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
@@ -5,29 +6,42 @@ import { redirect } from "next/navigation";
|
|||||||
import { clearSessionToken, getSessionToken } from "@/lib/session";
|
import { clearSessionToken, getSessionToken } from "@/lib/session";
|
||||||
import type { ApiEnvelope } from "@/lib/types";
|
import type { ApiEnvelope } from "@/lib/types";
|
||||||
|
|
||||||
|
/** 保留后端状态以便 BFF 清理失效会话。 */
|
||||||
export class BackendError extends Error {
|
export class BackendError extends Error {
|
||||||
constructor(
|
constructor(
|
||||||
message: string,
|
message: string,
|
||||||
public status: number
|
public status: number,
|
||||||
) {
|
) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 后端根地址仅由服务端环境配置决定。 */
|
||||||
export function getBackendBaseUrl() {
|
export function getBackendBaseUrl() {
|
||||||
return process.env.ACCESS_MANAGE_API_BASE_URL || "http://localhost:3500/api";
|
return process.env.ACCESS_MANAGE_API_BASE_URL || "http://localhost:3500/api";
|
||||||
}
|
}
|
||||||
|
|
||||||
function toUrl(path: string) {
|
function toUrl(path: string) {
|
||||||
return new URL(path.replace(/^\//, ""), `${getBackendBaseUrl().replace(/\/$/, "")}/`);
|
return new URL(
|
||||||
|
path.replace(/^\//, ""),
|
||||||
|
`${getBackendBaseUrl().replace(/\/$/, "")}/`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseBackendResponse<T>(response: Response): Promise<T> {
|
async function parseBackendResponse<T>(response: Response): Promise<T> {
|
||||||
const contentType = response.headers.get("content-type") || "";
|
const contentType = response.headers.get("content-type") || "";
|
||||||
const payload = contentType.includes("application/json") ? await response.json() : null;
|
const payload = contentType.includes("application/json")
|
||||||
|
? await response.json()
|
||||||
|
: null;
|
||||||
|
|
||||||
if (!response.ok || payload?.success === false) {
|
if (!response.ok || payload?.success === false) {
|
||||||
throw new BackendError(payload?.message || response.statusText || "请求失败", response.status);
|
throw new BackendError(
|
||||||
|
payload?.error?.message ||
|
||||||
|
payload?.message ||
|
||||||
|
response.statusText ||
|
||||||
|
"请求失败",
|
||||||
|
response.status,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload && typeof payload === "object" && "data" in payload) {
|
if (payload && typeof payload === "object" && "data" in payload) {
|
||||||
@@ -37,9 +51,10 @@ async function parseBackendResponse<T>(response: Response): Promise<T> {
|
|||||||
return payload as T;
|
return payload as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 为服务端请求附加 HttpOnly 会话并禁止缓存私有数据。 */
|
||||||
export async function backendRequest<T>(
|
export async function backendRequest<T>(
|
||||||
path: string,
|
path: string,
|
||||||
init: RequestInit & { token?: string; allowUnauthorized?: boolean } = {}
|
init: RequestInit & { token?: string; allowUnauthorized?: boolean } = {},
|
||||||
) {
|
) {
|
||||||
const token = init.token ?? (await getSessionToken());
|
const token = init.token ?? (await getSessionToken());
|
||||||
const headers = new Headers(init.headers);
|
const headers = new Headers(init.headers);
|
||||||
@@ -55,12 +70,13 @@ export async function backendRequest<T>(
|
|||||||
const response = await fetch(toUrl(path), {
|
const response = await fetch(toUrl(path), {
|
||||||
...init,
|
...init,
|
||||||
headers,
|
headers,
|
||||||
cache: "no-store"
|
cache: "no-store",
|
||||||
});
|
});
|
||||||
|
|
||||||
return parseBackendResponse<T>(response);
|
return parseBackendResponse<T>(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 页面数据要求登录,失效时通过登出路由清理 Cookie。 */
|
||||||
export async function requireBackendData<T>(path: string) {
|
export async function requireBackendData<T>(path: string) {
|
||||||
try {
|
try {
|
||||||
return await backendRequest<T>(path);
|
return await backendRequest<T>(path);
|
||||||
@@ -73,7 +89,11 @@ export async function requireBackendData<T>(path: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function proxyBackendJson<T>(path: string, init: RequestInit = {}) {
|
/** 包装普通 JSON 业务接口,流式对话使用专用 BFF。 */
|
||||||
|
export async function proxyBackendJson<T>(
|
||||||
|
path: string,
|
||||||
|
init: RequestInit = {},
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
const data = await backendRequest<T>(path, init);
|
const data = await backendRequest<T>(path, init);
|
||||||
return Response.json({ success: true, data } satisfies ApiEnvelope<T>);
|
return Response.json({ success: true, data } satisfies ApiEnvelope<T>);
|
||||||
@@ -82,7 +102,11 @@ export async function proxyBackendJson<T>(path: string, init: RequestInit = {})
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function backendErrorResponse(error: unknown, fallbackMessage = "请求失败") {
|
/** 对浏览器返回统一错误,401 时同步清理 Cookie。 */
|
||||||
|
export async function backendErrorResponse(
|
||||||
|
error: unknown,
|
||||||
|
fallbackMessage = "请求失败",
|
||||||
|
) {
|
||||||
const status = error instanceof BackendError ? error.status : 500;
|
const status = error instanceof BackendError ? error.status : 500;
|
||||||
const message = error instanceof Error ? error.message : fallbackMessage;
|
const message = error instanceof Error ? error.message : fallbackMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/** 数字人客户端协议与事件解码,不包含模型凭据或实验操作。 */
|
||||||
|
/** 前台可见内容摘要,提示词不会下发。 */
|
||||||
|
export type Card = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
kind: "character" | "worldbook" | "preset";
|
||||||
|
version: number;
|
||||||
|
description: string;
|
||||||
|
greeting: string;
|
||||||
|
alternateGreetings: string[];
|
||||||
|
gender: string;
|
||||||
|
age: number;
|
||||||
|
cover: string;
|
||||||
|
tags: string[];
|
||||||
|
source: string;
|
||||||
|
entriesCount: number;
|
||||||
|
};
|
||||||
|
/** 用户自己的身份资料。 */
|
||||||
|
export type Profile = {
|
||||||
|
favorites: string[];
|
||||||
|
persona: string;
|
||||||
|
userName: string;
|
||||||
|
};
|
||||||
|
/** 会话消息拥有持久化 id,避免流式刷新时重复插入。 */
|
||||||
|
export type Message = {
|
||||||
|
id: string;
|
||||||
|
role: "user" | "assistant";
|
||||||
|
content: string;
|
||||||
|
status: string;
|
||||||
|
pinned: boolean;
|
||||||
|
sequenceId?: number;
|
||||||
|
};
|
||||||
|
/** 不含实验配置的会话偏好。 */
|
||||||
|
export type Settings = {
|
||||||
|
persona: string;
|
||||||
|
userName: string;
|
||||||
|
memory: string;
|
||||||
|
presetId?: string;
|
||||||
|
bookIds: string[];
|
||||||
|
};
|
||||||
|
/** 对话详情。 */
|
||||||
|
export type Conversation = {
|
||||||
|
id: string;
|
||||||
|
characterId: string;
|
||||||
|
title: string;
|
||||||
|
settings: Settings;
|
||||||
|
busy: boolean;
|
||||||
|
messages: Message[];
|
||||||
|
};
|
||||||
|
/** 通用请求保留服务端错误文本,401 自动返回登录。 */
|
||||||
|
export async function digital<T>(
|
||||||
|
path: string,
|
||||||
|
method = "GET",
|
||||||
|
body?: unknown,
|
||||||
|
signal?: AbortSignal,
|
||||||
|
): Promise<T> {
|
||||||
|
const response = await fetch(`/api/digital/${path}`, {
|
||||||
|
method,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: body === undefined ? undefined : JSON.stringify(body),
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
if (response.status === 401) {
|
||||||
|
window.location.assign("/login");
|
||||||
|
throw new Error("登录已过期");
|
||||||
|
}
|
||||||
|
if (!response.ok || data.success === false)
|
||||||
|
throw new Error(data.error?.message ?? data.message ?? "请求失败");
|
||||||
|
return data.data as T;
|
||||||
|
}
|
||||||
|
/** 网络分片可跨多个 SSE 事件,最后不完整事件不会被误解析。 */
|
||||||
|
export async function readStream(
|
||||||
|
response: Response,
|
||||||
|
onEvent: (event: string, data: Record<string, unknown>) => void,
|
||||||
|
) {
|
||||||
|
if (!response.ok) {
|
||||||
|
const p = await response.json();
|
||||||
|
throw new Error(p.error?.message ?? p.message ?? "发送失败");
|
||||||
|
}
|
||||||
|
if (!response.body) throw new Error("浏览器不支持流式连接");
|
||||||
|
const reader = response.body.getReader(),
|
||||||
|
decoder = new TextDecoder();
|
||||||
|
let buffer = "";
|
||||||
|
try {
|
||||||
|
for (;;) {
|
||||||
|
const { value, done } = await reader.read();
|
||||||
|
buffer += (
|
||||||
|
done ? decoder.decode() : decoder.decode(value, { stream: true })
|
||||||
|
).replaceAll("\r\n", "\n");
|
||||||
|
let end: number;
|
||||||
|
while ((end = buffer.indexOf("\n\n")) >= 0) {
|
||||||
|
const block = buffer.slice(0, end);
|
||||||
|
buffer = buffer.slice(end + 2);
|
||||||
|
const event = block
|
||||||
|
.split("\n")
|
||||||
|
.find((s) => s.startsWith("event:"))
|
||||||
|
?.slice(6)
|
||||||
|
.trim();
|
||||||
|
const data = block
|
||||||
|
.split("\n")
|
||||||
|
.filter((s) => s.startsWith("data:"))
|
||||||
|
.map((s) => s.slice(5).trim())
|
||||||
|
.join("\n");
|
||||||
|
if (event && data) onEvent(event, JSON.parse(data));
|
||||||
|
}
|
||||||
|
if (done) break;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
reader.releaseLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 会话列表摘要。 */
|
||||||
|
export type Summary = {
|
||||||
|
id: string;
|
||||||
|
characterId: string;
|
||||||
|
title: string;
|
||||||
|
updatedAt: string;
|
||||||
|
};
|
||||||
|
/** 服务端首屏数据,仅包含可公开的内容摘要和当前账号决策。 */
|
||||||
|
export type Bootstrap = {
|
||||||
|
catalog: Card[];
|
||||||
|
profile: Profile;
|
||||||
|
decision: {
|
||||||
|
variant: string | null;
|
||||||
|
value?: unknown;
|
||||||
|
fallbackValue?: unknown;
|
||||||
|
decisionId: string | null;
|
||||||
|
expiresAt: number;
|
||||||
|
fallbackVariant: string | null;
|
||||||
|
};
|
||||||
|
serverNow: number;
|
||||||
|
};
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import "server-only";
|
||||||
|
|
||||||
|
export type AppEnv = "local" | "develop" | "production";
|
||||||
|
|
||||||
|
export function getAppEnv(): AppEnv {
|
||||||
|
const appEnv = process.env.APP_ENV;
|
||||||
|
|
||||||
|
if (appEnv === "production") {
|
||||||
|
return "production";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appEnv === "develop" || appEnv === "test") {
|
||||||
|
return "develop";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appEnv === "local") {
|
||||||
|
return "local";
|
||||||
|
}
|
||||||
|
|
||||||
|
return process.env.NODE_ENV === "production" ? "production" : "local";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAppEnvLabel() {
|
||||||
|
if (process.env.APP_ENV_LABEL) {
|
||||||
|
return process.env.APP_ENV_LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const labels: Record<AppEnv, string> = {
|
||||||
|
local: "本地环境",
|
||||||
|
develop: "测试环境",
|
||||||
|
production: "生产环境"
|
||||||
|
};
|
||||||
|
|
||||||
|
return labels[getAppEnv()];
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ import "server-only";
|
|||||||
|
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
|
import { getAppEnv } from "@/lib/environment";
|
||||||
|
|
||||||
const DEFAULT_COOKIE_NAME = "role_user_session";
|
const DEFAULT_COOKIE_NAME = "role_user_session";
|
||||||
|
|
||||||
export function getSessionCookieName() {
|
export function getSessionCookieName() {
|
||||||
@@ -17,7 +19,7 @@ export async function setSessionToken(token: string) {
|
|||||||
|
|
||||||
cookieStore.set(getSessionCookieName(), token, {
|
cookieStore.set(getSessionCookieName(), token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: process.env.NODE_ENV === "production",
|
secure: getAppEnv() === "production",
|
||||||
sameSite: "lax",
|
sameSite: "lax",
|
||||||
path: "/",
|
path: "/",
|
||||||
maxAge: 60 * 60 * 8
|
maxAge: 60 * 60 * 8
|
||||||
|
|||||||
@@ -1,13 +1,24 @@
|
|||||||
|
/** 私有页面会话路由,默认登录后进入数字人空间。 */
|
||||||
import { NextRequest, NextResponse } from "next/server";
|
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 publicRoutes = ["/", "/login"];
|
||||||
const cookieName = process.env.ROLE_USER_SESSION_COOKIE || "role_user_session";
|
const cookieName = process.env.ROLE_USER_SESSION_COOKIE || "role_user_session";
|
||||||
|
|
||||||
export function proxy(request: NextRequest) {
|
export function proxy(request: NextRequest) {
|
||||||
const path = request.nextUrl.pathname;
|
const path = request.nextUrl.pathname;
|
||||||
const hasSession = Boolean(request.cookies.get(cookieName)?.value);
|
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);
|
const isPublic = publicRoutes.includes(path);
|
||||||
|
|
||||||
if (isProtected && !hasSession) {
|
if (isProtected && !hasSession) {
|
||||||
@@ -15,12 +26,14 @@ export function proxy(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPublic && hasSession) {
|
if (isPublic && hasSession) {
|
||||||
return NextResponse.redirect(new URL("/dashboard", request.url));
|
return NextResponse.redirect(new URL("/discover", request.url));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
matcher: ["/((?!api|_next/static|_next/image|manifest.webmanifest|sw.js|.*\\..*).*)"]
|
matcher: [
|
||||||
|
"/((?!api|_next/static|_next/image|manifest.webmanifest|sw.js|.*\\..*).*)",
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||