修改提取ip时的传参方式
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -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,9 +25,11 @@ 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) {
|
||||||
|
result = await createChannelsV2({
|
||||||
|
resource_no: resourceParam,
|
||||||
auth_type: Number(auth_type),
|
auth_type: Number(auth_type),
|
||||||
protocol: Number(protocol),
|
protocol: Number(protocol),
|
||||||
count: Number(count),
|
count: Number(count),
|
||||||
@@ -35,6 +38,19 @@ export async function GET(req: NextRequest) {
|
|||||||
isp: Number(isp),
|
isp: Number(isp),
|
||||||
host_format: hostFormat === 'domain' ? 1 : 2,
|
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)
|
||||||
|
|||||||
@@ -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 && (
|
||||||
|
|||||||
Reference in New Issue
Block a user