更新资源列表页面
This commit is contained in:
@@ -1,11 +1,51 @@
|
||||
import {ReactNode} from 'react'
|
||||
'use client'
|
||||
import {ReactNode, useEffect, useState} from 'react'
|
||||
import {PageRecord} from '@/lib/api'
|
||||
import {ResourcePss} from '@/lib/models'
|
||||
import {useStatus} from '@/lib/states'
|
||||
import {listResourcePss} from '@/actions/resource'
|
||||
|
||||
export type ResourcesPageProps = {
|
||||
}
|
||||
export type ResourcesPageProps = {}
|
||||
|
||||
export default async function ResourcesPage(props: ResourcesPageProps) {
|
||||
export default function ResourcesPage(props: ResourcesPageProps) {
|
||||
|
||||
// region 数据
|
||||
|
||||
const [status, setStatus] = useStatus()
|
||||
const [data, setData] = useState<PageRecord<ResourcePss>>({
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
list: [],
|
||||
})
|
||||
|
||||
const refresh = async (page: number, size: number) => {
|
||||
setStatus('load')
|
||||
try {
|
||||
const res = await listResourcePss({page, size})
|
||||
setStatus('done')
|
||||
|
||||
if (res.success) {
|
||||
setData(res.data)
|
||||
}
|
||||
else {
|
||||
throw new Error('Failed to load resource pss')
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
setStatus('fail')
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
refresh(1, 10).then()
|
||||
}, [])
|
||||
|
||||
// endregion
|
||||
|
||||
// render
|
||||
return (
|
||||
<main>
|
||||
<main className={`flex-auto bg-white rounded-tl-xl`}>
|
||||
|
||||
</main>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user