From 96ab4a2cd08288dd645c8d2810ba58093ba62b59 Mon Sep 17 00:00:00 2001 From: binjoo Date: Wed, 27 Aug 2025 11:27:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?add=20=E5=A2=9E=E5=8A=A0=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=8E=A8=E9=80=81=E6=B8=A0=E9=81=93=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增、编辑推送接口时,选择推送渠道可以查看渠道类型。 --- components/channel-dialog.tsx | 2 +- components/endpoint-dialog.tsx | 35 ++++++++++++++++++++++++++-------- components/ui/select.tsx | 2 +- 3 files changed, 29 insertions(+), 10 deletions(-) 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/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) => ( )) From e359bd3cdecf0d2914a7f6206a9e31f7e1decbcc Mon Sep 17 00:00:00 2001 From: binjoo Date: Wed, 27 Aug 2025 11:49:53 +0800 Subject: [PATCH 2/2] Update endpoint-table.tsx --- components/endpoint-table.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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