修复实名认证后的状态更新 & 使用sse方式解决支付轮询两次完成问题 & 修复账户总览图标展示 & 白名单新增获取当前用户IP地址功能 & 购买套餐添加白名单链接

This commit is contained in:
Eamon-meng
2025-12-04 14:43:13 +08:00
parent 591177e7a1
commit a1c80ba588
8 changed files with 128 additions and 77 deletions

View File

@@ -75,8 +75,11 @@ export default function Extract(props: ExtractProps) {
<Alert variant="warn" className="flex items-center">
<CircleAlert/>
<AlertTitle className="flex">IP前需要将本机IP添加到白名单后才可使用</AlertTitle>
<Link href="/admin/whitelist">
<Button ><Plus/></Button>
<Link
href="/admin/whitelist"
className="text-blue-600 hover:text-blue-800 hover:underline font-medium ml-2"
>
</Link>
</Alert>
@@ -526,12 +529,16 @@ function ApplyLink() {
const handler = form.handleSubmit(
// eslint-disable-next-line react-hooks/refs
async (values: z.infer<typeof schema>) => {
console.log(values, 'values')
const params = link(values)
console.log(params, 'paramsparams')
switch (type.current) {
case 'copy':
const url = new URL(window.location.href).origin
const text = `${url}${params}`
console.log(text, 'text')
// 使用 clipboard API 复制链接
let copied = false

View File

@@ -33,33 +33,28 @@ export function PaymentModal(props: PaymentModalProps) {
}
}
// 轮询检查支付状态
// SSE处理方式检查支付状态
useEffect(() => {
const pollInterval = 2000
const maxRetries = 30
let retries = 0
const interval = setInterval(async () => {
try {
await props.onConfirm(false)
return
const eventSource = new EventSource(
`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/trade/check?trade_no=${props.inner_no}&method=${props.method}`,
)
eventSource.onmessage = async (event) => {
console.log(event, 'eventeventevent')
switch (event.data) {
case '1':
props.onConfirm?.(true)
case '2':
props.onClose?.()
}
catch (error) {
console.error('支付状态检查失败:', error)
}
finally {
console.log('进入轮询支付状态')
retries++
if (retries >= maxRetries) {
clearInterval(interval)
}
}
}, pollInterval)
}
eventSource.onerror = (error) => {
console.error('SSE 连接错误:', error)
}
return () => {
clearInterval(interval)
eventSource.close()
}
}, [props])
}, [props.inner_no, props.method, props.onConfirm])
return (
<Dialog