Skip to content

Commit 768766b

Browse files
committed
修复代码审查发现的问题
CasesPage/WatchlistPage: - 修复stale closure: 移除setCurrentPage后多余的fetch调用 (React setState异步,手动fetch用旧值,依赖useEffect触发) ConversationsPage: - 修复stale closure: 移除addSelectedConversations中多余的fetch调用 - 修复selectedAccountId误入useEffect依赖(未被fetchConversations使用) - 修复自动刷新时alert阻塞UI: 移除自动fetch的alert提示 所有页面统一模式: setCurrentPage(1)后由useEffect自动触发fetch
1 parent 66dd984 commit 768766b

8 files changed

Lines changed: 120 additions & 23 deletions

File tree

frontend/src/pages/.agentic-security/findings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"scanId": "531b298d-affd-414e-b24b-f2a5424dc84c",
3-
"startedAt": "2026-07-18T09:10:40.397Z",
4-
"durationMs": 1226,
2+
"scanId": "3fe5af73-e51a-4c03-9183-19ec893d60ea",
3+
"startedAt": "2026-07-18T09:30:56.341Z",
4+
"durationMs": 778,
55
"scanned": {
66
"files": 19,
77
"lines": 0

frontend/src/pages/.agentic-security/last-scan.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"scanId": "531b298d-affd-414e-b24b-f2a5424dc84c",
3-
"startedAt": "2026-07-18T09:10:40.397Z",
4-
"durationMs": 1226,
2+
"scanId": "3fe5af73-e51a-4c03-9183-19ec893d60ea",
3+
"startedAt": "2026-07-18T09:30:56.341Z",
4+
"durationMs": 778,
55
"scanned": {
66
"files": 19,
77
"lines": 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
32003de013161f2893b72570ef2ba7f9f5ec9f288a301051f6871a4c0b08204c
1+
b554cf5750377191626c36b52d0779b509e6d8e0c928ad305f565c4856055512

frontend/src/pages/.agentic-security/scan-history.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,109 @@
180180
"ids": [
181181
"SettingsPage.tsx:210:214:SSRF"
182182
]
183+
},
184+
{
185+
"timestamp": "2026-07-18T09:29:11.774Z",
186+
"label": "scan",
187+
"total": 1,
188+
"critical": 0,
189+
"high": 1,
190+
"medium": 0,
191+
"low": 0,
192+
"kev": 0,
193+
"ids": [
194+
"SettingsPage.tsx:210:214:SSRF"
195+
]
196+
},
197+
{
198+
"timestamp": "2026-07-18T09:29:25.111Z",
199+
"label": "scan",
200+
"total": 1,
201+
"critical": 0,
202+
"high": 1,
203+
"medium": 0,
204+
"low": 0,
205+
"kev": 0,
206+
"ids": [
207+
"SettingsPage.tsx:210:214:SSRF"
208+
]
209+
},
210+
{
211+
"timestamp": "2026-07-18T09:29:36.730Z",
212+
"label": "scan",
213+
"total": 1,
214+
"critical": 0,
215+
"high": 1,
216+
"medium": 0,
217+
"low": 0,
218+
"kev": 0,
219+
"ids": [
220+
"SettingsPage.tsx:210:214:SSRF"
221+
]
222+
},
223+
{
224+
"timestamp": "2026-07-18T09:29:50.564Z",
225+
"label": "scan",
226+
"total": 1,
227+
"critical": 0,
228+
"high": 1,
229+
"medium": 0,
230+
"low": 0,
231+
"kev": 0,
232+
"ids": [
233+
"SettingsPage.tsx:210:214:SSRF"
234+
]
235+
},
236+
{
237+
"timestamp": "2026-07-18T09:30:04.993Z",
238+
"label": "scan",
239+
"total": 1,
240+
"critical": 0,
241+
"high": 1,
242+
"medium": 0,
243+
"low": 0,
244+
"kev": 0,
245+
"ids": [
246+
"SettingsPage.tsx:210:214:SSRF"
247+
]
248+
},
249+
{
250+
"timestamp": "2026-07-18T09:30:21.433Z",
251+
"label": "scan",
252+
"total": 1,
253+
"critical": 0,
254+
"high": 1,
255+
"medium": 0,
256+
"low": 0,
257+
"kev": 0,
258+
"ids": [
259+
"SettingsPage.tsx:210:214:SSRF"
260+
]
261+
},
262+
{
263+
"timestamp": "2026-07-18T09:30:39.446Z",
264+
"label": "scan",
265+
"total": 1,
266+
"critical": 0,
267+
"high": 1,
268+
"medium": 0,
269+
"low": 0,
270+
"kev": 0,
271+
"ids": [
272+
"SettingsPage.tsx:210:214:SSRF"
273+
]
274+
},
275+
{
276+
"timestamp": "2026-07-18T09:30:57.118Z",
277+
"label": "scan",
278+
"total": 1,
279+
"critical": 0,
280+
"high": 1,
281+
"medium": 0,
282+
"low": 0,
283+
"kev": 0,
284+
"ids": [
285+
"SettingsPage.tsx:210:214:SSRF"
286+
]
183287
}
184288
]

