11 Commits

Author SHA1 Message Date
Codex d6f104ee3f fix(private-zone): hide incomplete albums and refresh Maya cover
Docker Image / Build and Push Docker Image (push) Successful in 2m12s
2026-07-23 12:31:44 +08:00
Codex 9ca56c2a04 refactor(private-zone): use canonical product name 2026-07-23 12:31:44 +08:00
Codex 4639acf232 fix(multi-role): enable Maya and Nayeli commercial flows 2026-07-23 12:29:22 +08:00
Codex bdd53a6ea1 docs(private-zoom): remove legacy literal [skip ci] 2026-07-22 19:34:28 +08:00
Codex fb9e30cfd1 docs(private-zoom): record verified rollout [skip ci] 2026-07-22 19:32:16 +08:00
Codex 35939e7681 chore(release): update Private Zoom rollout guide
Docker Image / Build and Push Docker Image (push) Successful in 1m56s
2026-07-22 18:52:48 +08:00
Codex a39d3c25ce chore(release): promote Private Zoom rename to pre
Docker Image / Build and Push Docker Image (push) Successful in 2m34s
2026-07-22 18:31:36 +08:00
Codex a317a46e87 chore(release): promote E2E fixes to pre
Docker Image / Build and Push Docker Image (push) Successful in 2m12s
2026-07-22 16:53:48 +08:00
Codex b531b02a85 chore(release): promote dev fixes to pre
Docker Image / Build and Push Docker Image (push) Successful in 4m0s
2026-07-22 15:40:23 +08:00
Codex adfb230908 chore(release): rename pre-release branch to pre
Docker Image / Build and Push Docker Image (push) Successful in 2m2s
2026-07-22 10:56:59 +08:00
admin 291f268cce chore(favicon): 使用预发布环境的图标
Docker Image / Build and Push Docker Image (push) Successful in 3m47s
2026-07-22 10:06:31 +08:00
121 changed files with 892 additions and 617 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ on:
push:
branches:
- main
- test
- pre
workflow_dispatch:
jobs:
@@ -48,7 +48,7 @@ jobs:
DEPLOY_ENV="prod"
NEXT_ENV_FILE=".env.production"
;;
test)
pre)
DEPLOY_ENV="test"
NEXT_ENV_FILE=".env.local"
;;
+2 -2
View File
@@ -72,12 +72,12 @@ copy_env_by_branch() {
START_PORT=9185
echo "=== env: copied .env.production (main → prod) ===" >> "$LOG_FILE"
;;
test)
pre)
cp -f env-example/.env.local.example .env.local
ENV_FILE=".env.local"
DEPLOY_ENV="test"
START_PORT=9135
echo "=== env: copied .env.local (test → test) ===" >> "$LOG_FILE"
echo "=== env: copied .env.local (pre branch → test runtime) ===" >> "$LOG_FILE"
;;
dev)
cp -f env-example/.env.development.example .env.local
+3 -3
View File
@@ -25,9 +25,9 @@
"./src/data/schemas/payment",
"./src/data/schemas/payment/request",
"./src/data/schemas/payment/response",
"./src/data/schemas/private-zoom",
"./src/data/schemas/private-zoom/request",
"./src/data/schemas/private-zoom/response",
"./src/data/schemas/private-zone",
"./src/data/schemas/private-zone/request",
"./src/data/schemas/private-zone/response",
"./src/data/schemas/user",
"./src/data/storage/app",
"./src/data/storage/auth",
+8 -8
View File
@@ -12,7 +12,7 @@
| 环境 | Git remote | 推送分支 | 宿主机端口 | 容器端口 | 部署脚本 |
| --- | --- | --- | --- | --- | --- |
| 测试环境 | `test` | `test` | `9135` | `3000` | `scripts/deploy/deploy_web_test.sh` |
| 预发环境 | `test` | `pre` | `9135` | `3000` | `scripts/deploy/deploy_web_test.sh` |
| 生产环境 | `production` | `main` | `9185` | `3000` | `scripts/deploy/deploy_web.sh` |
当前 remote 配置示例:
@@ -26,15 +26,15 @@ production root@43.106.13.130:/root/cozsweet-repos/main
## 本地发布流程
测试环境发布流程(脚本迁移前):
预发环境发布流程(脚本迁移前):
1. 进入 test worktree`cozsweet-frontend-nextjs.worktrees/cozsweet-nextjs-test`
1. 进入 pre worktree`cozsweet-frontend-nextjs.worktrees/cozsweet-nextjs-pre`
2. 确认当前分支。
3. 执行 `git rebase dev`,把 `dev` 的最新代码变基到 `test` 分支。
3. 执行 `git rebase dev`,把 `dev` 的最新代码变基到 `pre` 分支。
4. 复制测试环境图标到 `public/`
5. 复制 `env-example/.env.local.example``.env.local`
6. 执行旧版 `scripts/deploy/deploy_web_test.sh`
7. 旧版 `deploy_web_test.sh` 推送 `test` remote 的 `test` 分支。
7. 旧版 `deploy_web_test.sh` 推送 `test` remote 的 `pre` 分支。
8. 推送成功后尝试清除 Cloudflare CDN 缓存。
旧生产环境发布流程(脚本迁移前):
@@ -71,7 +71,7 @@ production root@43.106.13.130:/root/cozsweet-repos/main
| 服务端分支 | 环境变量复制 | 宿主机端口 | 容器名 | 镜像标签 |
| --- | --- | --- | --- | --- |
| `main` | `env-example/.env.production.example``.env.production` | `9185` | `cozsweet-web-prod` | `cozsweet-web:prod-<commit>` |
| `test` | `env-example/.env.local.example``.env.local` | `9135` | `cozsweet-web-test` | `cozsweet-web:test-<commit>` |
| `pre` | `env-example/.env.local.example``.env.local` | `9135` | `cozsweet-web-test` | `cozsweet-web:test-<commit>` |
| `dev` | `env-example/.env.development.example``.env.local` | `9135` | `cozsweet-web-dev` | `cozsweet-web:dev-<commit>` |
| 其他分支 | 使用默认 `.env.local` | `9135` | `cozsweet-web-<branch>` | `cozsweet-web:<branch>-<commit>` |
@@ -264,12 +264,12 @@ ABORTED ... (docker compose up failed)
1. `scripts/deploy/*` 只负责推送代码,不负责本地构建和本地启动。
2. 自动构建和自动重启只发生在服务器端 `post-receive` hook。
3. `main` 分支对应生产环境,`test` 分支对应测试环境。
3. `main` 分支对应生产环境,`pre` 分支对应预发环境。
4. 生产推送当前使用 `git push --force production main`
5. 构建失败时不会重启容器,旧容器继续运行。
6. 服务启动由 Docker Compose 管理,不再使用 `nohup pnpm run start`
7. 服务器需要安装 Docker,并支持 `docker compose` 或旧版 `docker-compose` 命令。
8. 测试环境和生产环境都通过同一套 `post-receive` 容器化流程部署,差异仅由分支、环境变量文件和端口决定。
8. 预发环境和生产环境都通过同一套 `post-receive` 容器化流程部署,差异仅由分支、环境变量文件和端口决定。
## 后续优化建议
+5 -5
View File
@@ -63,7 +63,7 @@ Authorization: Bearer <TOKEN>
2. `isActive=true`
3. `capabilities.chat=true`
服务端目录决定角色是否可聊天及排序;本地目录继续提供 slug、图片、文案和 Tip 能力。`privateZoom` 只有在本地能力和服务端 `privateContent` 同时开启时可用。
服务端目录决定角色是否可聊天及排序;本地目录继续提供 slug、图片、文案和 Tip 能力。`privateZone` 只有在本地能力和服务端 `privateContent` 同时开启时可用。
远端目录返回前,生产环境只使用 Elio 作为临时目录;非生产环境可使用完整本地目录。远端目录加载成功后,以合并结果为准。
@@ -72,7 +72,7 @@ Authorization: Bearer <TOKEN>
```text
/characters/{slug}/splash
/characters/{slug}/chat
/characters/{slug}/private-zoom
/characters/{slug}/private-zone
/characters/{slug}/tip
```
@@ -81,11 +81,11 @@ Authorization: Bearer <TOKEN>
```text
/splash -> /characters/elio/splash
/chat -> /characters/elio/chat
/private-zoom -> /characters/elio/private-zoom
/private-zone -> /characters/elio/private-zone
/tip -> /characters/elio/tip
```
Chat Provider 以 `characterId` 为边界,路由角色变化时创建新的 Actor。Private Zoom 的角色边界由 [Private Zoom 权威协议](./FRONTEND_PRIVATE_ZOOM_API.md) 定义。
Chat Provider 以 `characterId` 为边界,路由角色变化时创建新的 Actor。Private Zone 的角色边界由 [Private Zone 权威协议](./FRONTEND_PRIVATE_ZONE_API.md) 定义。
## 3. Chat HTTP 协议
@@ -308,7 +308,7 @@ conversationKey = {ownerKey}::character:{encodeURIComponent(characterId)}
## 7. 关联业务边界
- Private Zoom 的相册、解锁、Gallery 和支付回跳由 [Private Zoom 权威协议](./FRONTEND_PRIVATE_ZOOM_API.md) 定义。
- Private Zone 的相册、解锁、Gallery 和支付回跳由 [Private Zone 权威协议](./FRONTEND_PRIVATE_ZONE_API.md) 定义。
- Tip 的角色归属、订单轮询和支付回跳由 [Payment 权威协议](./FRONTEND_PAYMENT_API.md) 定义;Chat 只保存解锁所需的原角色回跳地址。
- 登录、支付和解锁回跳保存原角色动态 URL,不能降级为通用 `/chat`
- Analytics 可以使用 `characterId`,聊天正文不属于路由或身份协议的一部分。
+2 -2
View File
@@ -224,7 +224,7 @@ payChannel = ezpay
subscriptionType = vip | topup | tip
giftCategory(仅 Tip,可空)
giftPlanId(仅 Tip,可空)
returnTo = chat | private-zoom | profile(可选)
returnTo = chat | private-zone | profile(可选)
characterSlug(可选)
createdAt
```
@@ -238,7 +238,7 @@ Tip -> /characters/{slug}/tip?category=...&planId=...&payChannel=ezpay&
恢复页面只接受与当前 `paymentType` 相同的待处理订单。带有 `paymentReturn=1` 时派发 `PaymentReturned` 并继续轮询;普通进入支付页时会清理同类型的旧待处理订单。订单进入 paid、failed 或 expired 后清理持久化记录。缺少 Gift 字段的旧记录由最新目录默认选择第一件商品,不再读取 `coffee_type`
无效或未知 `characterSlug` 回退到默认角色 slug。有效角色回跳必须保留原角色,不能统一返回 Elio。`returnTo=private-zoom` 的最终页面行为由 [Private Zoom 权威协议](./FRONTEND_PRIVATE_ZOOM_API.md) 定义。
无效或未知 `characterSlug` 回退到默认角色 slug。有效角色回跳必须保留原角色,不能统一返回 Elio。`returnTo=private-zone` 的最终页面行为由 [Private Zone 权威协议](./FRONTEND_PRIVATE_ZONE_API.md) 定义。
## 8. 成功后的跨域同步
@@ -1,4 +1,4 @@
# CozSweet Private Zoom 权威协议
# CozSweet Private Zone 权威协议
## 1. 状态与范围
@@ -9,11 +9,11 @@
| 边界 | 实现位置 |
| --- | --- |
| API 路径与方法 | `src/data/services/api/api_contract.json` |
| 请求与响应字段 | `src/data/schemas/private-zoom` |
| API 与 Repository | `src/data/services/api/private_zoom_api.ts``src/data/repositories/private_zoom_repository.ts` |
| Private Zoom 状态机 | `src/stores/private-zoom` |
| 页面、Gallery 与导航 | `src/app/private-zoom` |
| 角色 Provider | `src/providers/private-zoom-route-provider.tsx` |
| 请求与响应字段 | `src/data/schemas/private-zone` |
| API 与 Repository | `src/data/services/api/private_zone_api.ts``src/data/repositories/private_zone_repository.ts` |
| Private Zone 状态机 | `src/stores/private-zone` |
| 页面、Gallery 与导航 | `src/app/private-zone` |
| 角色 Provider | `src/providers/private-zone-route-provider.tsx` |
修改上述实现时必须在同一变更中更新本文,不能再新增按相册列表、解锁或 Gallery 拆分的并行协议。
@@ -22,13 +22,13 @@
标准路由:
```text
/characters/{characterSlug}/private-zoom
/characters/{characterSlug}/private-zone
```
旧地址保留为默认角色重定向,并保留查询参数:
```text
/private-zoom -> /characters/elio/private-zoom
/private-zone -> /characters/elio/private-zone
```
URL 使用角色 `slug`,API 和 Actor 使用角色业务 `id`
@@ -39,14 +39,14 @@ URL 使用角色 `slug`API 和 Actor 使用角色业务 `id`
| `maya-tan` | `maya` |
| `nayeli-cervantes` | `nayeli` |
角色必须同时存在于本地目录且 `capabilities.privateZoom=true`。该能力由本地配置和角色目录响应的 `privateContent` 共同决定;能力关闭或 slug 未知时路由返回 Not Found。
角色必须同时存在于本地目录且 `capabilities.privateZone=true`。该能力由本地配置和角色目录响应的 `privateContent` 共同决定;能力关闭或 slug 未知时路由返回 Not Found。
`PrivateZoomProvider``characterId` 为输入和 React key。切换角色会销毁旧 Actor 并创建空状态,不能复用上一角色的相册、余额或解锁请求。
`PrivateZoneProvider``characterId` 为输入和 React key。切换角色会销毁旧 Actor 并创建空状态,不能复用上一角色的相册、余额或解锁请求。
## 3. 相册列表
```http
GET <API_BASE_URL>/api/private-zoom/albums?characterId=maya-tan&limit=20
GET <API_BASE_URL>/api/private-zone/albums?characterId=maya-tan&limit=20
Authorization: Bearer <TOKEN>
```
@@ -55,7 +55,7 @@ Authorization: Bearer <TOKEN>
| `characterId` | 是 | 当前角色业务 ID |
| `limit` | 否 | 当前固定为 20 |
前端当前只加载第一页,不实现 Private Zoom 分页,也不把相册列表写入本地缓存。初始化、手动刷新或登录身份变化时重新请求网络。
前端当前只加载第一页,不实现 Private Zone 分页,也不把相册列表写入本地缓存。初始化、手动刷新或登录身份变化时重新请求网络。
标准响应数据:
@@ -105,7 +105,7 @@ album.locked || !album.unlocked || album.lockDetail.locked
用户点击锁定相册后,前端先展示确认 Dialog。只有待确认 `albumId` 仍存在于当前 Actor 的 `items` 中,才会发起请求。
```http
POST <API_BASE_URL>/api/private-zoom/albums/{albumId}/unlock
POST <API_BASE_URL>/api/private-zone/albums/{albumId}/unlock
Content-Type: application/json
Authorization: Bearer <TOKEN>
```
@@ -177,25 +177,25 @@ Schema 同时允许未知字符串,未知失败原因使用通用错误文案
## 5. 身份与支付导航
Private Zoom 初始化会复用 Guest 登录引导。Auth 尚未初始化或正在加载时不请求列表;`notLoggedIn` 完成 Guest bootstrap 后再进入列表加载。Guest 和正式用户都可以读取后端允许的相册列表。
Private Zone 初始化会复用 Guest 登录引导。Auth 尚未初始化或正在加载时不请求列表;`notLoggedIn` 完成 Guest bootstrap 后再进入列表加载。Guest 和正式用户都可以读取后端允许的相册列表。
积分不足生成 Paywall 请求后:
| 当前身份 | 导航 |
| --- | --- |
| Guest 或 Not Logged In | 打开 Authredirect 为当前角色 Private Zoom |
| 已认证用户 | 打开 Top-up,`returnTo=private-zoom`,保留当前角色来源 |
| Guest 或 Not Logged In | 打开 Authredirect 为当前角色 Private Zone |
| 已认证用户 | 打开 Top-up,`returnTo=private-zone`,保留当前角色来源 |
Paywall 导航发起后立即消费当前请求,避免 React 重渲染重复导航。支付回跳和订单恢复遵循 [Payment 权威协议](./FRONTEND_PAYMENT_API.md)。
解锁成功后 `unlockSuccessNonce` 递增,页面桥接到 `UserFetch`,刷新当前积分和权益。Private Zoom 不自行修改 User Store 余额。
解锁成功后 `unlockSuccessNonce` 递增,页面桥接到 `UserFetch`,刷新当前积分和权益。Private Zone 不自行修改 User Store 余额。
## 6. Gallery URL 协议
解锁相册使用查询参数打开页内 Gallery:
```text
/characters/{slug}/private-zoom?album={albumId}&image={zeroBasedIndex}
/characters/{slug}/private-zone?album={albumId}&image={zeroBasedIndex}
```
解析规则:
@@ -208,7 +208,7 @@ Paywall 导航发起后立即消费当前请求,避免 React 重渲染重复
任一条件不满足时,页面通过 replace 删除 `album``image`,并保留其他查询参数。
页面内点击九宫格缩略图时,Gallery 从该图片的后端数组原始索引打开。关闭操作优先使用浏览器 back;直接刷新或外部分享 Gallery URL 时,关闭操作使用 replace 返回当前角色 Private Zoom
页面内点击九宫格缩略图时,Gallery 从该图片的后端数组原始索引打开。关闭操作优先使用浏览器 back;直接刷新或外部分享 Gallery URL 时,关闭操作使用 replace 返回当前角色 Private Zone
Gallery 只浏览 `locked=false` 且 URL 非空的图片,但 URL 中的 `image` 仍使用原始数组索引。横向拖动时图片跟随指针,达到视口宽度 18%(最低 56px),或达到 0.45px/ms 且至少移动 24px 时切换;首尾越界拖动使用 0.28 阻尼且不循环。松手后使用 240ms 横向吸附动画,键盘方向键和左右按钮复用相同切换逻辑。Escape 关闭;`prefers-reduced-motion` 下取消吸附过渡。
@@ -222,17 +222,17 @@ Gallery 只浏览 `locked=false` 且 URL 非空的图片,但 URL 中的 `image
- 超过 9 张时卡片显示前九张,末格显示 `+N`,Gallery 仍可浏览全部有效图片;
- Gallery 只挂载当前图片和相邻图片,避免多图相册同时解码全部原图;
- `creditBalance` 是当前列表/解锁响应快照,不替代 User Store 权益;
- Private Zoom 不使用 Chat 的 `conversationKey`、消息缓存或媒体缓存;
- Private Zoom 不持有 Payment ActorTop-up 通过路由级导航进入独立 Payment Provider。
- Private Zone 不使用 Chat 的 `conversationKey`、消息缓存或媒体缓存;
- Private Zone 不持有 Payment ActorTop-up 通过路由级导航进入独立 Payment Provider。
## 8. 变更验收
Private Zoom 协议相关变更至少验证:
Private Zone 协议相关变更至少验证:
1. `src/data/schemas/private-zoom/__tests__`
2. `src/data/services/api/__tests__/multi_character_api.test.ts` 中的 Private Zoom 请求;
3. `src/stores/private-zoom/__tests__`
4. `src/app/private-zoom/__tests__` 与组件测试;
1. `src/data/schemas/private-zone/__tests__`
2. `src/data/services/api/__tests__/multi_character_api.test.ts` 中的 Private Zone 请求;
3. `src/stores/private-zone/__tests__`
4. `src/app/private-zone/__tests__` 与组件测试;
5. Elio、Maya、Nayeli 列表互不串联;
6. 登录身份变化会刷新当前角色列表;
7. 成功、余额不足、价格变化、重复解锁、退款失败和 not found 分支;
+7 -7
View File
@@ -8,13 +8,13 @@
| Workflow | 触发时机 | 职责 |
| --- | --- | --- |
| `.gitea/workflows/ci.yml` | `dev``main``test` push / PR | 安装依赖、执行完整质量检查、Python 后端 OpenAPI 差异检查、移动端 smoke,并校验 bundle 预算 |
| `.gitea/workflows/docker-image.yml` | `main``test` push / 手动触发 | 构建 Docker 镜像、推送到镜像仓库,并通过 SSH 部署 |
| `.gitea/workflows/ci.yml` | `dev``main``pre` push / PR | 安装依赖、执行完整质量检查、Python 后端 OpenAPI 差异检查、移动端 smoke,并校验 bundle 预算 |
| `.gitea/workflows/docker-image.yml` | `main``pre` push / 手动触发 | 构建 Docker 镜像、推送到镜像仓库,并通过 SSH 部署 |
这样可以避免所有开发分支都发布镜像,并确保生产镜像通过发布门禁。
`main` 分支发布前会执行 Docker workflow 内的完整质量和 bundle 门禁。`test`
分支快速部署测试环境,会跳过完整质量检查,但仍必须通过 bundle 预算;独立的
`main` 分支发布前会执行 Docker workflow 内的完整质量和 bundle 门禁。`pre`
分支用于快速部署预发环境,会跳过完整质量检查,但仍必须通过 bundle 预算;独立的
`ci.yml` 会同时执行完整检查并提供测试结果。
## 必需 Secrets
@@ -39,7 +39,7 @@ Next.js 的 `NEXT_PUBLIC_*` 会在构建期固化到产物中,因此测试环
## 镜像 Tag 规则
`test` 分支发布:
`pre` 分支发布时继续使用现有 `test-*` 运行镜像标签
```bash
REGISTRY_IMAGE:test-<short_sha>
@@ -81,7 +81,7 @@ volumes:
## 验证方式
推送到 `test` 分支后,检查 Actions 日志中是否出现:
推送到 `pre` 分支后,检查 Actions 日志中是否出现:
```text
Build Docker image
@@ -124,4 +124,4 @@ gitea.banlv-ai.com/admin/cozsweet-web:prod-<short_sha>
- `prod-*` 精确 tag 只保留最近 3 个,`prod-latest` 不计入也不删除。
- 当前刚推送的 `IMAGE_VERSION_TAG` 永远不会被删除。
SSH 部署成功后,服务器本机只保留当前环境正在运行的一个精确版本镜像;测试环境清理旧 `test-*`,生产环境清理旧 `prod-*`
SSH 部署成功后,服务器本机只保留当前环境正在运行的一个精确版本镜像;预发环境清理旧 `test-*`,生产环境清理旧 `prod-*`
+3 -3
View File
@@ -19,7 +19,7 @@ https://<APP_HOST>/external-entry?<参数>
| 参数 | 可选值或格式 | 用途 |
| --- | --- | --- |
| `target` | `chat``tip``private-zoom` | 指定进入的页面;不传或值无效时进入聊天页。 |
| `target` | `chat``tip``private-zone` | 指定进入的页面;不传或值无效时进入聊天页。 |
| `character` | `elio``maya``nayeli` | 指定角色;不传或值无效时使用 Elio。 |
| `psid` | string | 传入 Facebook Page-scoped User ID。 |
| `mode` | `promotion` | 开启聊天促销模式。 |
@@ -78,13 +78,13 @@ https://<APP_HOST>/external-entry?target=tip
私密空间:
```text
https://<APP_HOST>/external-entry?target=private-zoom
https://<APP_HOST>/external-entry?target=private-zone
```
进入 Nayeli 私密空间:
```text
https://<APP_HOST>/external-entry?target=private-zoom&character=nayeli
https://<APP_HOST>/external-entry?target=private-zone&character=nayeli
```
`psid` 可以与任意 `target` 或聊天促销参数组合使用。参数值需要进行 URL 编码,不要在入口中传递登录 Token、Page Access Token 或 App Secret。
+3 -3
View File
@@ -40,8 +40,8 @@
| 角色 | 链接 |
| --- | --- |
| Elio | [打开 Elio 私密空间](http://localhost:3000/external-entry?target=private-zoom&character=elio) |
| Maya | [打开 Maya 私密空间](http://localhost:3000/external-entry?target=private-zoom&character=maya) |
| Nayeli | [打开 Nayeli 私密空间](http://localhost:3000/external-entry?target=private-zoom&character=nayeli) |
| Elio | [打开 Elio 私密空间](http://localhost:3000/external-entry?target=private-zone&character=elio) |
| Maya | [打开 Maya 私密空间](http://localhost:3000/external-entry?target=private-zone&character=maya) |
| Nayeli | [打开 Nayeli 私密空间](http://localhost:3000/external-entry?target=private-zone&character=nayeli) |
如需为其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`。对于不带查询参数的默认入口,请改为追加 `?psid=27511427698460020`
+6 -6
View File
@@ -18,9 +18,9 @@
| 咖啡打赏 | [打开咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip) |
| Maya 咖啡打赏 | [打开 Maya 咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip&character=maya) |
| Nayeli 咖啡打赏 | [打开 Nayeli 咖啡打赏](https://frontend-test.banlv-ai.com/external-entry?target=tip&character=nayeli) |
| 私密空间 | [打开私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zoom) |
| Maya 私密空间 | [打开 Maya 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zoom&character=maya) |
| Nayeli 私密空间 | [打开 Nayeli 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zoom&character=nayeli) |
| 私密空间 | [打开私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zone) |
| Maya 私密空间 | [打开 Maya 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zone&character=maya) |
| Nayeli 私密空间 | [打开 Nayeli 私密空间](https://frontend-test.banlv-ai.com/external-entry?target=private-zone&character=nayeli) |
## 正式环境
@@ -36,8 +36,8 @@
| 咖啡打赏 | [打开咖啡打赏](https://cozsweet.com/external-entry?target=tip) |
| Maya 咖啡打赏 | [打开 Maya 咖啡打赏](https://cozsweet.com/external-entry?target=tip&character=maya) |
| Nayeli 咖啡打赏 | [打开 Nayeli 咖啡打赏](https://cozsweet.com/external-entry?target=tip&character=nayeli) |
| 私密空间 | [打开私密空间](https://cozsweet.com/external-entry?target=private-zoom) |
| Maya 私密空间 | [打开 Maya 私密空间](https://cozsweet.com/external-entry?target=private-zoom&character=maya) |
| Nayeli 私密空间 | [打开 Nayeli 私密空间](https://cozsweet.com/external-entry?target=private-zoom&character=nayeli) |
| 私密空间 | [打开私密空间](https://cozsweet.com/external-entry?target=private-zone) |
| Maya 私密空间 | [打开 Maya 私密空间](https://cozsweet.com/external-entry?target=private-zone&character=maya) |
| Nayeli 私密空间 | [打开 Nayeli 私密空间](https://cozsweet.com/external-entry?target=private-zone&character=nayeli) |
如需在其他入口携带 PSID,在链接末尾追加 `&psid=27511427698460020`
@@ -1,12 +1,12 @@
# Private Zoom 全链路改名联调说明
# Private Zone 全链路改名联调说明
- 日期:2026-07-22
- 目标环境:本地、`pre`、生产
- 当前状态:已实现待联调
- 当前状态:已验证
## 1. 目标
原功能名称存在拼写错误。本次将前端、unified 后端、Manager、数据库、埋点和文档中的正式命名统一为 `Private Zoom`,并同步切换页面路由、API 路径和公开枚举值。
原功能名称存在拼写错误。本次将前端、unified 后端、Manager、数据库、埋点和文档中的正式命名统一为 `Private Zone`,并同步切换页面路由、API 路径和公开枚举值。
## 2. 环境地址
@@ -19,12 +19,12 @@
前端已完成以下修改:
- 页面路由统一为 `/private-zoom``/characters/{characterSlug}/private-zoom`
- 外部入口参数统一为 `target=private-zoom`
- 支付回跳参数统一为 `returnTo=private-zoom`
- 类型、Repository、API client、XState actor、Provider 和资源目录统一使用 `privateZoom``PrivateZoom``private-zoom``private_zoom`
- 埋点键统一为 `navigation.private_zoom``chat.open_private_zoom_from_avatar` 等新名称。
- 角色能力字段统一为 `capabilities.privateZoom`
- 页面路由统一为 `/private-zone``/characters/{characterSlug}/private-zone`
- 外部入口参数统一为 `target=private-zone`
- 支付回跳参数统一为 `returnTo=private-zone`
- 类型、Repository、API client、XState actor、Provider 和资源目录统一使用 `privateZone``PrivateZone``private-zone``private_zone`
- 埋点键统一为 `navigation.private_zone``chat.open_private_zone_from_avatar` 等新名称。
- 角色能力字段统一为 `capabilities.privateZone`
旧页面和旧查询参数不再作为正式入口保留。发布时必须让前后端属于同一个发布批次。
@@ -34,19 +34,19 @@
| 方法 | 新路径 | 用途 |
| --- | --- | --- |
| `GET` | `/api/private-zoom/albums` | 查询付费图片包 |
| `POST` | `/api/private-zoom/albums/{albumId}/unlock` | 解锁图片包 |
| `GET` | `/api/private-zoom/moments` | 查询朋友圈式内容 |
| `POST` | `/api/private-zoom/moments/{momentId}/unlock` | 解锁单条内容 |
| `GET` | `/api/private-zoom/config` | 查询当前角色和用户解锁配置 |
| `GET` | `/api/private-zoom/diaries` | 查询关系日记 |
| `POST` | `/api/private-zoom/diaries/{diaryId}/seen` | 标记关系日记已读 |
| `POST` | `/api/private-zoom/diaries/{diaryId}/unlock` | 解锁关系日记 |
| `GET` | `/api/private-zone/albums` | 查询付费图片包 |
| `POST` | `/api/private-zone/albums/{albumId}/unlock` | 解锁图片包 |
| `GET` | `/api/private-zone/moments` | 查询朋友圈式内容 |
| `POST` | `/api/private-zone/moments/{momentId}/unlock` | 解锁单条内容 |
| `GET` | `/api/private-zone/config` | 查询当前角色和用户解锁配置 |
| `GET` | `/api/private-zone/diaries` | 查询关系日记 |
| `POST` | `/api/private-zone/diaries/{diaryId}/seen` | 标记关系日记已读 |
| `POST` | `/api/private-zone/diaries/{diaryId}/unlock` | 解锁关系日记 |
### 4.1 图片包列表
```http
GET /api/private-zoom/albums?characterId=elio&limit=20
GET /api/private-zone/albums?characterId=elio&limit=20
Authorization: Bearer <TOKEN>
```
@@ -59,14 +59,14 @@ Authorization: Bearer <TOKEN>
调用示例:
```bash
curl 'https://proapi.banlv-ai.com/api/private-zoom/albums?characterId=elio&limit=20' \
curl 'https://proapi.banlv-ai.com/api/private-zone/albums?characterId=elio&limit=20' \
-H 'Authorization: Bearer <TOKEN>'
```
### 4.2 解锁图片包
```http
POST /api/private-zoom/albums/{albumId}/unlock
POST /api/private-zone/albums/{albumId}/unlock
Authorization: Bearer <TOKEN>
Content-Type: application/json
```
@@ -77,7 +77,7 @@ Content-Type: application/json
| `expectedCost` | body | integer | 否 | 是 | 前端确认价格;与后端价格不一致时拒绝解锁 |
```bash
curl -X POST 'https://proapi.banlv-ai.com/api/private-zoom/albums/<ALBUM_ID>/unlock' \
curl -X POST 'https://proapi.banlv-ai.com/api/private-zone/albums/<ALBUM_ID>/unlock' \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"expectedCost":320}'
@@ -86,8 +86,8 @@ curl -X POST 'https://proapi.banlv-ai.com/api/private-zoom/albums/<ALBUM_ID>/unl
### 4.3 Moments 内容与解锁
```http
GET /api/private-zoom/moments?characterId=elio&limit=20
POST /api/private-zoom/moments/{momentId}/unlock
GET /api/private-zone/moments?characterId=elio&limit=20
POST /api/private-zone/moments/{momentId}/unlock
```
解锁请求体与图片包一致,`expectedCost` 为可选整数。响应中的正式分类值同步改为:
@@ -95,8 +95,8 @@ POST /api/private-zoom/moments/{momentId}/unlock
```json
{
"lockDetail": {
"type": "private_zoom_moment",
"reason": "private_zoom_moment"
"type": "private_zone_moment",
"reason": "private_zone_moment"
}
}
```
@@ -105,24 +105,24 @@ POST /api/private-zoom/moments/{momentId}/unlock
| 使用位置 | 新值 | 类型 |
| --- | --- | --- |
| `/api/chat/unlock-private``lockType` 别名 | `private_zoom` | string enum |
| 日程导入 `contentType` 别名 | `private_zoom` | string enum,归一化为 `paid_content` |
| 外部入口 `target` | `private-zoom` | string enum |
| 支付回跳 `returnTo` | `private-zoom` | string enum |
| 锁定详情分类 | `private_zoom_moment` | string enum |
| `/api/chat/unlock-private``lockType` 别名 | `private_zone` | string enum |
| 日程导入 `contentType` 别名 | `private_zone` | string enum,归一化为 `paid_content` |
| 外部入口 `target` | `private-zone` | string enum |
| 支付回跳 `returnTo` | `private-zone` | string enum |
| 锁定详情分类 | `private_zone_moment` | string enum |
## 6. 数据库迁移
因为 `pre` 与生产当前共用 `https://dbapi.banlv-ai.com`,预发部署前先执行 unified 仓库中的临时桥接脚本:
```text
database/private-zoom-bridge.sql
database/private-zone-bridge.sql
```
桥接脚本会创建新表并在切换窗口内保持新旧解锁写入双向同步。生产前后端全部切换完成后,再执行最终迁移:
```text
database/private-zoom-migration.sql
database/private-zone-migration.sql
```
迁移会在同一事务中完成:
@@ -130,7 +130,7 @@ database/private-zoom-migration.sql
- 将历史解锁表无损重命名;新旧表同时存在时先合并再删除旧表。
- 重命名关联约束、索引、策略和触发器。
- 合并 `users.preferences` 中历史解锁键,防止已解锁内容重新锁定。
- 把 `credit_ledger` 历史分类迁移到 `private_zoom``private_zoom_moment`
- 把 `credit_ledger` 历史分类迁移到 `private_zone``private_zone_moment`
- 定向迁移历史埋点键、页面 URL 和系统媒体路径,不改写用户聊天正文。
- 删除切换窗口使用的双写触发器和函数。
- 支持重复执行。
@@ -140,13 +140,13 @@ database/private-zoom-migration.sql
这是破坏性命名修正,不保留旧 API、旧页面路由或旧公开枚举作为正式兼容层。必须按以下顺序发布:
1. 备份数据库并记录当前 unified、前端和 Manager 版本。
2. 执行 `database/private-zoom-bridge.sql`,确认新旧表双向写入一致。
3. 部署 unified `pre`,验证所有 `/api/private-zoom/*` 接口。
2. 执行 `database/private-zone-bridge.sql`,确认新旧表双向写入一致。
3. 部署 unified `pre`,验证所有 `/api/private-zone/*` 接口。
4. 部署前端 `pre`,验证页面、外部入口、解锁和支付回跳。
5. Manager 更新后验证积分用途显示为新分类。
6. `pre` 验证通过后,先启动新生产后端并临时配置旧 API 到新 API 的 Nginx 转发。
7. 切换生产后端,再部署同批次生产前端;确认新前端只调用 `/api/private-zoom/*`
8. 删除临时 Nginx 转发,执行 `database/private-zoom-migration.sql` 清理旧数据库对象。
7. 切换生产后端,再部署同批次生产前端;确认新前端只调用 `/api/private-zone/*`
8. 删除临时 Nginx 转发,执行 `database/private-zone-migration.sql` 清理旧数据库对象。
## 8. 错误与界面状态
@@ -154,32 +154,35 @@ database/private-zoom-migration.sql
- `403`:游客访问仅注册用户可用的关系日记操作,展示现有注册引导。
- `404`:角色、图片包、内容或日记不存在,展示现有空状态或失效提示。
- `409``expectedCost` 与后端价格不同,刷新列表后重新确认。
- `402` 或业务余额不足错误:进入现有充值流程,并使用 `returnTo=private-zoom` 返回原角色页面。
- `402` 或业务余额不足错误:进入现有充值流程,并使用 `returnTo=private-zone` 返回原角色页面。
- 网络失败:不修改本地解锁状态,保留重试入口。
## 9. 验收用例
1. `/characters/elio/private-zoom`、Maya 和 Nayeli 对应页面均可打开。
2. `GET /api/private-zoom/albums` 返回当前角色内容,角色之间不混用。
1. `/characters/elio/private-zone`、Maya 和 Nayeli 对应页面均可打开。
2. `GET /api/private-zone/albums` 返回当前角色内容,角色之间不混用。
3. 已解锁历史记录在迁移后保持解锁状态,不重复扣积分。
4. 新解锁成功后刷新页面仍为已解锁状态。
5. 积分不足进入充值页后,回跳到原角色 `/private-zoom` 页面。
6. `target=private-zoom&character=nayeli` 进入 Nayeli 对应页面。
5. 积分不足进入充值页后,回跳到原角色 `/private-zone` 页面。
6. `target=private-zone&character=nayeli` 进入 Nayeli 对应页面。
7. Manager 的积分用途不再出现旧分类。
8. 三个仓库执行旧命名残留扫描,结果为 `0`
## 10. 当前测试证据
- unified`316 passed`
- 前端:TypeScript 类型检查通过;Vitest `639 passed`ESLint 通过;契约测试 `4 passed`;生产构建通过并生成三个角色的 `/private-zoom` 页面。
- 前端:TypeScript 类型检查通过;Vitest `639 passed`ESLint 通过;契约测试 `4 passed`;生产构建通过并生成三个角色的 `/private-zone` 页面。
- Manager`75 passed`
- PostgreSQL 16 临时库:升级、重复升级、回滚和再次升级全部通过;历史解锁、偏好键、积分账本、埋点、媒体路径和数据库对象名均通过断言,临时容器已删除。
- `pre`unified `71da49b` 和前端 `35939e7` 已验证;新 API 已注册 `8``/api/private-zone/*` 路径,旧 API 路径数量为 `0`;新页面返回 `200`,旧页面返回 `404`
- 生产:unified 镜像 `ai-boyfriend-unified:prod-20260722-71da49b`(镜像 ID `sha256:755ef5741856d83d7d808e7df8ee259b6fa5fb94fe333b523ee280ed1d5f674b`)和前端镜像 `prod-35939e7` 已健康运行;Manager 当前版本为 `6eea005`
- 生产接口:测试账号调用 `GET https://api.banlv-ai.com/api/private-zone/config?characterId=elio` 返回 `200``success=true`;旧版 API 路径在所有公开 API 入口均返回 `404`
- 生产数据库:最终迁移已执行,旧表、桥接函数、桥接触发器、旧偏好键、旧积分分类和旧埋点值的残留数量均为 `0`
## 11. 回滚影响
最终迁移执行前可直接恢复旧应用,桥接表会保留双向一致的数据。最终迁移执行后,回滚必须同时执行 unified 仓库中的 `database/private-zoom-rollback.sql`。回滚前应停止写入,先保存切换后的新增解锁记录,再执行逆向迁移并恢复旧应用版本。不得只恢复前端或只恢复 unified。
最终迁移执行前可直接恢复旧应用,桥接表会保留双向一致的数据。最终迁移执行后,回滚必须同时执行 unified 仓库中的 `database/private-zone-rollback.sql`。回滚前应停止写入,先保存切换后的新增解锁记录,再执行逆向迁移并恢复旧应用版本。不得只恢复前端或只恢复 unified。
## 12. 待确认事项
- `pre` 浏览器真实联调和生产发布尚未执行
- 生产镜像 ID 将在发布前固化到发布记录。
-
+7 -7
View File
@@ -3,7 +3,7 @@
当前推荐部署链路:
```text
push test/main
push pre/main
→ Gitea Actions 构建并推送 Docker 镜像
→ Actions 通过 SSH 登录目标服务器
→ 目标服务器 docker pull 指定镜像 tag
@@ -16,7 +16,7 @@ push test/main
| 分支 | 环境 | 镜像 tag | 宿主机端口 | 默认服务器目录 | 容器名 |
| --- | --- | --- | --- | --- | --- |
| `test` | 测试环境 | `test-<short_sha>` | `9135` | `/opt/cozsweet-web-test` | `cozsweet-web-test` |
| `pre` | 预发环境 | `test-<short_sha>` | `9135` | `/opt/cozsweet-web-test` | `cozsweet-web-test` |
| `main` | 生产环境 | `prod-<short_sha>` | `9185` | `/opt/cozsweet-web-prod` | `cozsweet-web-prod` |
## Gitea Secrets
@@ -75,14 +75,14 @@ prod-<short_sha> 最近 3 个
`test-latest` / `prod-latest` 不计入保留数量,也不会主动删除。
部署脚本会在 `docker compose up` 成功后清理服务器本机旧镜像,只保留当前环境正在运行的一个精确版本镜像:测试环境保留当前 `test-<short_sha>`,生产环境保留当前 `prod-<short_sha>`
部署脚本会在 `docker compose up` 成功后清理服务器本机旧镜像,只保留当前环境正在运行的一个精确版本镜像:预发环境保留当前 `test-<short_sha>`,生产环境保留当前 `prod-<short_sha>`
## 本地发布入口
本地发布脚本现在只负责推送 Gitea 分支,触发 Actions
```bash
# 测试环境
# 预发环境
./scripts/release/pre_release_web.sh
# 生产环境
@@ -92,16 +92,16 @@ prod-<short_sha> 最近 3 个
也可以直接推送:
```bash
git push gitea test
git push gitea pre
git push --force gitea main
```
## 验证
测试环境:
预发环境:
```bash
ssh <user>@<test-host>
ssh <user>@<pre-host>
cd /opt/cozsweet-web-test
docker compose ps
curl -I http://127.0.0.1:9135/
+2 -2
View File
@@ -27,8 +27,8 @@ pnpm exec playwright install chromium
For local development on macOS, `pnpm test:e2e:chrome` can reuse the installed Google Chrome.
`pnpm test:e2e:mobile-smoke` runs the critical authentication, logout, token
refresh and paid-image unlock paths with the Pixel 7 profile. CI runs this tier
on every pull request and `dev` / `test` / `main` push.
refresh and paid-image unlock paths with the Pixel 7 profile. CI 在所有 pull
request 以及 `dev` / `pre` / `main` push 时运行这一层测试。
## Environment overrides
@@ -31,5 +31,5 @@ test("user can email login from other sign-in options and return to chat", async
expect(["desktop", "android"]).toContain(loginRequest?.postDataJSON().platform);
await expect(page.getByRole("textbox", { name: "Message" })).toBeVisible();
await expect(page.getByRole("button", { name: "Profile" })).toBeVisible();
await expect(page.getByRole("button", { name: "Save CozSweet" })).toBeVisible();
});
@@ -27,9 +27,12 @@ test("user can log out from the profile after email login", async ({
await expect(page).toHaveURL(/\/auth(?:\?.*)?$/);
await switchToEmailSignIn(page);
await submitEmailLogin(page, { expectedUrl: defaultCharacterChatUrl });
await expect(page.getByRole("button", { name: "Profile" })).toBeVisible();
await page.getByRole("link", { name: "Back to home" }).click();
await expect(page).toHaveURL(
new RegExp(defaultCharacterSplashPath.replace("?", "\\?") + "$"),
);
await page.getByRole("button", { name: "Profile" }).click();
await page.getByRole("button", { name: "Menu" }).click();
await expect(page).toHaveURL(
new RegExp(defaultCharacterProfilePath.replace("?", "\\?") + "$"),
);
@@ -42,7 +42,7 @@ test("guest user avatar returns to Profile after sign-in", async ({
});
for (const character of characters) {
test(`${character.displayName} avatar opens the matching Private Zoom`, async ({
test(`${character.displayName} avatar opens the matching Private Zone`, async ({
page,
}) => {
await enterCharacterChat(page, character.slug);
@@ -50,13 +50,13 @@ for (const character of characters) {
await page
.getByRole("button", {
name: `Open ${character.displayName}'s private zoom`,
name: `Open ${character.displayName}'s private zone`,
})
.last()
.click();
await expect(page).toHaveURL(
new RegExp(`/characters/${character.slug}/private-zoom(?:\\?.*)?$`),
new RegExp(`/characters/${character.slug}/private-zone(?:\\?.*)?$`),
);
});
}
@@ -0,0 +1,232 @@
import path from "node:path";
import { expect, test, type Page } from "@playwright/test";
import { mockCoreApis } from "@e2e/fixtures/api-mocks";
import { apiEnvelope } from "@e2e/fixtures/data/common";
import { clearBrowserState } from "@e2e/fixtures/test-helpers";
const characters = [
{
id: "elio",
slug: "elio",
displayName: "Elio Silvestri",
shortName: "Elio",
cover: "elio.png",
},
{
id: "maya-tan",
slug: "maya",
displayName: "Maya Tan",
shortName: "Maya",
cover: "maya.webp",
},
{
id: "nayeli-cervantes",
slug: "nayeli",
displayName: "Nayeli Cervantes",
shortName: "Nayeli",
cover: "nayeli.webp",
},
] as const;
const previewDirectory = path.join(
process.cwd(),
".codex",
"artifacts",
"frontend-preview",
"2026-07-22",
"multi-role-commercial",
);
test.beforeEach(async ({ baseURL, context, page }) => {
await clearBrowserState(context, page, baseURL);
await mockCoreApis(page);
await registerMultiRoleCommercialMocks(page);
});
for (const character of characters) {
test(`${character.displayName} homepage renders its assigned cover`, async ({
page,
}, testInfo) => {
const mobile = testInfo.project.name.includes("mobile");
await page.setViewportSize(
mobile ? { width: 390, height: 844 } : { width: 1440, height: 900 },
);
await page.goto(`/characters/${character.slug}/splash`);
const cover = page.locator(`img[src*="${character.cover}"]`);
await expect(cover).toBeVisible();
await expect(page.getByText(character.displayName).last()).toBeVisible();
await expect
.poll(() =>
cover.evaluate((image: HTMLImageElement) =>
image.complete ? image.naturalWidth : 0,
),
)
.toBeGreaterThan(0);
if (
process.env.FRONTEND_PREVIEW_SCREENSHOTS === "1" &&
character.id !== "elio"
) {
await page.screenshot({
path: path.join(
previewDirectory,
`${character.slug}-${mobile ? "mobile-390x844" : "desktop-1440x900"}.png`,
),
animations: "disabled",
});
}
});
test(`${character.displayName} can open a character-scoped Private Zone`, async ({
page,
}) => {
const albumRequest = page.waitForRequest((request) => {
const url = new URL(request.url());
return (
url.pathname === "/api/private-zone/albums" &&
url.searchParams.get("characterId") === character.id
);
});
await page.goto(`/characters/${character.slug}/private-zone`);
await albumRequest;
await expect(
page.getByRole("heading", { name: "Private albums" }),
).toBeVisible();
await expect(page.getByText(character.displayName).last()).toBeVisible();
const albumButton = page.getByRole("button", {
name: `View locked collection with 8 images from ${character.displayName}`,
});
if (character.id === "maya-tan") {
await expect(albumButton).toHaveCount(0);
await expect(page.getByRole("button", { name: "Refresh" })).toHaveCount(0);
await expect(page.getByText("No private albums yet.")).toHaveCount(0);
} else {
await expect(albumButton).toBeVisible();
}
});
test(`${character.displayName} receives a character-scoped Tip catalog`, async ({
page,
}) => {
const catalogRequest = page.waitForRequest((request) => {
const url = new URL(request.url());
return (
url.pathname === "/api/payment/gift-products" &&
url.searchParams.get("characterId") === character.id
);
});
await page.goto(`/characters/${character.slug}/tip`);
await catalogRequest;
await expect(
page.getByRole("heading", { name: `Buy ${character.shortName} a coffee` }),
).toBeVisible();
await expect(page.getByRole("radio", { name: /Small Coffee/ })).toBeChecked();
await expect(
page.getByRole("button", { name: "Order and Buy" }),
).toBeEnabled();
await expect(
page.getByText("This character does not have any gifts available yet."),
).toHaveCount(0);
});
}
test("a real Private Zone request failure still offers Retry", async ({
page,
}) => {
await page.route("**/api/private-zone/albums**", async (route) => {
await route.fulfill({ status: 503, json: { message: "Albums unavailable" } });
});
await page.goto("/characters/maya/private-zone");
await expect(page.getByRole("button", { name: "Retry" })).toBeVisible();
await expect(page.getByRole("button", { name: "Refresh" })).toHaveCount(0);
});
async function registerMultiRoleCommercialMocks(page: Page): Promise<void> {
await page.route("**/api/private-zone/albums**", async (route) => {
const url = new URL(route.request().url());
const characterId = url.searchParams.get("characterId") ?? "elio";
const character =
characters.find((candidate) => candidate.id === characterId) ?? characters[0];
const hasCompleteAlbum = character.id !== "maya-tan";
await route.fulfill({
json: apiEnvelope({
creditBalance: 1000,
pendingImageCount: hasCompleteAlbum ? 0 : 7,
hasIncompleteContent: !hasCompleteAlbum,
items: hasCompleteAlbum ? [
{
albumId: `album-${character.id}`,
title: `${character.shortName} private photos`,
content: null,
previewText: "Unlock this private album",
imageCount: 8,
images: [
{
url: `/images/private-zone/banner/${character.slug}.png`,
locked: true,
index: 0,
},
],
locked: true,
unlocked: false,
unlockCost: 320,
publishedAt: "2026-07-22T10:00:00+08:00",
lockDetail: { locked: true },
},
] : [],
}),
});
});
await page.route("**/api/payment/gift-products**", async (route) => {
const url = new URL(route.request().url());
const characterId = url.searchParams.get("characterId") ?? "elio";
const planPrefix =
characterId === "elio"
? "tip"
: `tip_${characterId.replaceAll("-", "_")}`;
await route.fulfill({
json: apiEnvelope({
characterId,
categories: [
{
category: "coffee",
name: "Coffee",
productCount: 1,
imageUrl: null,
},
],
plans: [
{
planId: `${planPrefix}_coffee_usd_4_99`,
planName: "Small Coffee",
orderType: "tip",
tipType: "coffee_small",
category: "coffee",
characterId,
description: "A character-scoped coffee gift",
imageUrl: null,
amountCents: 499,
currency: "USD",
autoRenew: false,
isFirstRechargeOffer: false,
firstRechargeDiscountPercent: 0,
promotionType: null,
},
],
}),
});
});
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Before

Width:  |  Height:  |  Size: 814 KiB

After

Width:  |  Height:  |  Size: 814 KiB

Before

Width:  |  Height:  |  Size: 652 KiB

After

Width:  |  Height:  |  Size: 652 KiB

Before

Width:  |  Height:  |  Size: 907 KiB

After

Width:  |  Height:  |  Size: 907 KiB

@@ -13,13 +13,13 @@ describe("OpenAPI contract comparison", () => {
chatHistory: { method: "get", path: "/api/chat/history" },
unlockAlbum: {
method: "post",
path: "/api/private-zoom/albums/{albumId}/unlock",
path: "/api/private-zone/albums/{albumId}/unlock",
},
},
{
paths: {
"/api/chat/history": { get: {} },
"/api/private-zoom/albums/{album_id}/unlock/": { post: {} },
"/api/private-zone/albums/{album_id}/unlock/": { post: {} },
},
},
);
+1 -1
View File
@@ -3,7 +3,7 @@
# 推送指定分支到指定远端。
# 当前发布由 Gitea Actions 构建镜像并通过 SSH 部署;本脚本只负责触发分支 push。
# 调用方:deploy_web.shproduction)→ push_to_remote "gitea" "main"
# deploy_web_test.shtest)→ push_to_remote "gitea" "test"
# deploy_web_test.shpre)→ push_to_remote "gitea" "pre"
push_to_remote() {
local remote="$1"
local branch="$2"
+2 -2
View File
@@ -1,6 +1,6 @@
#!/bin/bash
# ==========================================
# 测试环境 Web 部署脚本(Next.js + Gitea Actions SSH 部署模型)
# 预发环境 Web 部署脚本(Next.js + Gitea Actions SSH 部署模型)
# 原始 Dart: scripts/deploy/deploy_web_test.sh
# ==========================================
@@ -11,7 +11,7 @@ source "$SCRIPT_DIR/_deploy_lib.sh"
# 主函数
main() {
push_to_remote "gitea" "test"
push_to_remote "gitea" "pre"
}
main
+8 -8
View File
@@ -11,9 +11,9 @@ unset_git_hook_env() {
unset_git_hook_env
# Test 分支 worktree 路径
WORKTREE_PATH="/Users/chase/Documents/frontend/cozsweet-frontend-nextjs.worktrees/cozsweet-nextjs-test"
echo "=== 进入 test 分支 worktree ==="
# pre 分支 worktree 路径
WORKTREE_PATH="/Users/chase/Documents/frontend/cozsweet-frontend-nextjs.worktrees/cozsweet-nextjs-pre"
echo "=== 进入 pre 分支 worktree ==="
cd "$WORKTREE_PATH" || { echo "错误: 无法进入 $WORKTREE_PATH"; exit 1; }
echo "=== 检查当前分支 ==="
@@ -22,17 +22,17 @@ git branch --show-current
echo "=== 变基到 dev 分支 ==="
git rebase dev
# 复制测试环境图标(source: $WORKTREE_PATH/icons/test → dest: $WORKTREE_PATH/public/
echo "=== 复制测试环境图标(icons/test → public/ ==="
# 复制预发环境图标(运行资源目录仍为 icons/test
echo "=== 复制预发环境图标(icons/test → public/ ==="
cp -f "$WORKTREE_PATH/icons/test/favicon.ico" "$WORKTREE_PATH/public/favicon.ico"
cp -f "$WORKTREE_PATH/icons/test/icons/Icon-192.png" "$WORKTREE_PATH/public/images/icons/Icon-192.png"
cp -f "$WORKTREE_PATH/icons/test/icons/Icon-512.png" "$WORKTREE_PATH/public/images/icons/Icon-512.png"
# 准备测试环境变量($WORKTREE_PATH/env-example/.env.local.example → $WORKTREE_PATH/.env.local
echo "=== 准备测试环境变量(env-example/.env.local.example → .env.local ==="
# 准备预发环境变量(运行配置仍使用 .env.local
echo "=== 准备预发环境变量(env-example/.env.local.example → .env.local ==="
cp -f "$WORKTREE_PATH/env-example/.env.local.example" "$WORKTREE_PATH/.env.local"
echo "=== 执行构建部署脚本(测试环境)==="
echo "=== 执行构建部署脚本(预发环境)==="
./scripts/deploy/deploy_web_test.sh
echo "=== 预发布完成 ==="
@@ -85,8 +85,8 @@ describe("shared Tailwind components", () => {
<CharacterAvatar
src="/images/avatar/elio.png"
alt="Elio Silvestri"
actionLabel="Open Elio's private zoom"
analyticsKey="chat.open_private_zoom_from_avatar"
actionLabel="Open Elio's private zone"
analyticsKey="chat.open_private_zone_from_avatar"
onClick={() => undefined}
/>,
);
@@ -100,10 +100,10 @@ describe("shared Tailwind components", () => {
expect(characterHtml).toContain('<button type="button"');
expect(characterHtml).toContain(
'aria-label="Open Elio&#x27;s private zoom"',
'aria-label="Open Elio&#x27;s private zone"',
);
expect(characterHtml).toContain(
'data-analytics-key="chat.open_private_zoom_from_avatar"',
'data-analytics-key="chat.open_private_zone_from_avatar"',
);
expect(userHtml).toContain('<button type="button"');
expect(userHtml).toContain('aria-label="Open profile"');
@@ -79,18 +79,18 @@ describe("core Tailwind components", () => {
<AppBottomNav
activeItem="chat"
variant="dark"
privateZoomLabel="Maya Private Zoom"
privateZoneLabel="Maya Private Zone"
onChatClick={() => undefined}
onPrivateZoomClick={() => undefined}
onPrivateZoneClick={() => undefined}
/>,
);
const privateZoomHtml = renderToStaticMarkup(
const privateZoneHtml = renderToStaticMarkup(
<AppBottomNav
activeItem="privateZoom"
activeItem="privateZone"
variant="warm"
privateZoomLabel="Maya Private Zoom"
privateZoneLabel="Maya Private Zone"
onChatClick={() => undefined}
onPrivateZoomClick={() => undefined}
onPrivateZoneClick={() => undefined}
/>,
);
@@ -99,13 +99,13 @@ describe("core Tailwind components", () => {
expect(chatHtml).toMatch(
/<button[^>]*aria-current="page"[^>]*>.*?<span>Chat<\/span>/,
);
expect(privateZoomHtml).toMatch(/class="[^"]*warm[^"]*"/);
expect(privateZoomHtml).toMatch(
/<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private Zoom<\/span>/,
expect(privateZoneHtml).toMatch(/class="[^"]*warm[^"]*"/);
expect(privateZoneHtml).toMatch(
/<button[^>]*aria-current="page"[^>]*>.*?<span>Maya Private Zone<\/span>/,
);
expect(chatHtml).toContain('data-analytics-key="navigation.chat"');
expect(privateZoomHtml).toContain(
'data-analytics-key="navigation.private_zoom"',
expect(privateZoneHtml).toContain(
'data-analytics-key="navigation.private_zone"',
);
});
});
+11 -11
View File
@@ -4,23 +4,23 @@ import { Camera, MessageCircle } from "lucide-react";
import styles from "./app-bottom-nav.module.css";
export type AppBottomNavItem = "chat" | "privateZoom";
export type AppBottomNavItem = "chat" | "privateZone";
export type AppBottomNavVariant = "warm" | "dark";
export interface AppBottomNavProps {
activeItem?: AppBottomNavItem | null;
variant?: AppBottomNavVariant;
privateZoomLabel: string;
privateZoneLabel: string;
onChatClick: () => void;
onPrivateZoomClick: () => void;
onPrivateZoneClick: () => void;
}
export function AppBottomNav({
activeItem = null,
variant = "warm",
privateZoomLabel,
privateZoneLabel,
onChatClick,
onPrivateZoomClick,
onPrivateZoneClick,
}: AppBottomNavProps) {
return (
<nav className={getRootClass(variant)} aria-label="Primary navigation">
@@ -37,14 +37,14 @@ export function AppBottomNav({
</button>
<button
type="button"
data-analytics-key="navigation.private_zoom"
data-analytics-label="Private Zoom navigation"
className={getButtonClass(activeItem === "privateZoom")}
aria-current={activeItem === "privateZoom" ? "page" : undefined}
onClick={onPrivateZoomClick}
data-analytics-key="navigation.private_zone"
data-analytics-label="Private Zone navigation"
className={getButtonClass(activeItem === "privateZone")}
aria-current={activeItem === "privateZone" ? "page" : undefined}
onClick={onPrivateZoneClick}
>
<Camera size={20} aria-hidden="true" />
<span>{privateZoomLabel}</span>
<span>{privateZoneLabel}</span>
</button>
</nav>
);
@@ -2,9 +2,9 @@ import type { ReactNode } from "react";
import { notFound } from "next/navigation";
import { getCharacterBySlug } from "@/data/constants/character";
import { PrivateZoomRouteProvider } from "@/providers/private-zoom-route-provider";
import { PrivateZoneRouteProvider } from "@/providers/private-zone-route-provider";
export default async function CharacterPrivateZoomLayout({
export default async function CharacterPrivateZoneLayout({
children,
params,
}: {
@@ -13,11 +13,11 @@ export default async function CharacterPrivateZoomLayout({
}) {
const { characterSlug } = await params;
const character = getCharacterBySlug(characterSlug);
if (!character?.capabilities.privateZoom) notFound();
if (!character?.capabilities.privateZone) notFound();
return (
<PrivateZoomRouteProvider characterId={character.id}>
<PrivateZoneRouteProvider characterId={character.id}>
{children}
</PrivateZoomRouteProvider>
</PrivateZoneRouteProvider>
);
}
@@ -0,0 +1,5 @@
import { PrivateZoneScreen } from "@/app/private-zone/private-zone-screen";
export default function CharacterPrivateZonePage() {
return <PrivateZoneScreen />;
}
@@ -1,5 +0,0 @@
import { PrivateZoomScreen } from "@/app/private-zoom/private-zoom-screen";
export default function CharacterPrivateZoomPage() {
return <PrivateZoomScreen />;
}
+3 -3
View File
@@ -253,8 +253,8 @@ export function ChatScreen() {
);
}
function handleOpenCharacterPrivateZoom(): void {
router.push(characterRoutes.privateZoom);
function handleOpenCharacterPrivateZone(): void {
router.push(characterRoutes.privateZone);
}
return (
@@ -304,7 +304,7 @@ export function ChatScreen() {
onUnlockImageMessage={handleUnlockImageMessage}
onOpenImage={handleOpenImage}
onUserAvatarClick={handleOpenUserProfile}
onCharacterAvatarClick={handleOpenCharacterPrivateZoom}
onCharacterAvatarClick={handleOpenCharacterPrivateZone}
onLoadMoreHistory={() => {
chatDispatch({ type: "ChatLoadMoreHistoryRequested" });
}}
@@ -62,10 +62,10 @@ describe("chat Tailwind components", () => {
expect(aiHtml).toContain('<button type="button"');
expect(aiHtml).toContain(
'data-analytics-key="chat.open_private_zoom_from_avatar"',
'data-analytics-key="chat.open_private_zone_from_avatar"',
);
expect(aiHtml).toContain(
'aria-label="Open Elio Silvestri&#x27;s private zoom"',
'aria-label="Open Elio Silvestri&#x27;s private zone"',
);
expect(userHtml).toContain('<button type="button"');
expect(userHtml).toContain(
+2 -2
View File
@@ -29,8 +29,8 @@ export function MessageAvatar({
imageSize={43}
priority
className={AVATAR_CLASS_NAME}
actionLabel={`Open ${character.displayName}'s private zoom`}
analyticsKey="chat.open_private_zoom_from_avatar"
actionLabel={`Open ${character.displayName}'s private zone`}
analyticsKey="chat.open_private_zone_from_avatar"
onClick={onClick}
/>
);
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import {
buildPrivateAlbumGalleryUrl,
buildPrivateZoomWithoutGalleryUrl,
buildPrivateZoneWithoutGalleryUrl,
getPrivateAlbumGalleryState,
} from "../private-album-gallery-url";
@@ -11,7 +11,7 @@ describe("private album gallery URL", () => {
const url = buildPrivateAlbumGalleryUrl("album:91", 3);
const params = new URL(url, "https://cozsweet.test").searchParams;
expect(url).toBe("/private-zoom?album=album%3A91&image=3");
expect(url).toBe("/private-zone?album=album%3A91&image=3");
expect(getPrivateAlbumGalleryState(params)).toEqual({
albumId: "album:91",
imageIndex: 3,
@@ -29,9 +29,9 @@ describe("private album gallery URL", () => {
it("removes gallery params without dropping other query values", () => {
expect(
buildPrivateZoomWithoutGalleryUrl(
buildPrivateZoneWithoutGalleryUrl(
new URLSearchParams("album=album-1&image=2&source=external"),
),
).toBe("/private-zoom?source=external");
).toBe("/private-zone?source=external");
});
});
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
import { PrivateAlbumSchema } from "@/data/schemas/private-zone";
import {
findPrivateAlbumDisplayImage,
@@ -6,10 +6,10 @@ import { getCharacterBySlug } from "@/data/constants/character";
import type { LoginStatus } from "@/data/schemas/auth";
import { CharacterProvider } from "@/providers/character-provider";
import { getCharacterRoutes } from "@/router/routes";
import type { PrivateZoomEvent } from "@/stores/private-zoom";
import type { PrivateZoomUnlockPaywallRequest } from "@/stores/private-zoom/private-zoom-state";
import type { PrivateZoneEvent } from "@/stores/private-zone";
import type { PrivateZoneUnlockPaywallRequest } from "@/stores/private-zone/private-zone-state";
import { usePrivateZoomUnlockPaywallNavigation } from "../use-private-zoom-flow";
import { usePrivateZoneUnlockPaywallNavigation } from "../use-private-zone-flow";
const mocks = vi.hoisted(() => ({
openAuth: vi.fn(),
@@ -30,7 +30,7 @@ vi.mock("@/lib/analytics", () => ({
},
}));
const unlockPaywallRequest: PrivateZoomUnlockPaywallRequest = {
const unlockPaywallRequest: PrivateZoneUnlockPaywallRequest = {
albumId: "album-1",
reason: "insufficient_credits",
requiredCredits: 10,
@@ -38,7 +38,7 @@ const unlockPaywallRequest: PrivateZoomUnlockPaywallRequest = {
shortfallCredits: 7,
};
describe("Private Zoom paywall navigation", () => {
describe("Private Zone paywall navigation", () => {
let container: HTMLDivElement;
let root: Root;
@@ -58,31 +58,31 @@ describe("Private Zoom paywall navigation", () => {
container.remove();
});
it("opens top up with a private zoom return target", () => {
const roomDispatch = vi.fn<Dispatch<PrivateZoomEvent>>();
it("opens top up with a private zone return target", () => {
const roomDispatch = vi.fn<Dispatch<PrivateZoneEvent>>();
renderHarness(root, "email", roomDispatch);
expect(mocks.openSubscription).toHaveBeenCalledWith({
type: "topup",
returnTo: "private-zoom",
returnTo: "private-zone",
analytics: {
entryPoint: "private_album_unlock",
triggerReason: "insufficient_credits",
},
});
expect(roomDispatch).toHaveBeenCalledWith({
type: "PrivateZoomUnlockPaywallConsumed",
type: "PrivateZoneUnlockPaywallConsumed",
});
});
it("keeps guest users on the private zoom auth return path", () => {
const roomDispatch = vi.fn<Dispatch<PrivateZoomEvent>>();
it("keeps guest users on the private zone auth return path", () => {
const roomDispatch = vi.fn<Dispatch<PrivateZoneEvent>>();
renderHarness(root, "guest", roomDispatch);
expect(mocks.openAuth).toHaveBeenCalledWith(
getCharacterRoutes("maya").privateZoom,
getCharacterRoutes("maya").privateZone,
);
expect(mocks.openSubscription).not.toHaveBeenCalled();
});
@@ -91,7 +91,7 @@ describe("Private Zoom paywall navigation", () => {
function renderHarness(
root: Root,
loginStatus: LoginStatus,
roomDispatch: Dispatch<PrivateZoomEvent>,
roomDispatch: Dispatch<PrivateZoneEvent>,
): void {
const character = getCharacterBySlug("maya");
if (!character) throw new Error("Missing Maya character fixture");
@@ -109,9 +109,9 @@ function Harness({
roomDispatch,
}: {
loginStatus: LoginStatus;
roomDispatch: Dispatch<PrivateZoomEvent>;
roomDispatch: Dispatch<PrivateZoneEvent>;
}) {
usePrivateZoomUnlockPaywallNavigation({
usePrivateZoneUnlockPaywallNavigation({
loginStatus,
roomDispatch,
unlockPaywallRequest,
@@ -1,19 +1,19 @@
import { describe, expect, it } from "vitest";
import { isPrivateZoomAuthRequired } from "../use-private-zoom-flow";
import { isPrivateZoneAuthRequired } from "../use-private-zone-flow";
describe("isPrivateZoomAuthRequired", () => {
describe("isPrivateZoneAuthRequired", () => {
it.each(["guest", "notLoggedIn"] as const)(
"requires auth for %s users",
(loginStatus) => {
expect(isPrivateZoomAuthRequired(loginStatus)).toBe(true);
expect(isPrivateZoneAuthRequired(loginStatus)).toBe(true);
},
);
it.each(["email", "facebook", "google"] as const)(
"allows %s users to top up directly",
(loginStatus) => {
expect(isPrivateZoomAuthRequired(loginStatus)).toBe(false);
expect(isPrivateZoneAuthRequired(loginStatus)).toBe(false);
},
);
});
@@ -4,7 +4,7 @@ import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
import { PrivateAlbumSchema } from "@/data/schemas/private-zone";
import { PrivateAlbumCard } from "../private-album-card";
@@ -33,9 +33,9 @@ describe("PrivateAlbumCard interactions", () => {
imageCount: 4,
images: [
{ url: "", locked: false, index: 0 },
{ url: "/images/private-zoom/locked.png", locked: true, index: 1 },
{ url: "/images/private-zoom/photo-2.png", locked: false, index: 2 },
{ url: "/images/private-zoom/photo-3.png", locked: false, index: 3 },
{ url: "/images/private-zone/locked.png", locked: true, index: 1 },
{ url: "/images/private-zone/photo-2.png", locked: false, index: 2 },
{ url: "/images/private-zone/photo-3.png", locked: false, index: 3 },
],
locked: false,
unlocked: true,
@@ -72,7 +72,7 @@ describe("PrivateAlbumCard interactions", () => {
title: "Locked afternoon",
imageCount: 3,
images: [
{ url: "/images/private-zoom/locked.png", locked: true, index: 0 },
{ url: "/images/private-zone/locked.png", locked: true, index: 0 },
],
locked: true,
unlocked: false,
@@ -5,11 +5,11 @@ import {
PrivateAlbumSchema,
type PrivateAlbum,
type PrivateAlbumInput,
} from "@/data/schemas/private-zoom";
} from "@/data/schemas/private-zone";
import { PrivateAlbumCard } from "../private-album-card";
const COVER_URL = "/images/private-zoom/banner/elio.png";
const COVER_URL = "/images/private-zone/banner/elio.png";
function makeAlbum(overrides: Partial<PrivateAlbumInput> = {}): PrivateAlbum {
return PrivateAlbumSchema.parse({
@@ -157,7 +157,7 @@ describe("PrivateAlbumCard", () => {
function makeImages(count: number) {
return Array.from({ length: count }, (_, index) => ({
url: `/images/private-zoom/photo-${index}.png`,
url: `/images/private-zone/photo-${index}.png`,
locked: false,
index,
}));
@@ -4,7 +4,7 @@ import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { PrivateAlbumSchema } from "@/data/schemas/private-zoom";
import { PrivateAlbumSchema } from "@/data/schemas/private-zone";
import { PrivateAlbumGallery } from "../private-album-gallery";
@@ -13,11 +13,11 @@ const album = PrivateAlbumSchema.parse({
title: "Private afternoon",
imageCount: 5,
images: [
{ url: "/images/private-zoom/photo-0.png", locked: false, index: 0 },
{ url: "/images/private-zone/photo-0.png", locked: false, index: 0 },
{ url: "", locked: false, index: 1 },
{ url: "/images/private-zoom/locked.png", locked: true, index: 2 },
{ url: "/images/private-zoom/photo-3.png", locked: false, index: 3 },
{ url: "/images/private-zoom/photo-4.png", locked: false, index: 4 },
{ url: "/images/private-zone/locked.png", locked: true, index: 2 },
{ url: "/images/private-zone/photo-3.png", locked: false, index: 3 },
{ url: "/images/private-zone/photo-4.png", locked: false, index: 4 },
],
locked: false,
unlocked: true,
@@ -3,8 +3,8 @@ import Image from "next/image";
import { Copy, ImageIcon, LockKeyhole } from "lucide-react";
import { CharacterAvatar } from "@/app/_components";
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import { isPrivateAlbumLocked } from "@/lib/private-zoom/private_album";
import type { PrivateAlbum } from "@/data/schemas/private-zone";
import { isPrivateAlbumLocked } from "@/lib/private-zone/private_album";
import {
getPrivateAlbumDisplayImages,
@@ -12,7 +12,7 @@ import {
PRIVATE_ALBUM_GRID_LIMIT,
} from "../private-album-images";
import styles from "../private-zoom-screen.module.css";
import styles from "../private-zone-screen.module.css";
export interface PrivateAlbumCardProps {
album: PrivateAlbum;
@@ -11,14 +11,14 @@ import {
import Image from "next/image";
import { ChevronLeft, ChevronRight, X } from "lucide-react";
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import type { PrivateAlbum } from "@/data/schemas/private-zone";
import {
getResistedGalleryDragDistance,
resolveGallerySwipeDirection,
} from "../private-album-gallery-motion";
import { getPrivateAlbumDisplayImages } from "../private-album-images";
import styles from "../private-zoom-screen.module.css";
import styles from "../private-zone-screen.module.css";
export interface PrivateAlbumGalleryProps {
album: PrivateAlbum;
@@ -1,4 +1,4 @@
import styles from "../private-zoom-screen.module.css";
import styles from "../private-zone-screen.module.css";
export interface StatusCardProps {
message: string;
@@ -1,6 +1,6 @@
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import type { PrivateAlbum } from "@/data/schemas/private-zone";
import styles from "../private-zoom-screen.module.css";
import styles from "../private-zone-screen.module.css";
export interface UnlockConfirmDialogProps {
album: PrivateAlbum;
@@ -7,14 +7,14 @@ import {
type RouteSearchParams,
} from "@/router/routes";
export default async function PrivateZoomPage({
export default async function PrivateZonePage({
searchParams,
}: {
searchParams: Promise<RouteSearchParams>;
}) {
redirect(
appendRouteSearchParams(
getCharacterRoutes(DEFAULT_CHARACTER_SLUG).privateZoom,
getCharacterRoutes(DEFAULT_CHARACTER_SLUG).privateZone,
await searchParams,
),
);
@@ -15,7 +15,7 @@ export function getPrivateAlbumGalleryState(input: {
export function buildPrivateAlbumGalleryUrl(
albumId: string,
imageIndex: number,
basePath: string = ROUTES.privateZoom,
basePath: string = ROUTES.privateZone,
): string {
const params = new URLSearchParams({
[PRIVATE_ALBUM_QUERY_PARAM]: albumId,
@@ -24,9 +24,9 @@ export function buildPrivateAlbumGalleryUrl(
return `${basePath}?${params.toString()}`;
}
export function buildPrivateZoomWithoutGalleryUrl(
export function buildPrivateZoneWithoutGalleryUrl(
input: { toString: () => string },
basePath: string = ROUTES.privateZoom,
basePath: string = ROUTES.privateZone,
): string {
const params = new URLSearchParams(input.toString());
params.delete(PRIVATE_ALBUM_QUERY_PARAM);
@@ -1,4 +1,4 @@
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import type { PrivateAlbum } from "@/data/schemas/private-zone";
export const PRIVATE_ALBUM_GRID_LIMIT = 9;
@@ -11,12 +11,12 @@ import {
useActiveCharacter,
useActiveCharacterRoutes,
} from "@/providers/character-provider";
import { isPrivateAlbumLocked } from "@/lib/private-zoom/private_album";
import { isPrivateAlbumLocked } from "@/lib/private-zone/private_album";
import { useAuthDispatch, useAuthState } from "@/stores/auth/auth-context";
import {
usePrivateZoomDispatch,
usePrivateZoomState,
} from "@/stores/private-zoom";
usePrivateZoneDispatch,
usePrivateZoneState,
} from "@/stores/private-zone";
import {
PrivateAlbumCard,
@@ -24,21 +24,21 @@ import {
StatusCard,
UnlockConfirmDialog,
} from "./components";
import styles from "./private-zoom-screen.module.css";
import styles from "./private-zone-screen.module.css";
import {
isPrivateZoomAuthRequired,
usePrivateZoomBootstrapFlow,
usePrivateZoomUnlockPaywallNavigation,
usePrivateZoomUnlockSuccessRefresh,
} from "./use-private-zoom-flow";
isPrivateZoneAuthRequired,
usePrivateZoneBootstrapFlow,
usePrivateZoneUnlockPaywallNavigation,
usePrivateZoneUnlockSuccessRefresh,
} from "./use-private-zone-flow";
import {
buildPrivateAlbumGalleryUrl,
buildPrivateZoomWithoutGalleryUrl,
buildPrivateZoneWithoutGalleryUrl,
getPrivateAlbumGalleryState,
} from "./private-album-gallery-url";
import { findPrivateAlbumDisplayImage } from "./private-album-images";
export function PrivateZoomScreen() {
export function PrivateZoneScreen() {
const router = useRouter();
const searchParams = useSearchParams();
const navigator = useAppNavigator();
@@ -46,15 +46,15 @@ export function PrivateZoomScreen() {
const characterRoutes = useActiveCharacterRoutes();
const authState = useAuthState();
const authDispatch = useAuthDispatch();
const state = usePrivateZoomState();
const dispatch = usePrivateZoomDispatch();
const state = usePrivateZoneState();
const dispatch = usePrivateZoneDispatch();
const openedGalleryInPageRef = useRef(false);
const galleryState = useMemo(
() => getPrivateAlbumGalleryState(searchParams),
[searchParams],
);
usePrivateZoomBootstrapFlow({
usePrivateZoneBootstrapFlow({
authDispatch,
hasInitialized: authState.hasInitialized,
isAuthLoading: authState.isLoading,
@@ -62,17 +62,17 @@ export function PrivateZoomScreen() {
roomDispatch: dispatch,
roomStatus: state.status,
});
usePrivateZoomUnlockPaywallNavigation({
usePrivateZoneUnlockPaywallNavigation({
loginStatus: authState.loginStatus,
roomDispatch: dispatch,
unlockPaywallRequest: state.unlockPaywallRequest,
});
usePrivateZoomUnlockSuccessRefresh(state.unlockSuccessNonce);
usePrivateZoneUnlockSuccessRefresh(state.unlockSuccessNonce);
const displayName = character.displayName;
const avatarUrl = character.assets.avatar;
const title = character.copy.privateZoomTitle;
const subtitle = character.copy.privateZoomSubtitle;
const title = character.copy.privateZoneTitle;
const subtitle = character.copy.privateZoneSubtitle;
const pendingAlbum = useMemo(
() =>
state.items.find(
@@ -107,15 +107,15 @@ export function PrivateZoomScreen() {
!galleryImage
) {
router.replace(
buildPrivateZoomWithoutGalleryUrl(
buildPrivateZoneWithoutGalleryUrl(
searchParams,
characterRoutes.privateZoom,
characterRoutes.privateZone,
),
{ scroll: false },
);
}
}, [
characterRoutes.privateZoom,
characterRoutes.privateZone,
galleryAlbum,
galleryImage,
galleryState,
@@ -125,15 +125,15 @@ export function PrivateZoomScreen() {
]);
const handleTopUpClick = () => {
if (isPrivateZoomAuthRequired(authState.loginStatus)) {
navigator.openAuth(characterRoutes.privateZoom);
if (isPrivateZoneAuthRequired(authState.loginStatus)) {
navigator.openAuth(characterRoutes.privateZone);
return;
}
navigator.openSubscription({
type: "topup",
returnTo: "private-zoom",
returnTo: "private-zone",
analytics: {
entryPoint: "private_zoom",
entryPoint: "private_zone",
triggerReason: "vip_cta",
},
});
@@ -145,7 +145,7 @@ export function PrivateZoomScreen() {
buildPrivateAlbumGalleryUrl(
albumId,
imageIndex,
characterRoutes.privateZoom,
characterRoutes.privateZone,
),
{ scroll: false },
);
@@ -158,9 +158,9 @@ export function PrivateZoomScreen() {
return;
}
router.replace(
buildPrivateZoomWithoutGalleryUrl(
buildPrivateZoneWithoutGalleryUrl(
searchParams,
characterRoutes.privateZoom,
characterRoutes.privateZone,
),
{ scroll: false },
);
@@ -172,7 +172,7 @@ export function PrivateZoomScreen() {
buildPrivateAlbumGalleryUrl(
galleryAlbum.albumId,
imageIndex,
characterRoutes.privateZoom,
characterRoutes.privateZone,
),
{ scroll: false },
);
@@ -187,7 +187,7 @@ export function PrivateZoomScreen() {
<section className={styles.hero} aria-label={title}>
<div className={styles.heroCover}>
<Image
src={character.assets.privateZoomBanner}
src={character.assets.privateZoneBanner}
alt=""
width={2048}
height={1152}
@@ -213,8 +213,8 @@ export function PrivateZoomScreen() {
<button
type="button"
data-analytics-key="private_zoom.primary_cta"
data-analytics-label="Open private zoom top up"
data-analytics-key="private_zone.primary_cta"
data-analytics-label="Open private zone top up"
className={styles.primaryCta}
onClick={handleTopUpClick}
>
@@ -237,7 +237,7 @@ export function PrivateZoomScreen() {
<StatusCard
message={state.errorMessage}
actionLabel="Retry"
onAction={() => dispatch({ type: "PrivateZoomRefresh" })}
onAction={() => dispatch({ type: "PrivateZoneRefresh" })}
/>
) : null}
@@ -245,14 +245,6 @@ export function PrivateZoomScreen() {
<StatusCard message="Loading private albums..." />
) : null}
{!state.isLoading && state.items.length === 0 && !state.errorMessage ? (
<StatusCard
message="No private albums yet."
actionLabel="Refresh"
onAction={() => dispatch({ type: "PrivateZoomRefresh" })}
/>
) : null}
<div className={styles.timeline}>
{state.items.map((album, index) => (
<PrivateAlbumCard
@@ -267,7 +259,7 @@ export function PrivateZoomScreen() {
}
onUnlock={() =>
dispatch({
type: "PrivateZoomUnlockRequested",
type: "PrivateZoneUnlockRequested",
albumId: album.albumId,
})
}
@@ -277,12 +269,12 @@ export function PrivateZoomScreen() {
</section>
<AppBottomNav
activeItem="privateZoom"
privateZoomLabel={character.copy.privateZoomTitle}
activeItem="privateZone"
privateZoneLabel={character.copy.privateZoneTitle}
onChatClick={() =>
navigator.push(characterRoutes.splash, { scroll: false })
}
onPrivateZoomClick={() => undefined}
onPrivateZoneClick={() => undefined}
/>
{pendingAlbum ? (
@@ -290,8 +282,8 @@ export function PrivateZoomScreen() {
album={pendingAlbum}
isUnlocking={state.isUnlocking}
errorMessage={state.unlockErrorMessage}
onCancel={() => dispatch({ type: "PrivateZoomUnlockCancelled" })}
onConfirm={() => dispatch({ type: "PrivateZoomUnlockConfirmed" })}
onCancel={() => dispatch({ type: "PrivateZoneUnlockCancelled" })}
onConfirm={() => dispatch({ type: "PrivateZoneUnlockConfirmed" })}
/>
) : state.unlockErrorMessage ? (
<div className={styles.toast} role="status">
@@ -8,37 +8,37 @@ import { behaviorAnalytics } from "@/lib/analytics";
import { useActiveCharacterRoutes } from "@/providers/character-provider";
import { useAppNavigator } from "@/router/use-app-navigator";
import type { AuthEvent } from "@/stores/auth/auth-events";
import type { PrivateZoomEvent } from "@/stores/private-zoom";
import type { PrivateZoomUnlockPaywallRequest } from "@/stores/private-zoom/private-zoom-state";
import type { PrivateZoneEvent } from "@/stores/private-zone";
import type { PrivateZoneUnlockPaywallRequest } from "@/stores/private-zone/private-zone-state";
import { useUserDispatch } from "@/stores/user/user-context";
export interface UsePrivateZoomBootstrapFlowInput {
export interface UsePrivateZoneBootstrapFlowInput {
authDispatch: Dispatch<AuthEvent>;
hasInitialized: boolean;
isAuthLoading: boolean;
loginStatus: LoginStatus;
roomDispatch: Dispatch<PrivateZoomEvent>;
roomDispatch: Dispatch<PrivateZoneEvent>;
roomStatus: string;
}
export interface UsePrivateZoomUnlockPaywallNavigationInput {
export interface UsePrivateZoneUnlockPaywallNavigationInput {
loginStatus: LoginStatus;
roomDispatch: Dispatch<PrivateZoomEvent>;
unlockPaywallRequest: PrivateZoomUnlockPaywallRequest | null;
roomDispatch: Dispatch<PrivateZoneEvent>;
unlockPaywallRequest: PrivateZoneUnlockPaywallRequest | null;
}
export function isPrivateZoomAuthRequired(loginStatus: LoginStatus): boolean {
export function isPrivateZoneAuthRequired(loginStatus: LoginStatus): boolean {
return loginStatus === "guest" || loginStatus === "notLoggedIn";
}
export function usePrivateZoomBootstrapFlow({
export function usePrivateZoneBootstrapFlow({
authDispatch,
hasInitialized,
isAuthLoading,
loginStatus,
roomDispatch,
roomStatus,
}: UsePrivateZoomBootstrapFlowInput): void {
}: UsePrivateZoneBootstrapFlowInput): void {
const previousLoginStatusRef = useRef(loginStatus);
useGuestLoginBootstrap({
@@ -56,12 +56,12 @@ export function usePrivateZoomBootstrapFlow({
previousLoginStatusRef.current = loginStatus;
if (roomStatus === "idle") {
roomDispatch({ type: "PrivateZoomInit" });
roomDispatch({ type: "PrivateZoneInit" });
return;
}
if (previousLoginStatus !== loginStatus && roomStatus !== "loading") {
roomDispatch({ type: "PrivateZoomRefresh" });
roomDispatch({ type: "PrivateZoneRefresh" });
}
}, [
hasInitialized,
@@ -72,19 +72,19 @@ export function usePrivateZoomBootstrapFlow({
]);
}
export function usePrivateZoomUnlockPaywallNavigation({
export function usePrivateZoneUnlockPaywallNavigation({
loginStatus,
roomDispatch,
unlockPaywallRequest,
}: UsePrivateZoomUnlockPaywallNavigationInput): void {
}: UsePrivateZoneUnlockPaywallNavigationInput): void {
const navigator = useAppNavigator();
const characterRoutes = useActiveCharacterRoutes();
useEffect(() => {
if (!unlockPaywallRequest) return;
if (isPrivateZoomAuthRequired(loginStatus)) {
navigator.openAuth(characterRoutes.privateZoom);
if (isPrivateZoneAuthRequired(loginStatus)) {
navigator.openAuth(characterRoutes.privateZone);
} else {
behaviorAnalytics.paywallShown({
entryPoint: "private_album_unlock",
@@ -92,16 +92,16 @@ export function usePrivateZoomUnlockPaywallNavigation({
});
navigator.openSubscription({
type: "topup",
returnTo: "private-zoom",
returnTo: "private-zone",
analytics: {
entryPoint: "private_album_unlock",
triggerReason: "insufficient_credits",
},
});
}
roomDispatch({ type: "PrivateZoomUnlockPaywallConsumed" });
roomDispatch({ type: "PrivateZoneUnlockPaywallConsumed" });
}, [
characterRoutes.privateZoom,
characterRoutes.privateZone,
loginStatus,
navigator,
roomDispatch,
@@ -109,7 +109,7 @@ export function usePrivateZoomUnlockPaywallNavigation({
]);
}
export function usePrivateZoomUnlockSuccessRefresh(
export function usePrivateZoneUnlockSuccessRefresh(
unlockSuccessNonce: number,
): void {
const userDispatch = useUserDispatch();
+4 -4
View File
@@ -37,8 +37,8 @@ export function SplashScreen() {
navigator.openChat({ replace: true });
};
const handleOpenPrivateZoom = () => {
navigator.push(characterRoutes.privateZoom, { scroll: false });
const handleOpenPrivateZone = () => {
navigator.push(characterRoutes.privateZone, { scroll: false });
};
const handleOpenSplash = () => {
@@ -77,9 +77,9 @@ export function SplashScreen() {
</div>
<AppBottomNav
activeItem="chat"
privateZoomLabel={character.copy.privateZoomTitle}
privateZoneLabel={character.copy.privateZoneTitle}
onChatClick={handleOpenSplash}
onPrivateZoomClick={handleOpenPrivateZoom}
onPrivateZoneClick={handleOpenPrivateZone}
/>
</div>
</MobileShell>
@@ -71,7 +71,7 @@ describe("local character catalog", () => {
expect(snapshot.catalog.getById("maya-tan")).toMatchObject({
displayName: "Maya Backend",
assets: { avatar: "/images/avatar/maya.png" },
capabilities: { chat: true, privateZoom: false, tip: true },
capabilities: { chat: true, privateZone: false, tip: true },
});
expect(snapshot.defaultCharacter.id).toBe("elio");
});
@@ -101,7 +101,7 @@ describe("local character catalog", () => {
for (const character of CHARACTERS) {
expect(character.capabilities).toEqual({
chat: true,
privateZoom: true,
privateZone: true,
tip: true,
});
expect(character.tagline.length).toBeGreaterThan(0);
+20 -20
View File
@@ -1,6 +1,6 @@
export interface CharacterCapabilities {
readonly chat: boolean;
readonly privateZoom: boolean;
readonly privateZone: boolean;
readonly tip: boolean;
}
@@ -17,12 +17,12 @@ export interface CharacterProfile {
readonly avatar: string;
readonly cover: string;
readonly chatBackground: string;
readonly privateZoomBanner: string;
readonly privateZoneBanner: string;
};
readonly copy: {
readonly splashRelationship: string;
readonly privateZoomTitle: string;
readonly privateZoomSubtitle: string;
readonly privateZoneTitle: string;
readonly privateZoneSubtitle: string;
readonly tipHeader: string;
readonly tipTitle: string;
};
@@ -62,19 +62,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
"Finally I can relax. How was your day out?",
capabilities: {
chat: true,
privateZoom: true,
privateZone: true,
tip: true,
},
assets: {
avatar: "/images/avatar/elio.png",
cover: "/images/cover/elio.png",
chatBackground: "/images/chat/bg-chatpage.png",
privateZoomBanner: "/images/private-zoom/banner/elio.png",
privateZoneBanner: "/images/private-zone/banner/elio.png",
},
copy: {
splashRelationship: "Your exclusive AI boyfriend",
privateZoomTitle: "Elio Private Zoom",
privateZoomSubtitle: "Join me, unlock my private zoom",
privateZoneTitle: "Elio Private Zone",
privateZoneSubtitle: "Join me, unlock my private zone",
tipHeader: "Tip Elio",
tipTitle: "Buy Elio a coffee",
},
@@ -91,19 +91,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
"How was your day?",
capabilities: {
chat: true,
privateZoom: true,
privateZone: true,
tip: true,
},
assets: {
avatar: "/images/avatar/maya.png",
cover: "/images/cover/maya.png",
cover: "/images/cover/maya.webp",
chatBackground: "/images/chat/bg-chatpage.png",
privateZoomBanner: "/images/private-zoom/banner/maya.png",
privateZoneBanner: "/images/private-zone/banner/maya.png",
},
copy: {
splashRelationship: "Your exclusive AI girlfriend",
privateZoomTitle: "Maya Private Zoom",
privateZoomSubtitle: "Join me, unlock my private zoom",
privateZoneTitle: "Maya Private Zone",
privateZoneSubtitle: "Join me, unlock my private zone",
tipHeader: "Tip Maya",
tipTitle: "Buy Maya a coffee",
},
@@ -120,19 +120,19 @@ const CHARACTER_PROFILES: readonly CharacterProfile[] = Object.freeze([
"Tell me how your day went.",
capabilities: {
chat: true,
privateZoom: true,
privateZone: true,
tip: true,
},
assets: {
avatar: "/images/avatar/nayeli.png",
cover: "/images/cover/nayeli.png",
cover: "/images/cover/nayeli.webp",
chatBackground: "/images/chat/bg-chatpage.png",
privateZoomBanner: "/images/private-zoom/banner/nayeli.png",
privateZoneBanner: "/images/private-zone/banner/nayeli.png",
},
copy: {
splashRelationship: "Your exclusive AI girlfriend",
privateZoomTitle: "Nayeli Private Zoom",
privateZoomSubtitle: "Join me, unlock my private zoom",
privateZoneTitle: "Nayeli Private Zone",
privateZoneSubtitle: "Join me, unlock my private zone",
tipHeader: "Tip Nayeli",
tipTitle: "Buy Nayeli a coffee",
},
@@ -186,8 +186,8 @@ export function mergeRemoteCharacterCatalog(
sortOrder: item.sortOrder,
capabilities: {
chat: item.capabilities.chat,
privateZoom:
local.capabilities.privateZoom && item.capabilities.privateContent,
privateZone:
local.capabilities.privateZone && item.capabilities.privateContent,
tip: local.capabilities.tip,
},
}),
+2 -2
View File
@@ -8,7 +8,7 @@ export * from "./character_repository";
export * from "./feedback_repository";
export * from "./metrics_repository";
export * from "./payment_repository";
export * from "./private_zoom_repository";
export * from "./private_zone_repository";
export * from "./user_repository";
export * from "./interfaces/iauth_repository";
export * from "./interfaces/ichat_repository";
@@ -16,5 +16,5 @@ export * from "./interfaces/icharacter_repository";
export * from "./interfaces/ifeedback_repository";
export * from "./interfaces/imetrics_repository";
export * from "./interfaces/ipayment_repository";
export * from "./interfaces/iprivate_zoom_repository";
export * from "./interfaces/iprivate_zone_repository";
export * from "./interfaces/iuser_repository";
+1 -1
View File
@@ -8,5 +8,5 @@ export * from "./icharacter_repository";
export * from "./ifeedback_repository";
export * from "./imetrics_repository";
export * from "./ipayment_repository";
export * from "./iprivate_zoom_repository";
export * from "./iprivate_zone_repository";
export * from "./iuser_repository";
@@ -1,7 +1,7 @@
import type {
PrivateAlbumsResponse,
PrivateAlbumUnlockResponse,
} from "@/data/schemas/private-zoom";
} from "@/data/schemas/private-zone";
import type { Result } from "@/utils/result";
export interface GetPrivateAlbumsInput {
@@ -9,7 +9,7 @@ export interface GetPrivateAlbumsInput {
limit?: number;
}
export interface IPrivateZoomRepository {
export interface IPrivateZoneRepository {
getAlbums(
input: GetPrivateAlbumsInput,
): Promise<Result<PrivateAlbumsResponse>>;
@@ -1,22 +1,22 @@
import type {
GetPrivateAlbumsInput,
IPrivateZoomRepository,
IPrivateZoneRepository,
} from "@/data/repositories/interfaces";
import {
type PrivateAlbumsResponse,
type PrivateAlbumUnlockResponse,
UnlockPrivateAlbumRequestSchema,
} from "@/data/schemas/private-zoom";
} from "@/data/schemas/private-zone";
import {
PrivateZoomApi,
privateZoomApi,
} from "@/data/services/api/private_zoom_api";
PrivateZoneApi,
privateZoneApi,
} from "@/data/services/api/private_zone_api";
import { Result } from "@/utils/result";
import { createLazySingleton } from "./lazy_singleton";
export class PrivateZoomRepository implements IPrivateZoomRepository {
constructor(private readonly api: PrivateZoomApi) {}
export class PrivateZoneRepository implements IPrivateZoneRepository {
constructor(private readonly api: PrivateZoneApi) {}
getAlbums(
input: GetPrivateAlbumsInput,
@@ -37,7 +37,7 @@ export class PrivateZoomRepository implements IPrivateZoomRepository {
}
}
export const getPrivateZoomRepository =
createLazySingleton<IPrivateZoomRepository>(
() => new PrivateZoomRepository(privateZoomApi),
export const getPrivateZoneRepository =
createLazySingleton<IPrivateZoneRepository>(
() => new PrivateZoneRepository(privateZoneApi),
);
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
import { FacebookIdentityResponseSchema } from "@/data/schemas/auth";
import { ChatHistoryResponseSchema } from "@/data/schemas/chat";
import { PaymentPlansResponseSchema } from "@/data/schemas/payment";
import { PrivateAlbumsResponseSchema } from "@/data/schemas/private-zoom";
import { PrivateAlbumsResponseSchema } from "@/data/schemas/private-zone";
import { UserSchema } from "@/data/schemas/user";
describe("immutable schemas", () => {
@@ -33,7 +33,7 @@ describe("immutable schemas", () => {
expectDeepFrozen(response);
});
it("freezes payment and private-zoom collections", () => {
it("freezes payment and private-zone collections", () => {
const plans = PaymentPlansResponseSchema.parse({
firstRechargeOffer: {
enabled: true,
@@ -4,7 +4,7 @@ import {
PrivateAlbumUnlockResponseSchema,
PrivateAlbumsResponseSchema,
UnlockPrivateAlbumRequestSchema,
} from "@/data/schemas/private-zoom";
} from "@/data/schemas/private-zone";
import { ApiPath } from "@/data/services/api";
const ALBUM_ID = "a1b2c3d4-0000-0000-0000-000000000000";
@@ -67,6 +67,20 @@ describe("Private Album schema models", () => {
expect(response).not.toHaveProperty("packageOptions");
});
it("keeps incomplete-content metadata without exposing pending images", () => {
const response = PrivateAlbumsResponseSchema.parse({
items: [],
creditBalance: 100,
pendingImageCount: 7,
hasIncompleteContent: true,
pendingImages: [{ url: COVER_URL }],
});
expect(response.pendingImageCount).toBe(7);
expect(response.hasIncompleteContent).toBe(true);
expect(response).not.toHaveProperty("pendingImages");
});
it("parses an unlock response with all album images", () => {
const response = PrivateAlbumUnlockResponseSchema.parse({
albumId: ALBUM_ID,
@@ -96,8 +110,8 @@ describe("Private Album schema models", () => {
});
it("encodes the album id in the unlock path", () => {
expect(ApiPath.privateZoomAlbumUnlock("album:91")).toBe(
"/api/private-zoom/albums/album%3A91/unlock",
expect(ApiPath.privateZoneAlbumUnlock("album:91")).toBe(
"/api/private-zone/albums/album%3A91/unlock",
);
});
});
@@ -1,12 +1,18 @@
import { z } from "zod";
import { arrayOrEmpty, numberOrZero } from "../../nullable-defaults";
import {
arrayOrEmpty,
booleanOrFalse,
numberOrZero,
} from "../../nullable-defaults";
import { PrivateAlbumSchema } from "../private_album";
export const PrivateAlbumsResponseSchema = z
.object({
items: arrayOrEmpty(PrivateAlbumSchema),
creditBalance: numberOrZero,
pendingImageCount: numberOrZero,
hasIncompleteContent: booleanOrFalse,
})
.readonly();
@@ -6,7 +6,7 @@ import { ApiPath } from "../api_path";
describe("ApiPath contract source", () => {
it("uses the shared contract path for every static operation", () => {
const staticOperations = Object.entries(apiContract).filter(
([operationId]) => operationId !== "privateZoomAlbumUnlock",
([operationId]) => operationId !== "privateZoneAlbumUnlock",
);
for (const [operationId, operation] of staticOperations) {
@@ -17,8 +17,8 @@ describe("ApiPath contract source", () => {
});
it("fills and encodes the private album path parameter", () => {
expect(ApiPath.privateZoomAlbumUnlock("album/id 1")).toBe(
"/api/private-zoom/albums/album%2Fid%201/unlock",
expect(ApiPath.privateZoneAlbumUnlock("album/id 1")).toBe(
"/api/private-zone/albums/album%2Fid%201/unlock",
);
});
});
@@ -14,7 +14,7 @@ vi.mock("../http_client", () => ({
import { ChatApi } from "../chat_api";
import { CharacterApi } from "../character_api";
import { PrivateZoomApi } from "../private_zoom_api";
import { PrivateZoneApi } from "../private_zone_api";
const CHARACTER_ID = "elio";
@@ -146,18 +146,18 @@ describe("multi-character API contract", () => {
);
});
it("scopes private-zoom albums to characterId", async () => {
it("scopes private-zone albums to characterId", async () => {
httpClientMock.mockResolvedValue({
success: true,
data: { items: [], creditBalance: 0 },
});
await new PrivateZoomApi().getAlbums({
await new PrivateZoneApi().getAlbums({
characterId: CHARACTER_ID,
limit: 20,
});
expect(httpClientMock).toHaveBeenCalledWith("/api/private-zoom/albums", {
expect(httpClientMock).toHaveBeenCalledWith("/api/private-zone/albums", {
query: { characterId: CHARACTER_ID, limit: 20 },
});
});
+2 -2
View File
@@ -21,8 +21,8 @@
"chatHistory": { "method": "get", "path": "/api/chat/history" },
"chatUnlockPrivate": { "method": "post", "path": "/api/chat/unlock-private" },
"chatUnlockHistory": { "method": "post", "path": "/api/chat/unlock-history" },
"privateZoomAlbums": { "method": "get", "path": "/api/private-zoom/albums" },
"privateZoomAlbumUnlock": { "method": "post", "path": "/api/private-zoom/albums/{albumId}/unlock" },
"privateZoneAlbums": { "method": "get", "path": "/api/private-zone/albums" },
"privateZoneAlbumUnlock": { "method": "post", "path": "/api/private-zone/albums/{albumId}/unlock" },
"metricsPwaEvent": { "method": "post", "path": "/api/metrics/pwa/event" },
"reportUserInfo": { "method": "post", "path": "/api/data/report-user-info" },
"feedback": { "method": "post", "path": "/api/feedback" },
+3 -3
View File
@@ -81,11 +81,11 @@ export class ApiPath {
// ============ 私密空间相关 ============
/** 获取私密图片包列表 */
static readonly privateZoomAlbums = apiContract.privateZoomAlbums.path;
static readonly privateZoneAlbums = apiContract.privateZoneAlbums.path;
/** 解锁私密图片包 */
static privateZoomAlbumUnlock(albumId: string): string {
return apiContract.privateZoomAlbumUnlock.path.replace(
static privateZoneAlbumUnlock(albumId: string): string {
return apiContract.privateZoneAlbumUnlock.path.replace(
"{albumId}",
encodeURIComponent(albumId),
);
+1 -1
View File
@@ -12,6 +12,6 @@ export * from "./feedback_api";
export * from "./http_client";
export * from "./metrics_api";
export * from "./payment_api";
export * from "./private_zoom_api";
export * from "./private_zone_api";
export * from "./response_helper";
export * from "./user_api";
@@ -4,7 +4,7 @@ import {
PrivateAlbumUnlockResponse,
PrivateAlbumUnlockResponseSchema,
UnlockPrivateAlbumRequest,
} from "@/data/schemas/private-zoom";
} from "@/data/schemas/private-zone";
import { ApiPath } from "./api_path";
import { httpClient } from "./http_client";
@@ -15,12 +15,12 @@ export interface GetPrivateAlbumsInput {
limit?: number;
}
export class PrivateZoomApi {
export class PrivateZoneApi {
async getAlbums(
input: GetPrivateAlbumsInput,
): Promise<PrivateAlbumsResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.privateZoomAlbums,
ApiPath.privateZoneAlbums,
{
query: {
characterId: input.characterId,
@@ -36,7 +36,7 @@ export class PrivateZoomApi {
body: UnlockPrivateAlbumRequest,
): Promise<PrivateAlbumUnlockResponse> {
const env = await httpClient<ApiEnvelope<unknown>>(
ApiPath.privateZoomAlbumUnlock(albumId),
ApiPath.privateZoneAlbumUnlock(albumId),
{
method: "POST",
body,
@@ -46,4 +46,4 @@ export class PrivateZoomApi {
}
}
export const privateZoomApi = new PrivateZoomApi();
export const privateZoneApi = new PrivateZoneApi();
@@ -14,7 +14,7 @@ const PendingPaymentOrderSchema = z
subscriptionType: z.enum(["vip", "topup", "tip"]),
giftCategory: z.string().min(1).nullable().default(null),
giftPlanId: z.string().min(1).nullable().default(null),
returnTo: z.enum(["chat", "private-zoom", "profile"]).optional(),
returnTo: z.enum(["chat", "private-zone", "profile"]).optional(),
characterSlug: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
createdAt: z.number(),
})
@@ -15,7 +15,7 @@ export type PaymentAnalyticsEntryPoint =
| "chat_input"
| "chat_unlock"
| "private_album_unlock"
| "private_zoom"
| "private_zone"
| "profile"
| "chat_offer_banner"
| "subscription_direct"
@@ -32,7 +32,7 @@ const ENTRY_POINTS = new Set<PaymentAnalyticsEntryPoint>([
"chat_input",
"chat_unlock",
"private_album_unlock",
"private_zoom",
"private_zone",
"profile",
"chat_offer_banner",
"subscription_direct",
@@ -17,15 +17,15 @@ describe("external entry navigation", () => {
it("resolves only canonical targets", () => {
expect(resolveExternalEntryTarget({ target: "chat" })).toBe(ROUTES.chat);
expect(resolveExternalEntryTarget({ target: "tip" })).toBe(ROUTES.tip);
expect(resolveExternalEntryTarget({ target: "private-zoom" })).toBe(
ROUTES.privateZoom,
expect(resolveExternalEntryTarget({ target: "private-zone" })).toBe(
ROUTES.privateZone,
);
});
it("rejects removed aliases and unsupported targets", () => {
expect(resolveExternalEntryTarget({ target: "tips" })).toBe(ROUTES.chat);
expect(resolveExternalEntryTarget({ target: "coffee" })).toBe(ROUTES.chat);
expect(resolveExternalEntryTarget({ target: "private_zoom" })).toBe(
expect(resolveExternalEntryTarget({ target: "private_zone" })).toBe(
ROUTES.chat,
);
expect(resolveExternalEntryTarget({ target: "/tip" })).toBe(ROUTES.chat);
@@ -44,10 +44,10 @@ describe("external entry navigation", () => {
).toBe(getCharacterRoutes("maya").chat);
expect(
resolveExternalEntryDestination({
target: "private-zoom",
target: "private-zone",
character: "unknown",
}),
).toBe(getCharacterRoutes("elio").privateZoom);
).toBe(getCharacterRoutes("elio").privateZone);
});
});
@@ -89,7 +89,7 @@ describe("subscription exit helpers", () => {
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
});
it("returns directly to private zoom without consuming chat state", async () => {
it("returns directly to private zone without consuming chat state", async () => {
consumePendingChatImageReturnMock.mockResolvedValue({
reason: "image_paywall",
characterId: "elio",
@@ -108,18 +108,18 @@ describe("subscription exit helpers", () => {
createdAt: 1,
});
expect(getSubscriptionFallbackExitUrl("private-zoom")).toBe(
getCharacterRoutes("elio").privateZoom,
expect(getSubscriptionFallbackExitUrl("private-zone")).toBe(
getCharacterRoutes("elio").privateZone,
);
await expect(consumeSubscriptionExitUrl("private-zoom")).resolves.toBe(
getCharacterRoutes("elio").privateZoom,
await expect(consumeSubscriptionExitUrl("private-zone")).resolves.toBe(
getCharacterRoutes("elio").privateZone,
);
expect(consumePendingChatImageReturnMock).not.toHaveBeenCalled();
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
expect(clearPendingChatUnlockMock).not.toHaveBeenCalled();
});
it("keeps private zoom ahead of stale chat state after payment", async () => {
it("keeps private zone ahead of stale chat state after payment", async () => {
peekPendingChatUnlockMock.mockResolvedValue({
reason: "single_message_unlock",
characterId: "elio",
@@ -132,8 +132,8 @@ describe("subscription exit helpers", () => {
});
await expect(
resolveSubscriptionSuccessExitUrl("private-zoom", "maya"),
).resolves.toBe(getCharacterRoutes("maya").privateZoom);
resolveSubscriptionSuccessExitUrl("private-zone", "maya"),
).resolves.toBe(getCharacterRoutes("maya").privateZone);
expect(peekPendingChatUnlockMock).not.toHaveBeenCalled();
expect(clearPendingChatUnlockMock).not.toHaveBeenCalled();
});
+3 -3
View File
@@ -13,7 +13,7 @@ import { getCharacterRoutes, ROUTES } from "@/router/routes";
export type ExternalEntryTarget =
| typeof ROUTES.chat
| typeof ROUTES.tip
| typeof ROUTES.privateZoom;
| typeof ROUTES.privateZone;
export interface ExternalEntryPayload {
deviceId?: string | null;
@@ -91,7 +91,7 @@ export function resolveExternalEntryDestination({
const routes = getCharacterRoutes(characterSlug);
const resolvedTarget = resolveExternalEntryTarget({ target });
if (resolvedTarget === ROUTES.tip) return routes.tip;
if (resolvedTarget === ROUTES.privateZoom) return routes.privateZoom;
if (resolvedTarget === ROUTES.privateZone) return routes.privateZone;
return routes.chat;
}
@@ -129,7 +129,7 @@ function resolveTarget(
if (target === "chat") return ROUTES.chat;
if (target === "tip") return ROUTES.tip;
if (target === "private-zoom") return ROUTES.privateZoom;
if (target === "private-zone") return ROUTES.privateZone;
return null;
}
+5 -5
View File
@@ -47,7 +47,7 @@ export function getSubscriptionFallbackExitUrl(
): string {
const routes = getCharacterRoutes(characterSlug);
if (returnTo === "chat") return routes.chat;
if (returnTo === "private-zoom") return routes.privateZoom;
if (returnTo === "private-zone") return routes.privateZone;
if (returnTo === "profile") {
return buildGlobalPageUrl(ROUTES.profile, routes.chat);
}
@@ -58,8 +58,8 @@ export async function consumeSubscriptionExitUrl(
returnTo: SubscriptionReturnTo,
characterSlug: string = DEFAULT_CHARACTER_SLUG,
): Promise<string> {
if (returnTo === "private-zoom") {
return getCharacterRoutes(characterSlug).privateZoom;
if (returnTo === "private-zone") {
return getCharacterRoutes(characterSlug).privateZone;
}
if (returnTo === "profile") {
return getSubscriptionFallbackExitUrl(returnTo, characterSlug);
@@ -75,8 +75,8 @@ export async function resolveSubscriptionSuccessExitUrl(
returnTo: SubscriptionReturnTo,
characterSlug: string = DEFAULT_CHARACTER_SLUG,
): Promise<string> {
if (returnTo === "private-zoom") {
return getCharacterRoutes(characterSlug).privateZoom;
if (returnTo === "private-zone") {
return getCharacterRoutes(characterSlug).privateZone;
}
if (returnTo === "profile") {
return getSubscriptionFallbackExitUrl(returnTo, characterSlug);
@@ -39,10 +39,10 @@ describe("payment search params", () => {
it("accepts only supported subscription return targets", () => {
expect(parseSubscriptionReturnTo("chat")).toBe("chat");
expect(parseSubscriptionReturnTo("private-zoom")).toBe("private-zoom");
expect(parseSubscriptionReturnTo("private-zone")).toBe("private-zone");
expect(parseSubscriptionReturnTo("profile")).toBe("profile");
expect(parseSubscriptionReturnTo(["private-zoom", "chat"])).toBe(
"private-zoom",
expect(parseSubscriptionReturnTo(["private-zone", "chat"])).toBe(
"private-zone",
);
expect(parseSubscriptionReturnTo("tip")).toBeNull();
expect(parseSubscriptionReturnTo(undefined)).toBeNull();
@@ -20,24 +20,24 @@ describe("pending payment order helpers", () => {
);
});
it("preserves private zoom returns when rebuilding Ezpay urls", () => {
it("preserves private zone returns when rebuilding Ezpay urls", () => {
expect(
buildPendingPaymentSubscriptionUrl({
payChannel: "ezpay",
returnTo: "private-zoom",
returnTo: "private-zone",
subscriptionType: "topup",
}),
).toBe(
"/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=private-zoom&character=elio",
"/subscription?type=topup&payChannel=ezpay&paymentReturn=1&returnTo=private-zone&character=elio",
);
});
it("stores private zoom as an Ezpay return target", async () => {
it("stores private zone as an Ezpay return target", async () => {
await clearPendingPaymentOrder();
const saveResult = await savePendingEzpayOrder({
orderId: "order-private-zoom",
returnTo: "private-zoom",
orderId: "order-private-zone",
returnTo: "private-zone",
subscriptionType: "topup",
createdAt: 1,
});
@@ -47,8 +47,8 @@ describe("pending payment order helpers", () => {
expect(storedResult).toMatchObject({
success: true,
data: {
orderId: "order-private-zoom",
returnTo: "private-zoom",
orderId: "order-private-zone",
returnTo: "private-zone",
},
});
await clearPendingPaymentOrder();
+1 -1
View File
@@ -28,7 +28,7 @@ export function parseSubscriptionReturnTo(
const returnTo = getFirstPaymentSearchParam(value);
if (
returnTo === "chat" ||
returnTo === "private-zoom" ||
returnTo === "private-zone" ||
returnTo === "profile"
) {
return returnTo;
@@ -1,4 +1,4 @@
import type { PrivateAlbum } from "@/data/schemas/private-zoom";
import type { PrivateAlbum } from "@/data/schemas/private-zone";
export function isPrivateAlbumLocked(album: PrivateAlbum): boolean {
return album.locked || !album.unlocked || album.lockDetail.locked;
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const instances = vi.hoisted(() => ({
chat: 0,
payment: 0,
privateZoom: 0,
privateZone: 0,
}));
vi.mock("@/stores/chat/chat-context", async () => {
@@ -51,23 +51,23 @@ vi.mock("@/stores/payment/payment-context", async () => {
};
});
vi.mock("@/stores/private-zoom", async () => {
vi.mock("@/stores/private-zone", async () => {
const { createElement, useState } = await import("react");
return {
PrivateZoomProvider({
PrivateZoneProvider({
characterId,
children,
}: {
characterId: string;
children: ReactNode;
}) {
const [instanceId] = useState(() => ++instances.privateZoom);
const [instanceId] = useState(() => ++instances.privateZone);
return createElement(
"div",
{
"data-character-id": characterId,
"data-instance-id": instanceId,
"data-testid": "private-zoom-provider",
"data-testid": "private-zone-provider",
},
children,
);
@@ -85,7 +85,7 @@ vi.mock("@/stores/sync/payment-success-sync", () => ({
import { ChatRouteProviders } from "@/providers/chat-route-providers";
import { PaymentRouteProvider } from "@/providers/payment-route-provider";
import { PrivateZoomRouteProvider } from "@/providers/private-zoom-route-provider";
import { PrivateZoneRouteProvider } from "@/providers/private-zone-route-provider";
describe("character actor route providers", () => {
let container: HTMLDivElement;
@@ -94,7 +94,7 @@ describe("character actor route providers", () => {
beforeEach(() => {
instances.chat = 0;
instances.payment = 0;
instances.privateZoom = 0;
instances.privateZone = 0;
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean })
.IS_REACT_ACT_ENVIRONMENT = true;
container = document.createElement("div");
@@ -121,14 +121,14 @@ describe("character actor route providers", () => {
);
});
it("recreates the private-zoom actor when the character changes", () => {
renderPrivateZoom("elio");
const firstInstance = instanceId("private-zoom-provider");
it("recreates the private-zone actor when the character changes", () => {
renderPrivateZone("elio");
const firstInstance = instanceId("private-zone-provider");
renderPrivateZoom("maya-tan");
renderPrivateZone("maya-tan");
expect(instanceId("private-zoom-provider")).not.toBe(firstInstance);
expect(testNode("private-zoom-provider").dataset.characterId).toBe(
expect(instanceId("private-zone-provider")).not.toBe(firstInstance);
expect(testNode("private-zone-provider").dataset.characterId).toBe(
"maya-tan",
);
});
@@ -155,12 +155,12 @@ describe("character actor route providers", () => {
});
}
function renderPrivateZoom(characterId: string): void {
function renderPrivateZone(characterId: string): void {
act(() => {
root.render(
<PrivateZoomRouteProvider characterId={characterId}>
<span>private zoom</span>
</PrivateZoomRouteProvider>,
<PrivateZoneRouteProvider characterId={characterId}>
<span>private zone</span>
</PrivateZoneRouteProvider>,
);
});
}
@@ -0,0 +1,21 @@
"use client";
import type { ReactNode } from "react";
import { PrivateZoneProvider } from "@/stores/private-zone";
export interface PrivateZoneRouteProviderProps {
children: ReactNode;
characterId: string;
}
export function PrivateZoneRouteProvider({
children,
characterId,
}: PrivateZoneRouteProviderProps) {
return (
<PrivateZoneProvider key={characterId} characterId={characterId}>
{children}
</PrivateZoneProvider>
);
}
@@ -1,21 +0,0 @@
"use client";
import type { ReactNode } from "react";
import { PrivateZoomProvider } from "@/stores/private-zoom";
export interface PrivateZoomRouteProviderProps {
children: ReactNode;
characterId: string;
}
export function PrivateZoomRouteProvider({
children,
characterId,
}: PrivateZoomRouteProviderProps) {
return (
<PrivateZoomProvider key={characterId} characterId={characterId}>
{children}
</PrivateZoomProvider>
);
}
+1 -1
View File
@@ -4,7 +4,7 @@
* 根级 Client Providers 包装
*
* 这里只保留跨路由的 Character Catalog、Auth、User、消息预览和 viewport
* Provider。Chat、Payment、PrivateZoom 状态机由对应路由 layout 按需挂载。
* Provider。Chat、Payment、PrivateZone 状态机由对应路由 layout 按需挂载。
*/
import type { ReactNode } from "react";
@@ -43,7 +43,7 @@ describe("global route context", () => {
"https://example.com/characters/maya/chat",
"//example.com/characters/maya/chat",
"/characters/unknown/chat",
"/characters/maya/private-zoom",
"/characters/maya/private-zone",
"/characters/maya/chat?image=1",
])("falls back to Elio for an invalid return target", (value) => {
expect(resolveGlobalRouteContextValue(value)).toBe(
@@ -54,15 +54,15 @@ describe("navigation resolver", () => {
).toBe(ROUTE_BUILDERS.authWithRedirect(subscriptionUrl));
});
it("builds private zoom subscription return urls", () => {
it("builds private zone subscription return urls", () => {
expect(
ROUTE_BUILDERS.subscription("topup", {
payChannel: "stripe",
returnTo: "private-zoom",
returnTo: "private-zone",
sourceCharacterSlug: "maya",
}),
).toBe(
"/subscription?type=topup&payChannel=stripe&returnTo=private-zoom&character=maya",
"/subscription?type=topup&payChannel=stripe&returnTo=private-zone&character=maya",
);
});
+5 -5
View File
@@ -8,7 +8,7 @@ describe("route meta", () => {
expect(getRouteAccess(ROUTES.splash)).toBe("authOnly");
expect(getRouteAccess(ROUTES.auth)).toBe("authOnly");
expect(getRouteAccess(ROUTES.chat)).toBe("guestEntry");
expect(getRouteAccess(ROUTES.privateZoom)).toBe("guestEntry");
expect(getRouteAccess(ROUTES.privateZone)).toBe("guestEntry");
expect(getRouteAccess(ROUTES.tip)).toBe("public");
expect(getRouteAccess(ROUTES.externalEntry)).toBe("public");
expect(getRouteAccess(ROUTES.profile)).toBe("realUser");
@@ -26,12 +26,12 @@ describe("route meta", () => {
expect(routes).toEqual({
splash: "/characters/maya/splash",
chat: "/characters/maya/chat",
privateZoom: "/characters/maya/private-zoom",
privateZone: "/characters/maya/private-zone",
tip: "/characters/maya/tip",
});
expect(getRouteAccess(routes.splash)).toBe("authOnly");
expect(getRouteAccess(routes.chat)).toBe("guestEntry");
expect(getRouteAccess(routes.privateZoom)).toBe("guestEntry");
expect(getRouteAccess(routes.privateZone)).toBe("guestEntry");
expect(getRouteAccess(routes.tip)).toBe("public");
});
@@ -41,8 +41,8 @@ describe("route meta", () => {
expect(getRouteAccess("/characters/maya/coins-rules")).toBe("public");
});
it("includes private zoom in static routes", () => {
expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateZoom);
it("includes private zone in static routes", () => {
expect(ALL_STATIC_ROUTES).toContain(ROUTES.privateZone);
});
it("includes tip in static routes", () => {

Some files were not shown because too many files have changed in this diff Show More