套餐添加操作列 & 登录后已实名的更新状态显示 &更新脚本的远程仓库地址

This commit is contained in:
Eamon-meng
2026-04-23 13:43:06 +08:00
parent d9cd5eb41b
commit 1e76275f04
5 changed files with 68 additions and 28 deletions

View File

@@ -8,7 +8,7 @@ import zod from 'zod'
import {toast} from 'sonner'
import {useStatus} from '@/lib/states'
import {ExtraResp} from '@/lib/api'
import {listResourceLong, listResourceShort} from '@/actions/resource'
import {listResourceLong, listResourceShort, updateCheckip} from '@/actions/resource'
import DataTable from '@/components/data-table'
import {ColumnDef} from '@tanstack/react-table'
import {Resource} from '@/lib/models/resource'
@@ -21,6 +21,7 @@ import {
isValidResourceType,
ResourceTypeBadge,
} from './utils'
import {Button} from '@/components/ui/button'
const filterSchema = zod.object({
resource_no: zod.string().optional().default(''),
@@ -130,6 +131,27 @@ export default function ResourceList({resourceType}: ResourceListProps) {
})
}
const handleCheckipChange = async (id: number, currentCheckip: boolean) => {
try {
const result = await updateCheckip({
id: id,
checkip: !currentCheckip,
})
if (result.success) {
toast.success(`IP检查已${!currentCheckip ? '启用' : '停用'}`)
await refresh(data.page, data.size)
}
else {
throw new Error(result.message || '操作失败')
}
}
catch (e) {
toast.error(e instanceof Error ? e.message : '更新IP检查状态失败')
}
}
console.log(data.list, 'data.list')
// 表格列定义
const columns = useMemo<ColumnDef<Resource<1> | Resource<2>>[]>(() => {
const resourceKey = isLong ? 'long' : 'short'
@@ -218,7 +240,11 @@ export default function ResourceList({resourceType}: ResourceListProps) {
{
header: '开通时间',
cell: ({row}) => formatDateTime(row.original.created_at),
},
}, // 短效资源增加到期时间列
!isLong ? {
header: '到期时间',
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
} : undefined,
{
header: '状态',
cell: ({row}) => {
@@ -231,25 +257,21 @@ export default function ResourceList({resourceType}: ResourceListProps) {
},
},
{
header: 'IP检查状态',
header: '操作',
cell: ({row}) => {
const checkip = row.original.checkip
return (
<span className={checkip ? 'text-green-500' : 'text-red-500'}>
{checkip ? '启用IP检查' : '停用IP检查'}
</span>
<Button
theme="default"
className="h-7 px-3 text-sm"
onClick={() => handleCheckipChange(row.original.id, row.original.checkip)}
>
{checkip ? '停用IP检查' : '启用IP检查'}
</Button>
)
},
},
]
// 短效资源增加到期时间列
if (!isLong) {
baseColumns.push({
header: '到期时间',
cell: ({row}) => formatDateTime((row.original as Resource<1>).short.expire_at),
})
}
].filter(Boolean)
return baseColumns
}, [isLong])