frontend/src/pages/.agentic-security/streak.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"firstScanDate": "2026-07-18T07:55:21.937Z",
3-
"lastScanDate": "2026-07-18T09:10:41.663Z",
4-
"totalScans": 14,
3+
"lastScanDate": "2026-07-18T09:30:57.139Z",
4+
"totalScans": 22,
55
"daysCleanCritical": 0,
66
"lastCleanDate": null,
77
"lastCriticalDate": "2026-07-18",

frontend/src/pages/CasesPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ export function CasesPage() {
9999
try {
100100
await api.cases.create(formData);
101101
setShowCreate(false);
102-
setCurrentPage(1);
103-
fetchCases();
102+
setCurrentPage(1); // useEffect will re-fetch with page=1
104103
} catch (error) {
105104
console.error("Failed to create case:", error);
106105
alert("创建案件失败");
@@ -111,8 +110,7 @@ export function CasesPage() {
111110
if (!confirm("确定删除此案件?")) return;
112111
try {
113112
await api.cases.delete(id);
114-
setCurrentPage(1);
115-
fetchCases();
113+
setCurrentPage(1); // useEffect will re-fetch with page=1
116114
} catch (error) {
117115
console.error("Failed to delete case:", error);
118116
alert("删除案件失败");

frontend/src/pages/ConversationsPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function ConversationsPage() {
101101

102102
useEffect(() => {
103103
fetchConversations();
104-
}, [filter, conversationsPage, selectedAccountId]);
104+
}, [filter, conversationsPage]);
105105

106106
const fetchAccounts = async () => {
107107
setLoadingAccounts(true);
@@ -137,7 +137,6 @@ export function ConversationsPage() {
137137
setConversations(conversationList);
138138
} catch (error) {
139139
console.error("获取会话失败:", error);
140-
alert("获取会话列表失败,请稍后重试");
141140
setConversations([]);
142141
} finally {
143142
setLoading(false);
@@ -255,8 +254,7 @@ export function ConversationsPage() {
255254

256255
setShowAddModal(false);
257256
setSelectedDialogs(new Set());
258-
setConversationsPage(1);
259-
fetchConversations();
257+
setConversationsPage(1); // useEffect will re-fetch with page=1
260258
} catch (error) {
261259
console.error("Failed to add conversations:", error);
262260
alert("添加对话失败");

frontend/src/pages/WatchlistPage.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ export function WatchlistPage() {
106106
try {
107107
await api.watchlist.create(formData);
108108
setShowCreate(false);
109-
setCurrentPage(1);
110-
fetchItems();
109+
setCurrentPage(1); // useEffect will re-fetch with page=1
111110
} catch (error) {
112111
console.error("Failed to create watchlist item:", error);
113112
alert("添加失败");
@@ -119,8 +118,7 @@ export function WatchlistPage() {
119118
try {
120119
await api.watchlist.update(editItem.id, formData);
121120
setEditItem(null);
122-
setCurrentPage(1);
123-
fetchItems();
121+
setCurrentPage(1); // useEffect will re-fetch with page=1
124122
} catch (error) {
125123
console.error("Failed to update watchlist item:", error);
126124
alert("更新失败");
@@ -131,8 +129,7 @@ export function WatchlistPage() {
131129
if (!confirm("确定删除此条目?")) return;
132130
try {
133131
await api.watchlist.delete(id);
134-
setCurrentPage(1);
135-
fetchItems();
132+
setCurrentPage(1); // useEffect will re-fetch with page=1
136133
} catch (error) {
137134
console.error("Failed to delete watchlist item:", error);
138135
alert("删除失败");

0 commit comments

Comments
 (0)