修复实名认证后的状态更新 & 使用sse方式解决支付轮询两次完成问题 & 修复账户总览图标展示 & 白名单新增获取当前用户IP地址功能 & 购买套餐添加白名单链接
This commit is contained in:
@@ -50,6 +50,8 @@ export default function Charts({initialData}: ChartsProps) {
|
||||
resource_no: value.resource_no ?? '',
|
||||
create_after: value.create_after ?? sevenDaysAgo,
|
||||
create_before: value.create_before ?? today,
|
||||
// create_after: value.create_after ? format(value.create_after, 'yyyy-MM-dd') : format(sevenDaysAgo, 'yyyy-MM-dd'),
|
||||
// create_before: value.create_before ? format(value.create_before, 'yyyy-MM-dd') : format(today, 'yyyy-MM-dd'),
|
||||
}
|
||||
|
||||
const resp = await statisticsResourceUsage(res)
|
||||
@@ -67,6 +69,7 @@ export default function Charts({initialData}: ChartsProps) {
|
||||
date: item.date,
|
||||
count: item.count,
|
||||
}))
|
||||
formattedData.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime())
|
||||
|
||||
setSubmittedData(formattedData)
|
||||
},
|
||||
@@ -147,7 +150,11 @@ type DashboardChartProps = {
|
||||
}
|
||||
|
||||
function DashboardChart(props: DashboardChartProps) {
|
||||
const chartData = props.data.map((item) => {
|
||||
const sortedData = [...props.data].sort((a, b) => {
|
||||
return new Date(a.date).getTime() - new Date(b.date).getTime()
|
||||
})
|
||||
|
||||
const chartData = sortedData.map((item) => {
|
||||
const date = new Date(item.date.split('T')[0])
|
||||
return {
|
||||
...item,
|
||||
|
||||
@@ -169,12 +169,12 @@ export default function IdentifyPage(props: IdentifyPageProps) {
|
||||
<div className="flex flex-col gap-4 items-center">
|
||||
<canvas ref={canvas} width={256} height={256}/>
|
||||
<p className="text-sm text-gray-600">请扫码完成认证</p>
|
||||
{/* <Button onClick={async () => {
|
||||
<Button onClick={async () => {
|
||||
await refreshProfile()
|
||||
setOpenDialog(false)
|
||||
}}>
|
||||
已完成认证
|
||||
</Button> */}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
|
||||
@@ -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