完善提取页面错误提示,优化复制链接和打开链接操作
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
|
提取后刷新提取页套餐可用余量
|
||||||
|
|
||||||
|
提取 ip 认证
|
||||||
|
|
||||||
保存客户端信息时用 jwt 序列化
|
保存客户端信息时用 jwt 序列化
|
||||||
|
|
||||||
登录后刷新 profile
|
登录后刷新 profile
|
||||||
|
|||||||
@@ -63,6 +63,6 @@ export async function GET(req: NextRequest) {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('Error creating channels:', error)
|
console.error('Error creating channels:', error)
|
||||||
return NextResponse.json({error: error})
|
return NextResponse.json({error: (error as Error).message})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {Button} from '@/components/ui/button'
|
|||||||
import {useForm} from 'react-hook-form'
|
import {useForm} from 'react-hook-form'
|
||||||
import {Alert, AlertTitle} from '@/components/ui/alert'
|
import {Alert, AlertTitle} from '@/components/ui/alert'
|
||||||
import {Box, CircleAlert, CopyIcon, ExternalLinkIcon, Loader, Timer} from 'lucide-react'
|
import {Box, CircleAlert, CopyIcon, ExternalLinkIcon, Loader, Timer} from 'lucide-react'
|
||||||
import {useEffect, useMemo, useState} from 'react'
|
import {useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {useStatus} from '@/lib/states'
|
import {useStatus} from '@/lib/states'
|
||||||
import {allResource} from '@/actions/resource'
|
import {allResource} from '@/actions/resource'
|
||||||
import {Resource, name} from '@/lib/models'
|
import {Resource, name} from '@/lib/models'
|
||||||
@@ -92,8 +92,22 @@ export default function Extract(props: ExtractProps) {
|
|||||||
return `/proxies?${sp.toString()}`
|
return `/proxies?${sp.toString()}`
|
||||||
}, [resource, authType, proto, isp, distinct, formatType, separator, breaker, count, prov, city])
|
}, [resource, authType, proto, isp, distinct, formatType, separator, breaker, count, prov, city])
|
||||||
|
|
||||||
const onSubmit = (values: z.infer<typeof schema>) => {
|
const type = useRef<'copy' | 'open'>('open')
|
||||||
console.log(values)
|
const onSubmit = async (values: z.infer<typeof schema>) => {
|
||||||
|
console.log('222', type.current)
|
||||||
|
switch (type.current) {
|
||||||
|
case 'copy':
|
||||||
|
console.log('copy')
|
||||||
|
const url = new URL(window.location.href).origin
|
||||||
|
await navigator.clipboard.writeText(`${url}${params}`)
|
||||||
|
toast.success('链接已复制到剪贴板')
|
||||||
|
break
|
||||||
|
case 'open':
|
||||||
|
console.log('open')
|
||||||
|
window.open(params, '_blank')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
console.log('333')
|
||||||
}
|
}
|
||||||
|
|
||||||
const getResources = async () => {
|
const getResources = async () => {
|
||||||
@@ -269,11 +283,11 @@ export default function Extract(props: ExtractProps) {
|
|||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormLabel htmlFor={`${id}-v-mobile`} className={`px-3 h-10 border rounded-md flex items-center w-40 text-sm`}>
|
<FormLabel htmlFor={`${id}-v-mobile`} className={`px-3 h-10 border rounded-md flex items-center w-40 text-sm`}>
|
||||||
<RadioGroupItem value="2" id={`${id}-v-mobile`}/>
|
<RadioGroupItem value="2" id={`${id}-v-mobile`}/>
|
||||||
<span>移动</span>
|
<span>联通</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormLabel htmlFor={`${id}-v-unicom`} className={`px-3 h-10 border rounded-md flex items-center w-40 text-sm`}>
|
<FormLabel htmlFor={`${id}-v-unicom`} className={`px-3 h-10 border rounded-md flex items-center w-40 text-sm`}>
|
||||||
<RadioGroupItem value="3" id={`${id}-v-unicom`}/>
|
<RadioGroupItem value="3" id={`${id}-v-unicom`}/>
|
||||||
<span>联通</span>
|
<span>移动</span>
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
)}
|
)}
|
||||||
@@ -453,23 +467,14 @@ export default function Extract(props: ExtractProps) {
|
|||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={async () => {
|
onClick={() => type.current = 'copy'}
|
||||||
if (!form.formState.isValid) return
|
|
||||||
const url = new URL(window.location.href).origin
|
|
||||||
await navigator.clipboard.writeText(`${url}${params}`)
|
|
||||||
toast.success('链接已复制到剪贴板')
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<CopyIcon/>
|
<CopyIcon/>
|
||||||
<span>复制链接</span>
|
<span>复制链接</span>
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={async () => {
|
onClick={() => type.current = 'open'}
|
||||||
if (!form.formState.isValid) return
|
|
||||||
window.open(params, '_blank')
|
|
||||||
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<ExternalLinkIcon/>
|
<ExternalLinkIcon/>
|
||||||
<span>打开链接</span>
|
<span>打开链接</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user