Files
cstb-next/src/app/page.tsx

41 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-11-11 10:04:00 +08:00
"use client"
2024-09-20 23:15:42 +08:00
2024-11-12 15:03:19 +08:00
import React from "react"
2024-11-11 10:04:00 +08:00
import { useRouter } from "next/navigation"
2024-11-12 15:03:19 +08:00
import { open } from "@tauri-apps/plugin-dialog"
2024-09-20 23:15:42 +08:00
const Home = () => {
2024-11-11 10:04:00 +08:00
const router = useRouter()
2024-11-12 15:03:19 +08:00
const [file, setFile] = React.useState<string | null>("")
const openFile = async () => {
const filePath = await open({
multiple: true,
directory: false,
})
setFile(filePath?.join("\n") || " ")
}
2024-09-20 23:15:42 +08:00
return (
2024-09-21 01:05:40 +08:00
<main
className="flex flex-col items-center justify-center w-full h-screen gap-6"
2024-09-21 01:05:40 +08:00
data-tauri-drag-region
>
2024-11-12 15:03:19 +08:00
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">CS </h1>
2024-11-11 10:04:00 +08:00
<button
type="button"
onClick={() => router.push("/home")}
className="px-4 py-1 rounded bg-zinc-200"
>
2024-09-20 23:15:42 +08:00
</button>
2024-11-12 15:03:19 +08:00
<button type="button" onClick={openFile} className="px-4 py-1 text-white bg-blue-500 rounded">
</button>
<p className="text-center bg-zinc-50">{file}</p>
2024-09-20 23:15:42 +08:00
</main>
2024-09-21 01:05:40 +08:00
)
2024-11-11 10:04:00 +08:00
}
2024-09-20 23:15:42 +08:00
2024-11-11 10:04:00 +08:00
export default Home