修改提取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_ID=web
CLIENT_SECRET=web CLIENT_SECRET=web

View File

@@ -36,3 +36,16 @@ export async function createChannels(params: {
}) { }) {
return callPublic<CreateChannelsResp[]>('/api/channel/create', 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 {NextRequest, NextResponse} from 'next/server'
import {createChannels} from '@/actions/channel' import {createChannels, createChannelsV2} from '@/actions/channel'
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
const params = req.nextUrl.searchParams const params = req.nextUrl.searchParams
try { try {
const resource_id = params.get('i') const resourceParam = params.get('i')
if (!resource_id) {
if (!resourceParam) {
throw new Error('需要指定资源ID') throw new Error('需要指定资源ID')
} }
let protocol = params.get('x') let protocol = params.get('x')
@@ -24,17 +25,32 @@ export async function GET(req: NextRequest) {
const city = params.get('b') || undefined const city = params.get('b') || undefined
const isp = params.get('s') || undefined const isp = params.get('s') || undefined
const hostFormat = params.get('rh') || 'domain' const hostFormat = params.get('rh') || 'domain'
const isNumeric = /^\d+$/.test(resourceParam)
const result = await createChannels({ let result
resource_id: Number(resource_id), if (!isNumeric) {
auth_type: Number(auth_type), result = await createChannelsV2({
protocol: Number(protocol), resource_no: resourceParam,
count: Number(count), auth_type: Number(auth_type),
prov, protocol: Number(protocol),
city, count: Number(count),
isp: Number(isp), prov,
host_format: hostFormat === 'domain' ? 1 : 2, 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) { if (!result.success) {
throw new Error(result.message) throw new Error(result.message)

View File

@@ -23,7 +23,7 @@ import Link from 'next/link'
import {useProfileStore} from '@/components/stores/profile' import {useProfileStore} from '@/components/stores/profile'
const schema = z.object({ const schema = z.object({
resource: z.number({required_error: '请选择套餐'}), resource: z.string({required_error: '请选择套餐'}),
prov: z.string().optional(), prov: z.string().optional(),
city: z.string().optional(), city: z.string().optional(),
regionType: z.enum(['unlimited', 'specific']).default('unlimited'), regionType: z.enum(['unlimited', 'specific']).default('unlimited'),
@@ -374,7 +374,7 @@ function SelectResource() {
{({field}) => ( {({field}) => (
<Select <Select
value={field.value ? String(field.value) : undefined} 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"> <SelectTrigger className="min-h-10 h-auto w-full">
<SelectValue placeholder="选择套餐"/> <SelectValue placeholder="选择套餐"/>
@@ -398,7 +398,7 @@ function SelectResource() {
{resources.map(resource => ( {resources.map(resource => (
<SelectItem <SelectItem
key={resource.id} key={resource.id}
value={String(resource.id)} value={String(resource.resource_no)}
className="p-3"> className="p-3">
<div className="flex flex-col gap-2 w-72"> <div className="flex flex-col gap-2 w-72">
{resource.type === 1 && resource.short.type === 1 && ( {resource.type === 1 && resource.short.type === 1 && (