diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index 4e108efe5..49ef9f056 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -32122,3 +32122,19 @@ - 防复发:后台授予角色与身份角色在同一事务里由触发器同步,不再依赖手工改库。 - 关联记录:BUG-1935(admin_runtime 读策略)、BUG-2346(后台两步验证)、首个 Owner 恢复迁移 20260807010000。 - 修复版本:分支 `claude/admin-role-sync-2360`。 + +## BUG-2361 | 电脑上找不到兑换码入口,鼠标放到图标上也没有提示 + +- 状态:resolved(待 staging 验收) +- 现象:2026-11-25 内测用户反馈:手机上好用,电脑上「有点找不到兑换入口,鼠标放过去也没有显示哪个是什么的指引」。 +- 触发条件:电脑浏览器。唯一入口是左下角头像 → 账户菜单「账户与点数」→ 弹窗里的「兑换码」页;菜单里没有「兑换」两个字,侧栏左下的余额只是文字;左上角收起侧栏的按钮只有图标、悬停无名字;侧栏收起成窄栏后,头像按钮没有名字也没有悬停提示。 +- 根因:入口命名只写了「账户与点数」,用户不会联想到兑换码;桌面上纯图标的控件(侧栏开合按钮、窄栏头像)没有悬停提示,SidebarRail 的读屏名还是英文。 +- 修复: + - 账户菜单在「账户与点数」下面加一行「兑换码」(Ticket 图标,与其他行同样式),直接打开「账户与点数」的兑换码页;电脑上(hover + 精确指针)输入框自动获得光标,手机不弹键盘。首页走 Home 的 controls(`onOpenRedeem`),其他页走外壳的 `onOpenAccountDialog`(多传 `{ tab: "redeem" }`)。 + - 侧栏账户行右侧的「N 点」改成独立按钮(盖在原位置上,原文字只占位、读屏隐藏;按钮不能放进菜单按钮里),点开「账户与点数」(第一页就是兑换码),悬停提示「点数与兑换码」。 + - 桌面上 SidebarTrigger 悬停显示「收起侧边栏 / 展开侧边栏」;窄栏头像悬停显示「账户」并有读屏名;SidebarRail 读屏名改中文。手机不加提示(手机上按钮带「菜单」字样)。 + - 「点数不够」时的路径已存在(聊天先弹兑换引导,再开账户与点数;报告的「去补点数」打开同一弹窗,第一页是兑换码),未改。 +- 验证:新增 `frontend/tests/redeem-entry-2361.test.tsx`(5 条:余额按钮在菜单按钮之外且有读屏名、点击在站外页 / 首页分别打开账户与点数、菜单「兑换码」行位置与 tab、兑换码页输入框两帧后聚焦且只在电脑上、桌面纯图标控件的悬停名);三个钉住旧调用的测试按原值 / 新值 / 原因更新(account-dialogs-every-page-2127、account-menu-every-page-20260928、sidebar-contract)。tsc 无错,ESLint 0 错误;`next build --webpack` 成功,用编译后的样式在无头 Chrome 1440 / 300 宽量过:余额按钮文字与占位文字位置相差 0.2px。前端全量 5374 条,失败 28 条,均为本机缺数据库 / docker / YAML / swisseph 的环境项。 +- 防复发:入口按用户的说法命名(「兑换码」直接出现在菜单里);桌面纯图标控件必须有悬停名,测试钉住侧栏开合与窄栏头像。 +- 关联记录:BUG-2253(账户行显示余额)、BUG-2127(账户弹窗每页原地打开)、BUG-2203(手机侧栏按钮带「菜单」字样)。 +- 修复版本:分支 `claude/redeem-entry-2361`。 diff --git a/frontend/src/app/(app)/layout.tsx b/frontend/src/app/(app)/layout.tsx index 217ba4025..6dccba642 100644 --- a/frontend/src/app/(app)/layout.tsx +++ b/frontend/src/app/(app)/layout.tsx @@ -74,9 +74,10 @@ function AppShell({ children }: { children: ReactNode }) { rectificationEnabled={rectificationEnabled} controls={registration?.controls} sessionControls={sessionActions.controls} - onOpenAccountDialog={(dialog, returnTarget) => { + onOpenAccountDialog={(dialog, returnTarget, options) => { // Same source as the menu on `/` (use-home-shell-registration). - accountDialogs.open(dialog, { returnTarget, source: dialog === "billing" ? "account-menu" : undefined }); + const source = dialog !== "billing" ? undefined : options?.tab === "redeem" ? "account-menu-redeem" : "account-menu"; + accountDialogs.open(dialog, { returnTarget, source, tab: options?.tab }); }} onOpenSession={(sessionId) => { navigateAppPath(sessionHref("", sessionId), router.push); diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index 857fc5926..9d0a4b5dd 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -1315,6 +1315,13 @@ button.shell-resize-handle:active { position: absolute; top: 0; right: -3px; z-i /* BUG-2253: the balance at the right end of the account row, small and quiet. */ .sidebar-account-credits { color: var(--color-ink-tertiary); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: var(--space-1); } .sidebar-account-trigger b { display: block; overflow: hidden; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; } +/* BUG-2361: the balance is its own button laid over its place on the row (opens 账户与点数 → 兑换码). + The copy inside the menu trigger only holds the width, so the name keeps the same room as before. */ +.sidebar-account-credits.is-placeholder { visibility: hidden; } +.sidebar-account-credits-button { height: auto; min-height: 0; width: auto; gap: 0; color: var(--color-ink-tertiary); font-weight: 400; box-shadow: none; } +.sidebar-account-credits-button { position: absolute; top: var(--space-2); bottom: var(--space-3); right: 0; display: flex; align-items: center; margin: 0; padding: 0 calc(var(--space-2) + var(--space-1)) 0 var(--space-2); border: 0; border-radius: var(--radius-md); background: transparent; font: inherit; font-size: 12px; cursor: pointer; transition: color var(--motion-instant) var(--ease-out); } +.sidebar-account-credits-button:hover { background: transparent; color: var(--color-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--color-border-strong); } +.sidebar-account-credits-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--sidebar-ring) 56%, transparent); outline-offset: -3px; } [data-sidebar="trigger"] { width: 44px; height: 44px; display: grid; flex: 0 0 auto; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--sidebar-foreground); cursor: pointer; } [data-sidebar="trigger"] svg { width: 18px; height: 18px; } [data-sidebar="trigger"]:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); } diff --git a/frontend/src/components/app-sidebar.tsx b/frontend/src/components/app-sidebar.tsx index 6b660a28a..61292c24f 100644 --- a/frontend/src/components/app-sidebar.tsx +++ b/frontend/src/components/app-sidebar.tsx @@ -24,14 +24,18 @@ import { MessageSquareWarning, Plus, Star, + Ticket, Users, } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { usePathname } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { primeSessionArrivals } from "@/lib/sidebar-session-arrivals"; -import type { MouseEvent, ReactNode, Ref } from "react"; +import type { MouseEvent, ReactElement, ReactNode, Ref } from "react"; import { OnboardingDot } from "@/components/onboarding-dot"; import type { AccountDialogIntent } from "@/lib/account-dialog-intent"; +import type { BillingPaneTab } from "@/lib/home-types"; import { newChatHref, sessionHref } from "@/lib/chat-session-url"; import { LEGAL_DOCUMENTS_VISIBLE } from "@/lib/legal-entity"; import { useOnboardingJourneyOptional } from "@/lib/onboarding-journey"; @@ -106,6 +110,8 @@ export type AppSidebarControls = { onOpenProfile: () => void; onOpenGeneral: () => void; onOpenBilling: () => void; + /** BUG-2361: 账户与点数 opened on its 兑换码 page. Optional so older registrations still type-check. */ + onOpenRedeem?: () => void; onOpenLogout: () => void; }; @@ -130,7 +136,7 @@ export type AppSidebarProps = { /** Opens a row off `/`: the shell routes it to `/?c=`. `controls` wins on `/`. */ onOpenSession?: (sessionId: string) => void; /** Off `/`: opens an account dialog in place, from the shell's account dialogs (BUG-2127). `controls` wins on `/`. */ - onOpenAccountDialog?: (dialog: AccountDialogIntent, returnTarget: HTMLButtonElement | null) => void; + onOpenAccountDialog?: (dialog: AccountDialogIntent, returnTarget: HTMLButtonElement | null, options?: { tab?: BillingPaneTab }) => void; }; const NAV_PAGES = [ @@ -182,6 +188,7 @@ export function AppSidebar({ onOpenProfile, onOpenGeneral, onOpenBilling, + onOpenRedeem, onOpenLogout, }: Partial = controls ?? {}; const onSelectSession = controlledSelectSession ?? onOpenSession; @@ -357,6 +364,23 @@ export function AppSidebar({ ); } + /* BUG-2361: a name on hover/focus for a control that shows only an icon. Desktop only — the + tooltip needs a pointer, and phones show words instead. `null` returns the control as it is. */ + function withHoverTooltip(label: string | null, control: ReactElement, side: "top" | "right" = "top") { + if (label === null) return control; + return ( + + + {label} + + ); + } + + /* The collapsed rail's avatar: same tooltip as the rail's other entries (to the right). */ + function withRailTooltip(label: string | null, control: ReactElement) { + return withHoverTooltip(label, control, "right"); + } + /* One entry of the account menu. The dialog opens in place on every page: on `/` through Home's controls, elsewhere through the shell (BUG-2127; off `/` the entry used to be a link to `/?account=`). */ @@ -366,10 +390,11 @@ export function AppSidebar({ className: string, content: ReactNode, pointer: { onPointerEnter?: () => void; onPointerDown?: () => void } = {}, + options?: { tab?: BillingPaneTab }, ) { const openInPlace = onOpen ?? (() => { setOwnMenuOpen(false); - onOpenAccountDialog?.(dialog, ownTriggerRef.current); + onOpenAccountDialog?.(dialog, ownTriggerRef.current, options); }); return ( {content} @@ -511,18 +536,41 @@ export function AppSidebar({ it keeps its own open state. Its entries open the dialogs in place everywhere (BUG-2127). Theme applies where the reader is. */ - - {account.avatar - ? - : } - {showExpandedContent ? {account.name} : null} - {/* BUG-2253 (产品负责人 2026-11-23): the balance on the account row, without opening the menu. */} - {showExpandedContent ? 点 : null} - + {withRailTooltip(isCollapsedDesktop ? "账户" : null, ( + + {account.avatar + ? + : } + {showExpandedContent ? {account.name} : null} + {/* BUG-2253 (产品负责人 2026-11-23): the balance on the account row, without opening the menu. + BUG-2361: here it only keeps its place; the visible balance is the button drawn over it below. */} + {showExpandedContent ? : null} + + ))} + {/* BUG-2361 (内测用户 2026-11-25「电脑找不到兑换入口,鼠标放过去也没有提示」): the balance is its + own button, laid over its place on the row (a button cannot sit inside the menu trigger), and + opens 账户与点数, whose first page is 兑换码. */} + {showExpandedContent ? withHoverTooltip(isMobile ? null : "点数与兑换码", ( + + )) : null} { prefetchBillingPanel(); if (account.paymentOpen !== false) prefetchPaymentPackages(); }, onPointerDown: () => { prefetchBillingPanel(); if (account.paymentOpen !== false) prefetchPaymentPackages(); }, })} + {/* BUG-2361 (内测用户 2026-11-25「电脑找不到兑换入口」): its own row, straight to the 兑换码 page. */} + {accountEntry("billing", onOpenRedeem, "account-menu-item", ( + <>