refactor(chat): rely on server message limits

This commit is contained in:
2026-06-23 11:20:48 +08:00
parent d81abd6efd
commit 6bcc070ba1
19 changed files with 46 additions and 489 deletions
+2 -10
View File
@@ -42,22 +42,14 @@ export function ChatScreen() {
// isGuest 派生(chat-screen 是唯一知道这个值的地方 —— chat 机器无 isGuest 字段)
const isGuest = deriveIsGuest(authState.loginStatus);
// 游客配额耗尽 → 显示 Unlock CTA banner(替代 ChatInputBar
// 三重条件:游客 + 配额加载完 + 用户被配额 guard 拦截过至少一次
// - quotaLoaded 避免一进 /chat 就跳 bannerloadQuota 还在 in-flight
// - quotaExceededTrigger 而非 guestTotalQuota / guestRemainingQuota ——
// trigger 由 chat 机器的 guard 在 ChatSendMessage / ChatSendImage 被拦截时 +1
// 是 "用户被配额拒绝过" 的权威信号(避免依赖 quota 数值本身的边界判断)
const showGuestQuotaBanner =
isGuest && state.quotaLoaded && state.quotaExceededTrigger > 0;
// 消息数量限制由后端统一返回 blocked/daily_limit,前端不再处理本地额度。
const showDailyLimitBanner =
!isGuest &&
state.paywallTriggered &&
state.paywallReason === "daily_limit";
const showPhotoPaywallBanner =
state.paywallTriggered && state.paywallReason === "photo_paywall";
const showExhaustedBanner =
showGuestQuotaBanner || showDailyLimitBanner || showPhotoPaywallBanner;
showDailyLimitBanner || showPhotoPaywallBanner;
const externalBrowserPromptShownRef = useRef(false);
@@ -3,9 +3,7 @@
* ChatQuotaExhaustedBanner 游客配额耗尽横幅
*
* 何时显示:
* - isGuest === true(仅游客业务事实"非游客无配额上限")
* - quotaLoaded === true(避免一进 /chat 就跳 banner
* - guestTotalQuota <= 0(用 total 而非 remaining —— 配额刚减为 0 不立即跳)
* - 后端返回 blocked=true && blockReason="daily_limit"
*
* 视觉规格(与设计稿对齐):
* - 粉→品红渐变背景(与 splash 渐变一致)