Skip to content

Commit c01d291

Browse files
CodFrmcyfung1031Copilottheluckystrike
authored
🐛 修复运行日志页面点击查询按钮不刷新时间的问题 (#1294)
* ✅ additional test for responseType=document (#1262) * additional test for responseType=document * 🐛 修复 脚本设置-授权管理 控制无效的问题 (#1267) * 🐛 修复 脚本设置-授权管理 控制无效的问题 * 将校验逻辑放到confirm * 修复GM cookie权限判断 * 删除directDeny * buildCacheKey * 整理代码 * Update src/app/service/service_worker/permission_verify.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * 🔒 使用 DOMPurify 清理公告通知 HTML 内容 (#1274) * 🔒 使用 DOMPurify 清理公告通知的 HTML 内容 #1273 使用 DOMPurify 对服务端下发的公告 HTML 进行白名单过滤,防止潜在的 UI 注入风险。只允许基础标签和安全的 CSS 属性(颜色、字体相关)。 * code update --------- Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> * 🐛 修复 include *?* 表达式处理问题 #1271 (#1272) * 🐛 修复 include *?* 表达式处理问题 #1271 * Added error handling to avoid crash * update globSplit * update globSplit * update globSplit --------- Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> * fix #1274 (#1275) * fix #1274 * Update index.ts * Array.includes -> Set.has * 🐛 修复与隐身窗口检查权限冲突导致反复重启的问题 * 📄 docs: update Chrome Web Store URLs to new domain (#1279) Google migrated the Chrome Web Store from `chrome.google.com/webstore` to `chromewebstore.google.com`. This updates all CWS URLs across README files to use the new domain. The old URLs currently redirect, but will eventually stop working. * ✅ 添加 Playwright E2E 测试及 GM API 功能测试 (#1283) * ✅ 添加 Playwright E2E 测试 - 新增 22 个 E2E 测试覆盖 Options、Popup、Install、Editor、Settings 页面 - 配置 Playwright 使用 --headless=new 模式加载扩展 - 在 CI workflow 中添加 E2E 测试 job * ✅ 添加 GM API E2E 测试 新增 gm-api.spec.ts 测试三类 GM API: - GM_ 同步 API (gm_api_test.js): 29 项测试 - GM.* 异步 API (gm_api_async_test.js): 29 项测试 - Content 注入测试 (inject_content_test.js): 11 项测试 实现要点: - 两阶段浏览器启动:Phase 1 启用 userScriptsAccess,Phase 2 重启运行测试 - 自动审批权限确认弹窗(cookie 等需要用户授权的 API) - 通过剪贴板注入脚本代码到 Monaco 编辑器 - 替换 jsdelivr CDN 为 unpkg 提升资源加载速度 - 去除 @require/@resource 的 SRI hash 避免校验失败 更新 utils.ts 中 installScriptByCode 增加保存失败的 fallback 检测 * 🐛 修复 GM API E2E 测试 CI 兼容性 - Phase 1 添加 --headless=new 参数,修复 CI 无 X server 环境 - 添加 eslint-disable 注释消除 Playwright use() 的误报 - prettier 格式化修正 * 🐛 修复 E2E 测试 CI 兼容性问题 - vitest.config.ts: 排除 e2e/ 目录避免 Vitest 误跑 Playwright 测试 - eslint.config.mjs: 为 e2e/ 目录关闭 react-hooks/rules-of-hooks 规则 - e2e/options.spec.ts: 菜单正则加 /i 标志修复英文环境大小写匹配 - prettier 格式化修正 * 🚑 修复其他扩展注入 chrome.runtime 导致环境误判的问题 #1280 (#1281) * 🐛 修复其他扩展注入 chrome.runtime 导致环境误判的问题 #1280 移除 isContent 运行时检测,改为通过 CustomEventMessage.envTag 在构建入口确定环境, 避免其他扩展(如大学搜题酱)向页面注入 chrome.runtime 对象导致 inject 环境被误判为 content 环境。 * Update src/app/service/content/gm_api/gm_api.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * update * 删除不必要的isconnect * 将 typecheck 集成到 lint/lint-fix 脚本中 * 修复引用 * 删除test-results --------- Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * ⚙️ 优化 CI 流水线和测试配置 - 缓存 Playwright 浏览器避免重复下载 - 测试失败时上传截图/视频/报告等调试产物 - Playwright CI 环境启用 HTML+list 双 reporter、失败截图和视频 - 各工具链配置屏蔽 .claude 目录 * ✅ 修复 e2e 测试 service worker 超时并优化等待策略 - gm-api.spec.ts: Phase 2 重启 context 后等待 service worker 注册完成 再交给 fixtures,避免 extensionId fixture 用 10s 全局超时等待失败 - gm-api.spec.ts: 用事件驱动 Promise 替换 500ms 轮询循环, console 结果一出现立即继续 - utils.ts: installScriptByCode 用 DOM 事件等待替代固定延迟: click 后等光标出现,粘贴后等 .view-lines 内容变化 --------- Co-authored-by: wangyizhi <yz@ggnb.top> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Michael Lip <51033404+theluckystrike@users.noreply.github.com> * 🐛 修复弹出框被遮挡的问题 (#1290) * fix getPopupContainer * 🐛 修复 pre-commit hook lint-fix 修改未加入暂存区的问题 * 🐛 修复运行日志页面日期选择弹出框被 overflow 容器裁剪的问题 * 🔧 修复 husky hook 可执行权限 --------- Co-authored-by: 王一之 <yz@ggnb.top> * 🐛 修复未绑定网盘时仍显示解绑按钮的问题 (#1291) * 🐛 修复未绑定网盘时仍显示解绑按钮的问题 closes #1289 * ♻️ 将 token 检查逻辑内聚到 auth.ts,降低 UI 组件耦合 * ♻️ 简化 FileSystemParams 中 token 检查逻辑,移除多余的 useCallback * 🐛 修复运行日志页面日期选择弹出框被容器裁剪的问题 (#1292) * 🐛 修复运行日志页面点击查询按钮不刷新时间的问题 (#1293) --------- Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Michael Lip <51033404+theluckystrike@users.noreply.github.com>
1 parent 8b4fd88 commit c01d291

9 files changed

Lines changed: 62 additions & 8 deletions

File tree

src/locales/ach-UG/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"delete_current_logs": "crwdns8080:0crwdne8080:0",
104104
"clear_completed": "crwdns8082:0crwdne8082:0",
105105
"clear_logs": "crwdns8084:0crwdne8084:0",
106+
"now": "Now",
106107
"total_logs": "crwdns8086:0{{length}}crwdne8086:0",
107108
"filtered_logs": "crwdns8088:0{{length}}crwdne8088:0",
108109
"enter_filter_conditions": "crwdns8090:0crwdne8090:0",

src/locales/de-DE/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "Aktuelle Protokolle löschen",
105105
"clear_completed": "Bereinigung abgeschlossen",
106106
"clear_logs": "Protokolle bereinigen",
107+
"now": "Jetzt",
107108
"total_logs": "Insgesamt {{length}} Protokolle gefunden",
108109
"filtered_logs": "Nach Filterung {{length}} Protokolle",
109110
"enter_filter_conditions": "Bitte geben Sie Filterbedingungen für die Abfrage ein",

src/locales/en-US/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "Delete Current Logs",
105105
"clear_completed": "Clearing Completed",
106106
"clear_logs": "Clear Logs",
107+
"now": "Now",
107108
"total_logs": "A total of {{length}} logs were queried",
108109
"filtered_logs": "{{length}} logs after filtering",
109110
"enter_filter_conditions": "Please Enter Filter Conditions for Query",

src/locales/ja-JP/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "現在のログを削除",
105105
"clear_completed": "クリア完了",
106106
"clear_logs": "ログをクリア",
107+
"now": "現在",
107108
"total_logs": "合計{{length}}件のログが見つかりました",
108109
"filtered_logs": "フィルタリング後{{length}}件のログ",
109110
"enter_filter_conditions": "フィルタリング条件を入力してクエリしてください",

src/locales/ru-RU/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "Удалить текущие журналы",
105105
"clear_completed": "Очистка завершена",
106106
"clear_logs": "Очистить журналы",
107+
"now": "Сейчас",
107108
"total_logs": "Найдено {{length}} записей журнала",
108109
"filtered_logs": "После фильтрации {{length}} записей журнала",
109110
"enter_filter_conditions": "Введите условия фильтрации для поиска",

src/locales/vi-VN/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "Xóa nhật ký hiện tại",
105105
"clear_completed": "Xóa hoàn tất",
106106
"clear_logs": "Xóa nhật ký",
107+
"now": "Hiện tại",
107108
"total_logs": "Tổng cộng {{length}} nhật ký đã được truy vấn",
108109
"filtered_logs": "{{length}} nhật ký sau khi lọc",
109110
"enter_filter_conditions": "Vui lòng nhập điều kiện lọc để truy vấn",

src/locales/zh-CN/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "删除当前日志",
105105
"clear_completed": "清空完成",
106106
"clear_logs": "清空日志",
107+
"now": "至今",
107108
"total_logs": "共查询到 {{length}} 条日志",
108109
"filtered_logs": "筛选后 {{length}} 条日志",
109110
"enter_filter_conditions": "请输入筛选条件进行查询",

src/locales/zh-TW/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"delete_current_logs": "刪除目前紀錄",
105105
"clear_completed": "清除完成",
106106
"clear_logs": "清除紀錄",
107+
"now": "至今",
107108
"total_logs": "共查詢到 {{length}} 筆紀錄",
108109
"filtered_logs": "篩選後 {{length}} 條紀錄",
109110
"enter_filter_conditions": "請輸入篩選條件進行查詢",

src/pages/options/routes/Logger.tsx

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from "react";
1+
import React, { useEffect, useRef } from "react";
22
import { BackTop, Button, Card, DatePicker, Input, List, Message, Space, Typography } from "@arco-design/web-react";
33
import dayjs from "dayjs";
44
import type { Logger } from "@App/app/repo/logger";
@@ -20,14 +20,23 @@ function LoggerPage() {
2020
const [search, setSearch] = React.useState<string>("");
2121
const [startTime, setStartTime] = React.useState(dayjs().subtract(24, "hour").unix());
2222
const [endTime, setEndTime] = React.useState(dayjs().unix());
23+
// 标记 endTime 是否代表"当前时间",默认为 true
24+
const [isNow, setIsNow] = React.useState(true);
25+
// 用于强制触发数据重新加载
26+
const [refreshToken, setRefreshToken] = React.useState(0);
27+
// 标记数据加载后是否需要自动执行过滤
28+
const needFilterRef = useRef(false);
29+
// 标记本次 onChange 是否由快捷方式触发
30+
const shortcutClickRef = useRef(false);
2331
const loggerDAO = new LoggerDAO();
2432
const systemConfig = { logCleanCycle: 1 };
2533
const { t } = useTranslation();
2634

27-
const onQueryLog = () => {
35+
const onQueryLog = (logsToFilter?: Logger[]) => {
36+
const data = logsToFilter ?? logs;
2837
const newQueryLogs: Logger[] = [];
2938
const regex = search && new RegExp(search);
30-
logs.forEach((log) => {
39+
data.forEach((log) => {
3140
for (let i = 0; i < querys.length; i += 1) {
3241
const query = querys[i];
3342
if (query.key) {
@@ -99,12 +108,18 @@ function LoggerPage() {
99108
});
100109
});
101110
setLabels(newLabels);
102-
setQueryLogs([]);
111+
// 如果是查询按钮触发的刷新,自动执行过滤
112+
if (needFilterRef.current) {
113+
needFilterRef.current = false;
114+
onQueryLog(l);
115+
} else {
116+
setQueryLogs([]);
117+
}
103118
if (init === 0) {
104119
setInit(1);
105120
}
106121
});
107-
}, [startTime, endTime]);
122+
}, [startTime, endTime, refreshToken]);
108123

109124
return (
110125
<>
@@ -133,10 +148,27 @@ function LoggerPage() {
133148
style={{ width: 400 }}
134149
showTime
135150
shortcutsPlacementLeft
136-
value={[startTime * 1000, endTime * 1000]}
151+
placeholder={isNow ? ["", t("now")] : undefined}
152+
value={isNow ? [startTime * 1000] : [startTime * 1000, endTime * 1000]}
137153
onChange={(_, time) => {
154+
if (!time || !time[0]) {
155+
// 清除操作,恢复默认状态
156+
setStartTime(dayjs().subtract(24, "hour").unix());
157+
setEndTime(dayjs().unix());
158+
setIsNow(true);
159+
return;
160+
}
138161
setStartTime(time[0].unix());
139162
setEndTime(time[1].unix());
163+
if (shortcutClickRef.current) {
164+
shortcutClickRef.current = false;
165+
setIsNow(true);
166+
} else {
167+
setIsNow(false);
168+
}
169+
}}
170+
onSelectShortcut={() => {
171+
shortcutClickRef.current = true;
140172
}}
141173
shortcuts={[
142174
{
@@ -177,7 +209,20 @@ function LoggerPage() {
177209
},
178210
]}
179211
/>
180-
<Button type="primary" onClick={onQueryLog}>
212+
<Button
213+
type="primary"
214+
onClick={() => {
215+
if (isNow) {
216+
// 刷新 endTime 到当前时间,数据加载后自动过滤
217+
needFilterRef.current = true;
218+
setEndTime(dayjs().unix());
219+
// 强制触发 useEffect,即使 endTime 值未变(同一秒内多次点击)
220+
setRefreshToken((prev) => prev + 1);
221+
} else {
222+
onQueryLog();
223+
}
224+
}}
225+
>
181226
{t("query")}
182227
</Button>
183228
</Space>
@@ -289,7 +334,8 @@ function LoggerPage() {
289334
}}
290335
>
291336
<Typography.Text>
292-
{formatUnixTime(startTime)} {t("to")} {formatUnixTime(endTime)} {t("total_logs", { length: logs.length })}
337+
{formatUnixTime(startTime)} {t("to")} {isNow ? t("now") : formatUnixTime(endTime)}{" "}
338+
{t("total_logs", { length: logs.length })}
293339
{init === 4
294340
? `, ${t("filtered_logs", { length: queryLogs.length })}`
295341
: `, ${t("enter_filter_conditions")}`}

0 commit comments

Comments
 (0)