修复实名认证后的状态更新 & 使用sse方式解决支付轮询两次完成问题 & 修复账户总览图标展示 & 白名单新增获取当前用户IP地址功能 & 购买套餐添加白名单链接
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
import Page from '@/components/page'
|
||||
import DataTable from '@/components/data-table'
|
||||
import {format, parseISO} from 'date-fns'
|
||||
|
||||
import {getClientIp} from '@/actions/ip'
|
||||
const schema = z.object({
|
||||
host: z.string().min(1, {message: 'IP地址不能为空'}),
|
||||
remark: z.string().optional(),
|
||||
@@ -226,6 +226,27 @@ export default function WhitelistPage(props: WhitelistPageProps) {
|
||||
return <div className="flex items-center justify-center h-full">加载失败,请重试</div>
|
||||
}
|
||||
|
||||
const getCurrentIP = async () => {
|
||||
setWait(true)
|
||||
|
||||
try {
|
||||
const result = await getClientIp()
|
||||
|
||||
if (result.ip) {
|
||||
form.setValue('host', result.ip)
|
||||
toast.success('已获取当前IP地址')
|
||||
}
|
||||
else {
|
||||
toast.error('获取失败', {
|
||||
description: result.error || '请手动输入IP地址',
|
||||
})
|
||||
}
|
||||
}
|
||||
finally {
|
||||
setWait(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
||||
@@ -236,14 +257,6 @@ export default function WhitelistPage(props: WhitelistPageProps) {
|
||||
添加白名单
|
||||
{data.total >= MAX_WHITELIST_COUNT && '(已达上限)'}
|
||||
</Button>
|
||||
{/* <Button
|
||||
theme="fail"
|
||||
className="ml-2"
|
||||
disabled={selection.size === 0 || wait}
|
||||
onClick={() => confirmRemove()}>
|
||||
<Trash2/>
|
||||
删除选中
|
||||
</Button> */}
|
||||
</section>
|
||||
|
||||
{/* 数据表 */}
|
||||
@@ -306,7 +319,23 @@ export default function WhitelistPage(props: WhitelistPageProps) {
|
||||
onSubmit={onSubmit}>
|
||||
<FormField name="host" label="IP地址">
|
||||
{({id, field}) => (
|
||||
<Input {...field} id={id} placeholder="输入IP地址"/>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
{...field}
|
||||
id={id}
|
||||
placeholder="输入IP地址"
|
||||
className="flex-1"
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={getCurrentIP}
|
||||
disabled={wait}
|
||||
className="shrink-0"
|
||||
theme="outline"
|
||||
>
|
||||
{wait ? <Loader2 className="w-4 h-4 animate-spin"/> : '获取当前IP'}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</FormField>
|
||||
<FormField name="remark" label="备注">
|
||||
|
||||
Reference in New Issue
Block a user