添加资源界面加载态和错误
This commit is contained in:
@@ -3,6 +3,13 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { ResourceCard } from "./components/ResourceCard";
|
import { ResourceCard } from "./components/ResourceCard";
|
||||||
import { ResourceApi } from "@/lib/api";
|
import { ResourceApi } from "@/lib/api";
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
AlertDescription,
|
||||||
|
AlertTitle,
|
||||||
|
} from "@/components/ui/alert"
|
||||||
|
import { AlertCircle } from "lucide-react";
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
export default function Resources() {
|
export default function Resources() {
|
||||||
const { data, isLoading, error } = useSWR(
|
const { data, isLoading, error } = useSWR(
|
||||||
@@ -16,8 +23,27 @@ export default function Resources() {
|
|||||||
<p className="mt-4 md:mt-8 mx-3 text-zinc-400 text-sm text-center duration-300">请在浏览此部分内容前阅读并同意
|
<p className="mt-4 md:mt-8 mx-3 text-zinc-400 text-sm text-center duration-300">请在浏览此部分内容前阅读并同意
|
||||||
<a className="text-zinc-600">《使用条款和隐私政策》</a>
|
<a className="text-zinc-600">《使用条款和隐私政策》</a>
|
||||||
,继续使用或浏览表示您接受协议条款。</p>
|
,继续使用或浏览表示您接受协议条款。</p>
|
||||||
|
{
|
||||||
|
error && (
|
||||||
|
<div className="mt-10 mx-5">
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertCircle className="h-4 w-4" />
|
||||||
|
<AlertTitle>出错了</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
{error.message}
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
<div className="mt-6 sm:mt-10 md:mt-15 w-full flex flex-col md:w-auto md:mx-auto md:grid grid-cols-2 2xl:gap-x-35 lg:gap-x-20 gap-x-10 lg:gap-y-10 gap-y-5 sm:mb-10 duration-300">
|
<div className="mt-6 sm:mt-10 md:mt-15 w-full flex flex-col md:w-auto md:mx-auto md:grid grid-cols-2 2xl:gap-x-35 lg:gap-x-20 gap-x-10 lg:gap-y-10 gap-y-5 sm:mb-10 duration-300">
|
||||||
|
{isLoading && (
|
||||||
|
[...Array(3).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-35 w-full md:w-92 lg:w-100 md:rounded-xl rounded-none duration-300" />
|
||||||
|
))]
|
||||||
|
)}
|
||||||
|
|
||||||
{data && data.map((resource) => (
|
{data && data.map((resource) => (
|
||||||
<ResourceCard
|
<ResourceCard
|
||||||
key={resource.id}
|
key={resource.id}
|
||||||
|
|||||||
Reference in New Issue
Block a user