修改提取ip时的传参方式

This commit is contained in:
Eamon-meng
2026-05-22 16:56:35 +08:00
parent 5c236c0b01
commit 3a2fbe29fb
4 changed files with 47 additions and 18 deletions

View File

@@ -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

View File

@@ -36,3 +36,16 @@ export async function createChannels(params: {
}) {
return callPublic<CreateChannelsResp[]>('/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<CreateChannelsResp[]>('/api/channel/create/v2', params)
}

View File

@@ -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)

View File

@@ -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}) => (
<Select
value={field.value ? String(field.value) : undefined}
onValueChange={value => field.onChange(Number(value))}
onValueChange={value => field.onChange(value)}
>
<SelectTrigger className="min-h-10 h-auto w-full">
<SelectValue placeholder="选择套餐"/>
@@ -398,7 +398,7 @@ function SelectResource() {
{resources.map(resource => (
<SelectItem
key={resource.id}
value={String(resource.id)}
value={String(resource.resource_no)}
className="p-3">
<div className="flex flex-col gap-2 w-72">
{resource.type === 1 && resource.short.type === 1 && (