From 3a2fbe29fb9e1ede4edee20744d8e69c7caee493 Mon Sep 17 00:00:00 2001 From: Eamon-meng <17516219072@163.com> Date: Fri, 22 May 2026 16:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E5=8F=96ip=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E4=BC=A0=E5=8F=82=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 +- src/actions/channel.ts | 13 ++++++ src/app/(api)/proxies/route.ts | 44 ++++++++++++++------- src/components/composites/extract/index.tsx | 6 +-- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/.env.example b/.env.example index 8438d07..df56996 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ # 开发环境配置 -API_BASE_URL=http://192.168.3.42:8080 +API_BASE_URL=http://192.168.0.15:8080 CLIENT_ID=web CLIENT_SECRET=web diff --git a/src/actions/channel.ts b/src/actions/channel.ts index 3dd2c13..1b69b7c 100644 --- a/src/actions/channel.ts +++ b/src/actions/channel.ts @@ -36,3 +36,16 @@ export async function createChannels(params: { }) { return callPublic('/api/channel/create', params) } + +export async function createChannelsV2(params: { + resource_no: string + protocol: number + auth_type: number + count: number + prov?: string + city?: string + isp?: number + host_format?: number +}) { + return callPublic('/api/channel/create/v2', params) +} diff --git a/src/app/(api)/proxies/route.ts b/src/app/(api)/proxies/route.ts index 06826e7..d6b9f31 100644 --- a/src/app/(api)/proxies/route.ts +++ b/src/app/(api)/proxies/route.ts @@ -1,11 +1,12 @@ import {NextRequest, NextResponse} from 'next/server' -import {createChannels} from '@/actions/channel' +import {createChannels, createChannelsV2} from '@/actions/channel' export async function GET(req: NextRequest) { const params = req.nextUrl.searchParams try { - const resource_id = params.get('i') - if (!resource_id) { + const resourceParam = params.get('i') + + if (!resourceParam) { throw new Error('需要指定资源ID') } let protocol = params.get('x') @@ -24,17 +25,32 @@ export async function GET(req: NextRequest) { const city = params.get('b') || undefined const isp = params.get('s') || undefined const hostFormat = params.get('rh') || 'domain' - - const result = await createChannels({ - resource_id: Number(resource_id), - auth_type: Number(auth_type), - protocol: Number(protocol), - count: Number(count), - prov, - city, - isp: Number(isp), - host_format: hostFormat === 'domain' ? 1 : 2, - }) + const isNumeric = /^\d+$/.test(resourceParam) + let result + if (!isNumeric) { + result = await createChannelsV2({ + resource_no: resourceParam, + auth_type: Number(auth_type), + protocol: Number(protocol), + count: Number(count), + prov, + city, + isp: Number(isp), + host_format: hostFormat === 'domain' ? 1 : 2, + }) + } + else { + result = await createChannels({ + resource_id: Number(resourceParam), + auth_type: Number(auth_type), + protocol: Number(protocol), + count: Number(count), + prov, + city, + isp: Number(isp), + host_format: hostFormat === 'domain' ? 1 : 2, + }) + } if (!result.success) { throw new Error(result.message) diff --git a/src/components/composites/extract/index.tsx b/src/components/composites/extract/index.tsx index 1334068..6bebc67 100644 --- a/src/components/composites/extract/index.tsx +++ b/src/components/composites/extract/index.tsx @@ -23,7 +23,7 @@ import Link from 'next/link' import {useProfileStore} from '@/components/stores/profile' const schema = z.object({ - resource: z.number({required_error: '请选择套餐'}), + resource: z.string({required_error: '请选择套餐'}), prov: z.string().optional(), city: z.string().optional(), regionType: z.enum(['unlimited', 'specific']).default('unlimited'), @@ -374,7 +374,7 @@ function SelectResource() { {({field}) => (