mirror of
https://github.com/whyour/qinglong.git
synced 2026-04-29 00:45:11 +08:00
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>
This commit is contained in:
parent
79964f149c
commit
0d33d2321a
|
|
@ -393,12 +393,13 @@ export default class SystemService {
|
||||||
}
|
}
|
||||||
|
|
||||||
let notifyType: string | undefined;
|
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) {
|
if (notificationInfo?.type) {
|
||||||
notifyType = typeString || (notificationInfo.type as string);
|
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(
|
const isSuccess = await this.notificationService.notify(
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,24 @@ import React from 'react';
|
||||||
import { Table, Tag } from 'antd';
|
import { Table, Tag } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
enum NotifyStatus {
|
interface NotifyLogItem {
|
||||||
'成功',
|
id?: number;
|
||||||
'失败',
|
timestamp?: number;
|
||||||
|
title?: string;
|
||||||
|
content?: string;
|
||||||
|
status?: number;
|
||||||
|
notifyType?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum NotifyStatusColor {
|
const NotifyStatusLabel: Record<number, string> = {
|
||||||
'success',
|
0: '成功',
|
||||||
'error',
|
1: '失败',
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const NotifyStatusColor: Record<number, string> = {
|
||||||
|
0: 'success',
|
||||||
|
1: 'error',
|
||||||
|
};
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
|
@ -56,13 +65,14 @@ const columns = [
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
key: 'status',
|
key: 'status',
|
||||||
width: 90,
|
width: 90,
|
||||||
render: (text: string, record: any) => {
|
render: (text: string, record: NotifyLogItem) => {
|
||||||
|
const statusKey = record.status ?? 1;
|
||||||
return (
|
return (
|
||||||
<Tag
|
<Tag
|
||||||
color={NotifyStatusColor[record.status]}
|
color={NotifyStatusColor[statusKey]}
|
||||||
style={{ marginRight: 0 }}
|
style={{ marginRight: 0 }}
|
||||||
>
|
>
|
||||||
{intl.get(NotifyStatus[record.status])}
|
{intl.get(NotifyStatusLabel[statusKey])}
|
||||||
</Tag>
|
</Tag>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
@ -73,7 +83,7 @@ const NotifyLog = ({
|
||||||
data,
|
data,
|
||||||
height,
|
height,
|
||||||
}: {
|
}: {
|
||||||
data: Array<object>;
|
data: Array<NotifyLogItem>;
|
||||||
height: number;
|
height: number;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user