Files
NapCatQQ/napcat.webui/src/components/onebot/display_card/meta.tsx
T
时瑾 06f6a542f5 refactor: 优化eslint配置,提升代码质量 (#1341)
* feat: 统一并标准化eslint

* lint: napcat.webui

* lint: napcat.webui

* lint: napcat.core

* build: fix

* lint: napcat.webui

* refactor: 重构eslint

* Update README.md
2025-11-03 16:30:45 +08:00

61 lines
1.3 KiB
TypeScript

import { Chip } from '@heroui/chip';
import { getLifecycleColor, getLifecycleName } from '@/utils/onebot';
import type {
OB11Meta,
OneBot11Heartbeat,
OneBot11Lifecycle,
} from '@/types/onebot';
export interface OneBotDisplayMetaProps {
data: OB11Meta
}
export interface OneBotDisplayMetaHeartbeatProps {
data: OneBot11Heartbeat
}
export interface OneBotDisplayMetaLifecycleProps {
data: OneBot11Lifecycle
}
const OneBotDisplayMetaHeartbeat: React.FC<OneBotDisplayMetaHeartbeatProps> = ({
data,
}) => {
return (
<div className='flex gap-2'>
<Chip>心跳</Chip>
<Chip>间隔 {data.status.interval}ms</Chip>
</div>
);
};
const OneBotDisplayMetaLifecycle: React.FC<OneBotDisplayMetaLifecycleProps> = ({
data,
}) => {
return (
<div className='flex gap-2'>
<Chip>生命周期</Chip>
<Chip color={getLifecycleColor(data.sub_type)}>
{getLifecycleName(data.sub_type)}
</Chip>
</div>
);
};
const OneBotDisplayMeta: React.FC<OneBotDisplayMetaProps> = ({ data }) => {
return (
<div className='h-full flex items-center'>
{data.meta_event_type === 'lifecycle' && (
<OneBotDisplayMetaLifecycle data={data} />
)}
{data.meta_event_type === 'heartbeat' && (
<OneBotDisplayMetaHeartbeat data={data} />
)}
</div>
);
};
export default OneBotDisplayMeta;