提取IP添加主机格式选项功能

This commit is contained in:
Eamon-meng
2026-05-08 11:37:36 +08:00
parent 9dea370a87
commit 84a5e27c05
5 changed files with 95 additions and 11 deletions

View File

@@ -28,10 +28,11 @@ const schema = z.object({
city: z.string().optional(),
regionType: z.enum(['unlimited', 'specific']).default('unlimited'),
isp: z.enum(['all', '1', '2', '3'], {required_error: '请选择运营商'}),
proto: z.enum(['all', '1', '2', '3'], {required_error: '请选择协议'}),
proto: z.enum(['all', '1', '2'], {required_error: '请选择协议'}),
authType: z.enum(['1', '2'], {required_error: '请选择认证方式'}),
distinct: z.enum(['1', '0'], {required_error: '请选择去重选项'}),
format: z.enum(['text', 'json'], {required_error: '请选择导出格式'}),
hostFormat: z.enum(['domain', 'ip'], {required_error: '请选择主机格式'}),
separator: z.string({required_error: '请选择分隔符'}),
breaker: z.string({required_error: '请选择换行符'}),
count: z.number({required_error: '请输入有效的数量'}).min(1),
@@ -53,6 +54,7 @@ export default function Extract(props: ExtractProps) {
authType: '1',
count: 1,
distinct: '1',
hostFormat: 'domain',
format: 'text',
breaker: '13,10',
separator: '124',
@@ -163,12 +165,12 @@ const FormFields = memo(() => {
<RadioGroupItem value="1" id={`${id}-v-http`} className="mr-2"/>
<span>HTTP</span>
</FormLabel>
<FormLabel htmlFor={`${id}-v-https`} className="px-3 h-10 border rounded-md flex items-center text-sm">
{/* <FormLabel htmlFor={`${id}-v-https`} className="px-3 h-10 border rounded-md flex items-center text-sm">
<RadioGroupItem value="2" id={`${id}-v-https`} className="mr-2"/>
<span>HTTPS</span>
</FormLabel>
</FormLabel> */}
<FormLabel htmlFor={`${id}-v-socks5`} className="px-3 h-10 border rounded-md flex items-center text-sm">
<RadioGroupItem value="3" id={`${id}-v-socks5`} className="mr-2"/>
<RadioGroupItem value="2" id={`${id}-v-socks5`} className="mr-2"/>
<span>SOCKS5</span>
</FormLabel>
</RadioGroup>
@@ -233,6 +235,26 @@ const FormFields = memo(() => {
)}
</FormField>
{/* 主机格式 */}
<FormField name="hostFormat" className="md:max-w-[calc(160px*2+1rem)]" label="主机格式" classNames={{label: 'max-md:text-sm'}}>
{({id, field}) => (
<RadioGroup
onValueChange={field.onChange}
defaultValue={field.value}
className="flex gap-4"
>
<FormLabel htmlFor={`${id}-v-domain`} className="px-3 h-10 flex-1 border rounded-md flex items-center text-sm">
<RadioGroupItem value="domain" id={`${id}-v-domain`} className="mr-2"/>
<span></span>
</FormLabel>
<FormLabel htmlFor={`${id}-v-ip`} className="px-3 h-10 flex-1 border rounded-md flex items-center text-sm">
<RadioGroupItem value="ip" id={`${id}-v-ip`} className="mr-2"/>
<span>IP</span>
</FormLabel>
</RadioGroup>
)}
</FormField>
{/* 分隔符 */}
<FormField name="separator" className="md:max-w-[calc(160px*3+1rem*2)]" label="分隔符" classNames={{label: 'max-md:text-sm'}}>
{({id, field}) => (
@@ -648,7 +670,7 @@ function ApplyLink() {
}
function link(values: Schema) {
const {resource, prov, city, isp, proto, authType, distinct, format: formatType, separator, breaker, count} = values
const {resource, prov, city, isp, proto, authType, distinct, format: formatType, hostFormat, separator, breaker, count} = values
const sp = new URLSearchParams()
if (resource) sp.set('i', String(resource))
@@ -660,6 +682,7 @@ function link(values: Schema) {
if (isp != 'all') sp.set('s', isp)
sp.set('d', distinct)
sp.set('rt', formatType)
sp.set('rh', hostFormat)
sp.set('rs', separator)
sp.set('rb', breaker)
sp.set('n', String(count))