完善提取页面错误提示,优化复制链接和打开链接操作
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
## TODO
|
||||
|
||||
提取后刷新提取页套餐可用余量
|
||||
|
||||
提取 ip 认证
|
||||
|
||||
保存客户端信息时用 jwt 序列化
|
||||
|
||||
登录后刷新 profile
|
||||
|
||||
@@ -63,6 +63,6 @@ export async function GET(req: NextRequest) {
|
||||
}
|
||||
catch (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 {Alert, AlertTitle} from '@/components/ui/alert'
|
||||
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 {allResource} from '@/actions/resource'
|
||||
import {Resource, name} from '@/lib/models'
|
||||
@@ -92,8 +92,22 @@ export default function Extract(props: ExtractProps) {
|
||||
return `/proxies?${sp.toString()}`
|
||||
}, [resource, authType, proto, isp, distinct, formatType, separator, breaker, count, prov, city])
|
||||
|
||||
const onSubmit = (values: z.infer<typeof schema>) => {
|
||||
console.log(values)
|
||||
const type = useRef<'copy' | 'open'>('open')
|
||||
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 () => {
|
||||
@@ -269,11 +283,11 @@ export default function Extract(props: ExtractProps) {
|
||||
</FormLabel>
|
||||
<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`}/>
|
||||
<span>移动</span>
|
||||
<span>联通</span>
|
||||
</FormLabel>
|
||||
<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`}/>
|
||||
<span>联通</span>
|
||||
<span>移动</span>
|
||||
</FormLabel>
|
||||
</RadioGroup>
|
||||
)}
|
||||
@@ -453,23 +467,14 @@ export default function Extract(props: ExtractProps) {
|
||||
<div className="flex gap-4">
|
||||
<Button
|
||||
type="submit"
|
||||
onClick={async () => {
|
||||
if (!form.formState.isValid) return
|
||||
const url = new URL(window.location.href).origin
|
||||
await navigator.clipboard.writeText(`${url}${params}`)
|
||||
toast.success('链接已复制到剪贴板')
|
||||
}}
|
||||
onClick={() => type.current = 'copy'}
|
||||
>
|
||||
<CopyIcon/>
|
||||
<span>复制链接</span>
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
onClick={async () => {
|
||||
if (!form.formState.isValid) return
|
||||
window.open(params, '_blank')
|
||||
|
||||
}}
|
||||
onClick={() => type.current = 'open'}
|
||||
>
|
||||
<ExternalLinkIcon/>
|
||||
<span>打开链接</span>
|
||||
|
||||
Reference in New Issue
Block a user