feat/update-playground-ui #1
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/update-playground-ui"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
close #issue_number
我已确认该 PR 已自测通过,相关截图如下:
1. visibleLinks 派生 key from name — 修 React key 警告 + iframe 永不渲染 - CHAT_LINKS 项只有 name 没 key,导致 useState(visibleLinks[0]?.key || null) 拿到 null → activeKey 变 undefined → activeSrc = null → iframe 不渲染 - 在 QRouter 内本地派生 key,不污染共享代码(/playground 也用 getChatLinks) 2. API 401 守护 — res === undefined 时不再 .data 抛错 - utils/api.js 的 response 拦截器在 401 / 网络错误时返回 undefined(不是 Promise.reject),所以 .then((res) => res.data) 会炸 - QRouter 显式判 res/data 缺失,走 tokenError 路径 3. --bg-base 加入 light 模式 — iframe 区不再漆黑 - 原 light 模式只覆写 --bg(实际是 panel 用的变量),没覆 --bg-base - 实际页面背景是 --bg-base,导致 light 模式下 iframe 区仍然深色 4. 侧栏 glassmorphism 渐变限定到暗色 — light 模式用纯白面板 - 原侧栏硬写 dark gradient,light 模式下一片暗黑 - 改成默认 var(--bg-panel),只在 :not(:where([data-theme-mode="light"])) 下加 dark gradient 5. /playground 路由恢复为原版(MUI Playground),/qrouter 为新版 - 之前把 /playground 重定向到 /qrouter;实测后保留双路由并存 Co-Authored-By: Mavis <mavis@mavis.local>1. /qrouter 去 status pill - 移除 .qrouter-iframe-status JSX 块 + 相关 state (iframeLoading / iframeError / onLoad / onError handler) - 移除 .qrouter-iframe-status CSS + @keyframes qrouter-pulse - iframe 现在没有 onLoad/onError 处理(就是裸 iframe) 2. MinimalLayout 支持 bare route - 加 BARE_ROUTES 数组 + useLocation 检测 pathname - /qrouter 命中时: * 不渲染 AppBar(顶部 Qine nav 整个去掉) * 不渲染 Footer(底部版本号那条) * Outlet Box marginTop 改成 0,minHeight 改成 100vh - 其他路由(Home / About / Login / /playground / /price 等) 行为不变,AppBar 1 个、Footer 1 个、marginTop 64px - 用数组 + includes 检测,后续要加新的全屏页直接 push 验证: / AppBar 1,Footer 1 (正常) /playground AppBar 1,Footer 1 (正常) /qrouter AppBar 0,Footer 0 (全屏) iframe 0,0 起 1389x868 铺满整个 viewport Co-Authored-By: Mavis <mavis@mavis.local>model.GetTokenByName already scopes by (user_id, name), so cross-user leakage isn't an issue, but the controller was returning the key of any token matching that pair regardless of status. fix: - require Status=Enabled when reusing - auto-delete disabled/expired token before recreating - default ExpiredTime to 30 days instead of permanent - clarify in the docstring that UnlimitedQuota=true is bound to user-group quota billing in model/token.go:IncreaseUserQuota, so this isn't a quota bypassgetChatLinks directly JSON.parse'd localStorage values, which would crash any view importing it (QRouter, Dashboard, QuickStartCard) if the user or a migration tool corrupted siteInfo. wrap with safeParse() and a numeric sort that handles NaN/invalid sort fields. spread CHAT_LINKS into a fresh array before mutating, so the const source stays clean. replace the placeholder markers '{key}' / '{server}' with '__PLAYGROUND_KEY__' and '__PLAYGROUND_SERVER__' so we don't replace literal occurrences of the old markers in URL templates (especially JSON in fragment hashes). keep the old names as a secondary fallback for backward compatibility with admin-set chat_links in the database. use split/join to only match the first occurrence.the iframe was loaded into a third-party chat app with full mic/camera permissions and no sandbox. tighten: - sandbox='allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-storage-access-by-user-activation' - trim allow to clipboard-read/write only; drop microphone, camera theme bridge: - drop the side-effect on document.documentElement.dataset.theme — that was leaking past the qrouter-root subtree and into other views - switch to wrapper div className qrouter-mode-{dark,light} - inject --qrouter-accent from theme.palette.primary.main via inline style, so the project theme + ThemeColorButton picker both flow through - rewrite qrouter.css: light is default on .qrouter-root, dark overrides on .qrouter-mode-dark, accent reads from var(--qrouter-accent)- Remove /qrouter alias route; /playground is the only chat entry - Drop QRouterEnabled Go constant and qrouter_enabled /api/status field - Remove qrouter i18n namespace (~60 lines, zero code references) and unused menu.qrouter / dashboard_index.quickStart* keys; rewrite home.hero.tryQrouter copy to 'Playground' across 4 locales - Strip qrouter_enabled gates from Hero, Header, and config defaults; unify header chat entry to mobile-icon variant and t('playground') - Delete two QRouter plan docs in docs/plans/ /playground still renders the same standalone chat iframe proxy. views/QRouter/ directory and qrouter-* CSS class names are kept (medium-scope cleanup; rename to Playground/ is out of scope).- en_US: Playground → Chat - ja_JP: 遊び場 → チャット - zh_CN/zh_HK already 聊天, no change Header ChatMenuLink (web/src/layout/MinimalLayout/Header/index.jsx) uses t('playground'), so this changes the homepage right-top button label across all locales.UI 调整而非功能重构。所有 chat link / token 注入 / iframe sandbox/allow 行为 完全保留;样式严格 scope 在 .playground-root 内,不污染其他 view。 新增: - TopBar: 浮动玻璃面板, 不抢屏幕高度; hamburger / ⌘K shortcut / 主题快切 / 全屏切换 - SideDrawer: 默认展开, 320px 玻璃面板, 列出 chat links (今天/昨天/本周/更早) - CommandLauncher: ⌘K / Ctrl+K 模态搜索, 上下键 + Enter 切换上游, Esc 关闭 - Overlay: empty/loading/error 三态玻璃面板 (lucide flat outline 图标, 冷蓝主色) - tokens.css: --pg-* 全套 design token (颜色/半径/间距/字号/motion/shadow/glass), 作用域锁 .playground-root / .playground-mode-light / .playground-mode-dark, 不写 :root, 不动 document.documentElement - playground-ui-isolation.spec.js: 验证 data-theme 不被改动, :root 不含 --pg-*, iframe 指纹字符级保持, ⌘K/Ctrl+K + Esc 工作 修改: - index.jsx: 接入新组件; 主题快切走规范 SET_THEME Redux 派发 (与 ThemeButton 同路) - playground.css: 删除 :root { --playground-accent } 兜底块 (改由 inline style 注入) E2E: 7/8 通过. 唯一失败 (/playgound 301) 为 pre-existing vite dev SPA fallback 问题, base commit 下同样失败, 与本次重构无关. Co-Authored-By: Claude <noreply@anthropic.com>Plan v3.1.5 (E-series) + v3.2 (task-style double topbar): 3-theme system (E.3): - New .playground-mode-{light,dark,midnight} className, localStorage key playground-mode (not the global 'theme'); pgMode state + persist - ModeSwitcher.jsx: 3-mode cycle button (sun/moon/star), placed in outer 56px TopBar; TopBar refactored from themeMode/onToggleThemeMode to pgMode/onChangePgMode; does NOT dispatch SET_THEME, so <html> data-theme stays clean (verified by playground-ui-isolation spec) - All --pg-* tokens stay scoped to .playground-root; light=#f0f5ff, dark=#0a1633, midnight=#000814; alpha=0.40 glass + 20px blur + blue shadow + inset highlight - playground-theme.spec.js updated to use playground-mode key + cycle light/dark/midnight task-style double topbar (v3.2.1-v3.2.3): - New .pg-iframe-stage flex container holds 48px MainTopBar (top) + flex 1 .pg-iframe-wrap (bottom) - MainTopBar.jsx: 48px glass bar, left = chat_link name + status dot (online/loading/error/idle), center = "Playground" eyebrow, right = masked token (sk-****xxxx) + info button → StatusPopover - iframe borderless + transparent bg, "融入" into canvas by way of MainTopBar's bottom edge as the implicit frame - StatusPopover.jsx: 320px glass panel anchored top-right under MainTopBar; chat_link metadata + token status; Esc closes (Esc priority: statusOpen > launcherOpen) - Mobile (<768px): MainTopBar hidden to save vertical space Constraints honored: - iframe sandbox/allow/referrerPolicy untouched - replaceChatPlaceholders / API.get('/api/token/playground') / getChatLinks unchanged - 3-theme localStorage key persists, no <html data-theme> pollution - SideDrawer / CommandLauncher / fullscreen / Cmd+K / Esc all retained - No task elements that Playground lacks are copied (no right panel, no middle panel, no input area, no chat scroll, no stats view) Co-Authored-By: Claude <noreply@anthropic.com>View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.