Repository navigation
✨ 日志页支持复制日志行与导出日志 - #1813
Open
CodFrm wants to merge 2 commits into
Open
✨ 日志页支持复制日志行与导出日志#1813CodFrm wants to merge 2 commits into
CodFrm wants to merge 2 commits into
Conversation
ui 测试项目 isolate:false,index.test.tsx 与 LoggerMobile.test.tsx 各自 mock 同一个 ./index 的依赖(./hooks、toast、use-is-mobile),先加载的文件的 mock 会被另一个文件复用,按目录运行时随机失败 1~2 条。合并为一个文件,useIsMobile 改为按 describe 切换的 vi.fn()。
- 日志行不再是 <button>,文字可拖选复制;拖选松开不触发展开,键盘展开改由行尾箭头按钮承担 - 每行新增复制按钮(桌面端悬停显示),复制为「时间 [级别] 消息 标签JSON」纯文本行 - 顶栏新增导出菜单:复制为文本 / 下载 .log / 下载 .json,范围为当前筛选结果,按时间升序
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
Description / 描述
close #1810
背景
1.5 重做日志页后,每行日志是一个
<button>(点击展开详情),文字无法拖选,桌面端消息还会被截断,展开详情只有 JSON。1.4 时每行是纯文本时间 消息 {标签JSON},用户靠拖选多行复制,这个用法在 1.5 里没了。issue 希望能导出成普通日志文件。本次改动
aria-expanded)。YYYY-MM-DD HH:mm:ss [LEVEL] message {"label":...}。这是 1.4 的行格式加上级别,标签为空时不带{}。makeBlobURL+chrome.downloads.download({ saveAs: true }),文件名scriptcat-logs-YYYYMMDD-HHmmss.{log,json}。复制或下载失败会弹错误提示。logs:文案补齐到 10 个语言包。LoggerMobile.test.tsx合并进index.test.tsx。ui测试项目配置了isolate: false,两个文件各自 mock 同一个./index的依赖,先加载的那个文件的 mock 会被另一个文件拿去用。改动前按目录运行,基线就随机挂 1~2 条(3 次运行分别失败 2/1/2 条)。合并只调整了测试组织方式,4 条移动端用例原样保留。已知限制
shrink-0,会把消息挤成 0 宽,行尾按钮也会被挤出可视区。这个排版在本 PR 之前就存在(chip 的 class 没改),但现在这种行上的复制按钮会点不到。没有在本 PR 里修,作为 follow-up。建议审查重点
components.tsx的LogRow:行容器onClick用getSelection().toString()判断是不是在拖选;两个内嵌按钮stopPropagation,避免同时触发行展开。filtered(当前筛选结果),不是全部日志。验证
pnpm exec vitest run --no-coverage src/pages/options/routes/Logger/ src/locales/:85/85 通过,在最终 head 上连续跑 3 次结果一致。新测试先确认失败(缺少函数或功能),再实现到通过。pnpm run typecheck、pnpm run check:i18n、改动文件的 prettier/eslint 均通过(pre-commit hook 也跑过)。pnpm test:改动只涉及 Logger 页面和 locales。pnpm run dev构建,e2e/session.mjs无头 Chromium,通过 CDP 操作真实鼠标):chrome.downloads.search显示 complete,.log 为 313 字节,和导出文本的 UTF-8 字节数一致。这一项是 Playwright 拦截的下载,没有覆盖「另存为」对话框和建议文件名(文件名由单测断言)。Screenshots / 截图
截图没有附在这里(暗色/亮色、导出菜单、悬停复制按钮、390px 移动端都在本地验证时看过),评审需要的话我再补。