mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-04 07:06:36 +08:00
chore(message-gateway): swagger and format
This commit is contained in:
@@ -24,7 +24,10 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { TelegramForm, type TelegramFormValue } from '../channels/telegram/form';
|
||||
import {
|
||||
TelegramForm,
|
||||
type TelegramFormValue,
|
||||
} from '../channels/telegram/form';
|
||||
import { QQForm, type QQFormValue } from '../channels/qq/form';
|
||||
import type { CreateMessageChannelRequest } from '@/lib/services/message-gateway';
|
||||
|
||||
@@ -66,7 +69,9 @@ export function AddChannelDialog({
|
||||
const canSubmit =
|
||||
name.trim() !== '' &&
|
||||
((type === 'telegram' && telegram.bot_token.trim() !== '') ||
|
||||
(type === 'qq' && qq.app_id.trim() !== '' && qq.app_secret.trim() !== ''));
|
||||
(type === 'qq' &&
|
||||
qq.app_id.trim() !== '' &&
|
||||
qq.app_secret.trim() !== ''));
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!canSubmit || !type) return;
|
||||
|
||||
@@ -39,8 +39,7 @@ export function ChannelCard({
|
||||
}: ChannelCardProps) {
|
||||
const t = useTranslations('admin.messageGateway');
|
||||
const [confirmOpen, setConfirmOpen] = React.useState(false);
|
||||
const typeLabel =
|
||||
channel.type === 'qq' ? t('typeQQ') : t('typeTelegram');
|
||||
const typeLabel = channel.type === 'qq' ? t('typeQQ') : t('typeTelegram');
|
||||
|
||||
return (
|
||||
<div className='rounded-xl border bg-card p-4 space-y-4'>
|
||||
|
||||
@@ -119,7 +119,9 @@ export default function MessageGatewayAdminPage() {
|
||||
key={ch.id}
|
||||
channel={ch}
|
||||
toggling={toggleMutation.isPending}
|
||||
deleting={deleteMutation.isPending && deleteMutation.variables === ch.id}
|
||||
deleting={
|
||||
deleteMutation.isPending && deleteMutation.variables === ch.id
|
||||
}
|
||||
onToggle={(enabled) =>
|
||||
toggleMutation.mutate({ id: ch.id, enabled })
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ export function BotBindingCard() {
|
||||
UserMessageGatewayService.bind({ channel_id: channelId, code }),
|
||||
onSuccess: () => {
|
||||
toast.success(t('bindSuccess'));
|
||||
queryClient.invalidateQueries({ queryKey: ['message-gateway', 'bindings'] });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['message-gateway', 'bindings'],
|
||||
});
|
||||
setOpen(false);
|
||||
setChannelId('');
|
||||
setCode('');
|
||||
@@ -65,7 +67,9 @@ export function BotBindingCard() {
|
||||
mutationFn: (id: string) => UserMessageGatewayService.unbind(id),
|
||||
onSuccess: () => {
|
||||
toast.success(t('unbindSuccess'));
|
||||
queryClient.invalidateQueries({ queryKey: ['message-gateway', 'bindings'] });
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['message-gateway', 'bindings'],
|
||||
});
|
||||
},
|
||||
onError: (err: unknown) => {
|
||||
toast.error(t('unbindFailed') + ': ' + (err as Error).message);
|
||||
@@ -82,8 +86,12 @@ export function BotBindingCard() {
|
||||
<Bot className='size-4' />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-base font-semibold tracking-tight'>{t('title')}</h2>
|
||||
<p className='text-[11px] text-muted-foreground'>{t('description')}</p>
|
||||
<h2 className='text-base font-semibold tracking-tight'>
|
||||
{t('title')}
|
||||
</h2>
|
||||
<p className='text-[11px] text-muted-foreground'>
|
||||
{t('description')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -165,7 +173,9 @@ export function BotBindingCard() {
|
||||
</Select>
|
||||
{!channelsQuery.isPending &&
|
||||
(channelsQuery.data ?? []).length === 0 ? (
|
||||
<p className='text-xs text-muted-foreground'>{t('noChannels')}</p>
|
||||
<p className='text-xs text-muted-foreground'>
|
||||
{t('noChannels')}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
|
||||
@@ -85,7 +85,11 @@ const adminItems: NavItem[] = [
|
||||
{ titleKey: 'storage', url: '/admin/files', icon: FolderOpen },
|
||||
{ titleKey: 'database', url: '/admin/database', icon: Database },
|
||||
{ titleKey: 'push', url: '/admin/push', icon: Bell },
|
||||
{ titleKey: 'messageGateway', url: '/admin/message-gateway', icon: MessagesSquare },
|
||||
{
|
||||
titleKey: 'messageGateway',
|
||||
url: '/admin/message-gateway',
|
||||
icon: MessagesSquare,
|
||||
},
|
||||
{ titleKey: 'logs', url: '/admin/logs', icon: Terminal },
|
||||
{ titleKey: 'system', url: '/admin/system', icon: ShieldCheck },
|
||||
{ titleKey: 'adminSettings', url: '/admin/settings', icon: Settings },
|
||||
|
||||
Reference in New Issue
Block a user