|
@@ -1,24 +1,24 @@
|
|
|
-"use server";
|
|
|
+"use client";
|
|
|
import { GroupType, PrizeTypes } from "@/api/home";
|
|
|
-import { server } from "@/utils/server";
|
|
|
-import dynamic from "next/dynamic";
|
|
|
+import { server } from "@/utils/client";
|
|
|
import React from "react";
|
|
|
+import HomeTabs from "./_home/HomeTabs";
|
|
|
|
|
|
-const HomeTabs = dynamic(() => import("./_home/HomeTabs"));
|
|
|
+// const HomeTabs = () => import("./_home/HomeTabs");
|
|
|
|
|
|
const TIME = 0;
|
|
|
-const getGames = React.cache(async () => {
|
|
|
+const getGames = async () => {
|
|
|
return server
|
|
|
.request<GroupType[]>({
|
|
|
url: "/v1/api/front/game_list",
|
|
|
method: "POST",
|
|
|
- next: { revalidate: TIME },
|
|
|
+ // next: { revalidate: TIME },
|
|
|
})
|
|
|
.then((res) => {
|
|
|
if (res.code === 200) return res.data;
|
|
|
return [];
|
|
|
});
|
|
|
-});
|
|
|
+};
|
|
|
|
|
|
const getPrizeApi = () => {
|
|
|
return server.request<PrizeTypes[]>({
|
|
@@ -27,11 +27,19 @@ const getPrizeApi = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-export default async function Page(props: any) {
|
|
|
- const group = await getGames();
|
|
|
- console.log(group);
|
|
|
+export default function Page(props: any) {
|
|
|
+ const [group, setGroup] = React.useState<GroupType[]>([]);
|
|
|
|
|
|
+ React.useEffect(() => {
|
|
|
+ getData();
|
|
|
+ }, []);
|
|
|
+ const getData = async () => {
|
|
|
+ const groupData = await getGames();
|
|
|
+ setGroup(groupData);
|
|
|
+ };
|
|
|
+ //const group = await getGames();
|
|
|
// const result = await getPrizeApi();
|
|
|
+ if (!group?.length) return null;
|
|
|
return (
|
|
|
<HomeTabs
|
|
|
tabs={group}
|