|
import Head from "next/head"; |
|
import Container from "@mui/material/Container"; |
|
import { Stack } from "@mui/material"; |
|
import { DividerBox } from "@/components/base/boxes"; |
|
import { useCallback, useEffect, useState } from "react"; |
|
import { HF_FileEntry, HFRes } from "@/types"; |
|
import { basename } from "path"; |
|
|
|
export default function Home() { |
|
const [repo, setRepo] = useState('https://huggingface.co/datasets/banned-historical-archives/wenhuibao_disk/tree/main'); |
|
const [entries, setEntries] = useState<HF_FileEntry[]>([]) |
|
const [next, setNext] = useState('') |
|
const update = useCallback( |
|
(async () => { |
|
const res = (await ((await fetch('/api/get_file_list')).json())) as HFRes; |
|
setEntries(res.entries); |
|
setNext(res.nextURL!); |
|
}), [] |
|
) |
|
useEffect(() => { |
|
update() |
|
}, []) |
|
return ( |
|
<> |
|
<Head> |
|
<title>nextjs-docker-starter</title> |
|
<link rel="icon" href="/favicon.ico" /> |
|
<meta name="description" content="Next.js in Docker on 🤗 Spaces" /> |
|
</Head> |
|
|
|
<Container component="main" sx={{ minHeight: "90vh" }}> |
|
<Stack spacing={4} useFlexGap> |
|
<input value={repo} onChange={e => setRepo(e.target.value)}/> |
|
{entries.map(i => <div key={i.path}> |
|
{basename(i.path)} |
|
</div>)} |
|
<button onClick={() => { |
|
}}>more</button> |
|
</Stack> |
|
</Container> |
|
|
|
</> |
|
); |
|
} |
|
|