diff --git a/index.html b/index.html
index a3d5856..7383981 100644
--- a/index.html
+++ b/index.html
@@ -3,6 +3,7 @@
+
eoefans-web
diff --git a/src/components/masonry/index.tsx b/src/components/masonry/index.tsx
index 6c577b1..9616d23 100644
--- a/src/components/masonry/index.tsx
+++ b/src/components/masonry/index.tsx
@@ -3,6 +3,8 @@ import { Masonry as Masonic_masonry, useInfiniteLoader } from "masonic";
import Image from "@components/image";
import { FetchNewImages } from "@utils/faker/index";
import { SingleRun } from "@utils/index";
+import { fetchVideos } from "@utils/fetch";
+import { nanoid } from "nanoid";
export default function Masonry() {
const [lists, setLists] = useState<
{
@@ -16,14 +18,27 @@ export default function Masonry() {
stopIndex: number,
currentItems: any[]
) => {
- const res = await FetchNewImages(stopIndex - startIndex);
+ // const res = await FetchNewImages(stopIndex - startIndex);
+ const res = await fetchVideos({
+ order: "view",
+ page: 1,
+ }),
+ data = res.data.result;
+
setLists((lists) => {
- console.log({
- startIndex,
- stopIndex,
- currentNum: lists.length + res.length,
- });
- return [...lists, ...res];
+ // console.log({
+ // startIndex,
+ // stopIndex,
+ // currentNum: lists.length + res.length,
+ // });
+ return [
+ ...lists,
+ ...data.map((item) => ({
+ image: item.face,
+ name: item.name,
+ id: nanoid(10),
+ })),
+ ];
});
};
const fetchMoreItemsHandler = useCallback(SingleRun(fetchMoreItems), [
diff --git a/src/routers/read.tsx b/src/routers/read.tsx
index 4feac19..fb5bcb7 100644
--- a/src/routers/read.tsx
+++ b/src/routers/read.tsx
@@ -1,3 +1,12 @@
+import getrealtiveTime from "@utils/time";
export default function ReadPage() {
- return 这里是read路由页面
;
+ const time = getrealtiveTime(1672570020000);
+ return (
+ <>
+ 这里是read路由页面
+
+ 1672570020000->{time}
+
+ >
+ );
}
diff --git a/src/utils/fetch/index.ts b/src/utils/fetch/index.ts
index 9b88a38..665de25 100644
--- a/src/utils/fetch/index.ts
+++ b/src/utils/fetch/index.ts
@@ -11,6 +11,8 @@ import { IFetchVideoParams, RFetchVideoRes } from "./fetchtype";
/**
* video视频数据获取接口
*/
-export function fetchVideos(params: IFetchVideoParams): RFetchVideoRes {
- return videoJson;
+export function fetchVideos(
+ params: IFetchVideoParams
+): Promise {
+ return Promise.resolve(videoJson);
}
diff --git a/src/utils/time/index.ts b/src/utils/time/index.ts
index 27eaf92..e0cb17d 100644
--- a/src/utils/time/index.ts
+++ b/src/utils/time/index.ts
@@ -5,5 +5,5 @@ dayJs.locale("zh-cn");
dayJs.extend(realtiveTime);
export default function getrealtiveTime(time: number): string {
- return dayJs(time).toNow();
+ return dayJs(time).fromNow();
}