diff --git a/components/channel-dialog.tsx b/components/channel-dialog.tsx index 5f38473..eb493bf 100644 --- a/components/channel-dialog.tsx +++ b/components/channel-dialog.tsx @@ -190,4 +190,4 @@ export function ChannelDialog({ mode = "create", channel }: ChannelDialogProps) ) -} \ No newline at end of file +} \ No newline at end of file diff --git a/components/endpoint-dialog.tsx b/components/endpoint-dialog.tsx index d1ba544..e89ea8e 100644 --- a/components/endpoint-dialog.tsx +++ b/components/endpoint-dialog.tsx @@ -27,7 +27,7 @@ import { FormMessage, } from "@/components/ui/form" import { Plus, Loader2 } from "lucide-react" -import { useState } from "react" +import React, { useState } from "react" import { useForm } from "react-hook-form" import { zodResolver } from "@hookform/resolvers/zod" import { insertEndpointSchema } from "@/lib/db/schema/endpoints" @@ -35,9 +35,10 @@ import { Endpoint, NewEndpoint } from "@/lib/db/schema/endpoints" import { useToast } from "@/components/ui/use-toast" import { DropdownMenuItem } from "@/components/ui/dropdown-menu" import { Channel, ChannelType } from "@/lib/channels" -import { CHANNEL_TEMPLATES } from "@/lib/channels" +import { CHANNEL_TEMPLATES, CHANNEL_LABELS } from "@/lib/channels" import { TemplateFields } from "@/components/template-fields" import { createEndpoint, updateEndpoint } from "@/lib/services/endpoints" +import { SelectGroup, SelectLabel } from "@/components/ui/select" interface EndpointDialogProps { mode?: "create" | "edit" @@ -182,11 +183,29 @@ export function EndpointDialog({ - {channels.map((channel) => ( - - {channel.name} - - ))} + {(() => { + // 按渠道类型分组 + const groupedChannels: Record = {} + channels.forEach(channel => { + if (!groupedChannels[channel.type]) { + groupedChannels[channel.type] = [] + } + groupedChannels[channel.type].push(channel) + }) + + return Object.entries(groupedChannels).map(([type, channels]) => ( + + + {CHANNEL_LABELS[type as ChannelType]} + {channels.map(channel => ( + + {channel.name} + + ))} + + + )) + })()} @@ -275,4 +294,4 @@ export function EndpointDialog({ ) -} \ No newline at end of file +} \ No newline at end of file diff --git a/components/endpoint-table.tsx b/components/endpoint-table.tsx index f012e52..c9544b5 100644 --- a/components/endpoint-table.tsx +++ b/components/endpoint-table.tsx @@ -37,7 +37,7 @@ import { AlertDialogTitle, } from "@/components/ui/alert-dialog" import { STATUS_LABELS, STATUS_COLORS } from "@/lib/constants/endpoints" -import { Channel } from "@/lib/channels" +import { Channel, CHANNEL_LABELS } from "@/lib/channels" import { EndpointExample } from "@/components/endpoint-example" import { useRouter } from "next/navigation" import { deleteEndpoint, toggleEndpointStatus, testEndpoint } from "@/lib/services/endpoints" @@ -211,6 +211,7 @@ export function EndpointTable({ ID 名称 + 渠道类型 推送渠道 消息模版 状态 @@ -221,7 +222,7 @@ export function EndpointTable({ {filteredEndpoints.length === 0 ? ( - + {searchQuery ? "未找到匹配的接口" : "暂无接口"} @@ -238,6 +239,7 @@ export function EndpointTable({ {endpoint.id} {endpoint.name} + {channel && CHANNEL_LABELS[channel.type]} {channel?.name} @@ -357,4 +359,4 @@ export function EndpointTable({ /> ) -} \ No newline at end of file +} \ No newline at end of file diff --git a/components/ui/select.tsx b/components/ui/select.tsx index 0cbf77d..131e10c 100644 --- a/components/ui/select.tsx +++ b/components/ui/select.tsx @@ -105,7 +105,7 @@ const SelectLabel = React.forwardRef< >(({ className, ...props }, ref) => ( ))