From 0d33d2321aa55aaf37641316a8e7cc5351fa6177 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Apr 2026 06:50:47 +0000 Subject: [PATCH] fix: address code review feedback - improve notifyType logic and typing Agent-Logs-Url: https://github.com/whyour/qinglong/sessions/4c9f0ab1-8b0e-4b94-b295-39c90ed942c2 Co-authored-by: whyour <22700758+whyour@users.noreply.github.com> --- back/services/system.ts | 9 +++++---- src/pages/setting/notifyLog.tsx | 32 +++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/back/services/system.ts b/back/services/system.ts index c3bb467a..967eb092 100644 --- a/back/services/system.ts +++ b/back/services/system.ts @@ -393,12 +393,13 @@ export default class SystemService { } let notifyType: string | undefined; - try { - const notifConfig = await this.getDb({ type: AuthDataType.notification }); - notifyType = notifConfig.info?.type as string | undefined; - } catch (e) {} if (notificationInfo?.type) { notifyType = typeString || (notificationInfo.type as string); + } else { + try { + const notifConfig = await this.getDb({ type: AuthDataType.notification }); + notifyType = notifConfig.info?.type as string | undefined; + } catch (e) {} } const isSuccess = await this.notificationService.notify( diff --git a/src/pages/setting/notifyLog.tsx b/src/pages/setting/notifyLog.tsx index de466296..7af6befb 100644 --- a/src/pages/setting/notifyLog.tsx +++ b/src/pages/setting/notifyLog.tsx @@ -3,15 +3,24 @@ import React from 'react'; import { Table, Tag } from 'antd'; import dayjs from 'dayjs'; -enum NotifyStatus { - '成功', - '失败', +interface NotifyLogItem { + id?: number; + timestamp?: number; + title?: string; + content?: string; + status?: number; + notifyType?: string; } -enum NotifyStatusColor { - 'success', - 'error', -} +const NotifyStatusLabel: Record = { + 0: '成功', + 1: '失败', +}; + +const NotifyStatusColor: Record = { + 0: 'success', + 1: 'error', +}; const columns = [ { @@ -56,13 +65,14 @@ const columns = [ dataIndex: 'status', key: 'status', width: 90, - render: (text: string, record: any) => { + render: (text: string, record: NotifyLogItem) => { + const statusKey = record.status ?? 1; return ( - {intl.get(NotifyStatus[record.status])} + {intl.get(NotifyStatusLabel[statusKey])} ); }, @@ -73,7 +83,7 @@ const NotifyLog = ({ data, height, }: { - data: Array; + data: Array; height: number; }) => { return (