优化组件页面代码
This commit is contained in:
@@ -33,9 +33,6 @@ const filterSchema = z
|
||||
batch_no: z.string().optional(),
|
||||
user_phone: z.string().optional(),
|
||||
resource_no: z.string().optional(),
|
||||
filter_prov: z.string().optional(),
|
||||
filter_city: z.string().optional(),
|
||||
filter_isp: z.string().optional(),
|
||||
proxy_host: z.string().optional(),
|
||||
proxy_port: z.string().optional(),
|
||||
node_ip: z.string().optional(),
|
||||
@@ -51,7 +48,7 @@ const filterSchema = z
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "结束时间不能早于开始时间",
|
||||
path: ["created_at_end"],
|
||||
path: ["expired_at_end"],
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -59,7 +56,6 @@ const filterSchema = z
|
||||
|
||||
type FilterSchema = z.infer<typeof filterSchema>
|
||||
|
||||
// 运营商映射
|
||||
const ispMap: Record<number, string> = {
|
||||
1: "电信",
|
||||
2: "联通",
|
||||
@@ -75,9 +71,6 @@ export default function ChannelPage() {
|
||||
batch_no: "",
|
||||
user_phone: "",
|
||||
resource_no: "",
|
||||
filter_prov: "",
|
||||
filter_city: "",
|
||||
filter_isp: "all",
|
||||
proxy_port: "",
|
||||
proxy_host: "",
|
||||
node_ip: "",
|
||||
@@ -109,7 +102,6 @@ export default function ChannelPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{/* 筛选表单 */}
|
||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<Controller
|
||||
@@ -126,7 +118,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="user_phone"
|
||||
control={control}
|
||||
@@ -141,7 +132,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="resource_no"
|
||||
control={control}
|
||||
@@ -156,7 +146,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="proxy_host"
|
||||
control={control}
|
||||
@@ -171,7 +160,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="proxy_port"
|
||||
control={control}
|
||||
@@ -186,7 +174,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="node_ip"
|
||||
control={control}
|
||||
@@ -201,7 +188,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="expired_at_start"
|
||||
control={control}
|
||||
@@ -216,7 +202,6 @@ export default function ChannelPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="expired_at_end"
|
||||
control={control}
|
||||
@@ -239,19 +224,7 @@ export default function ChannelPage() {
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
reset({
|
||||
batch_no: "",
|
||||
user_phone: "",
|
||||
resource_no: "",
|
||||
filter_prov: "",
|
||||
filter_city: "",
|
||||
filter_isp: "all",
|
||||
proxy_host: "",
|
||||
proxy_port: "",
|
||||
node_ip: "",
|
||||
expired_at_start: "",
|
||||
expired_at_end: "",
|
||||
})
|
||||
reset()
|
||||
setFilters({})
|
||||
table.pagination.onPageChange(1)
|
||||
}}
|
||||
@@ -279,18 +252,6 @@ export default function ChannelPage() {
|
||||
|
||||
{
|
||||
header: "自动配置",
|
||||
accessorFn: row => {
|
||||
const prov = row.filter_prov
|
||||
const city = row.filter_city
|
||||
const isp = row.filter_isp
|
||||
const parts = []
|
||||
if (prov && prov !== "all") parts.push(prov)
|
||||
if (city && city !== "all") parts.push(city)
|
||||
if (isp && isp !== "all") {
|
||||
parts.push(ispMap[Number(isp)] || isp)
|
||||
}
|
||||
return parts.length > 0 ? parts.join(" / ") : "不限"
|
||||
},
|
||||
cell: ({ row }) => {
|
||||
const prov = row.original.filter_prov
|
||||
const city = row.original.filter_city
|
||||
@@ -312,11 +273,9 @@ export default function ChannelPage() {
|
||||
header: "网关地址",
|
||||
accessorKey: "host",
|
||||
cell: ({ row }) => {
|
||||
const ip = row.original.host
|
||||
const port = row.original.port
|
||||
return (
|
||||
<span>
|
||||
{ip}:{port}{" "}
|
||||
{row.original.host}:{row.original.port}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
@@ -325,11 +284,9 @@ export default function ChannelPage() {
|
||||
header: "认证方式",
|
||||
cell: ({ row }) => {
|
||||
const channel = row.original
|
||||
|
||||
const hasWhitelist =
|
||||
channel.whitelists && channel.whitelists.trim() !== ""
|
||||
const hasAuth = channel.username && channel.password
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1 min-w-0">
|
||||
{hasWhitelist ? (
|
||||
|
||||
Reference in New Issue
Block a user