[test] open file api
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
"@reactuses/core": "5.0.23",
|
||||
"@tauri-apps/api": "2.1.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.0.0",
|
||||
"@tauri-apps/plugin-dialog": "2.0.1",
|
||||
"@tauri-apps/plugin-dialog": "~2",
|
||||
"@tauri-apps/plugin-fs": "2.0.0",
|
||||
"@tauri-apps/plugin-global-shortcut": "2.0.0",
|
||||
"@tauri-apps/plugin-http": "2.0.1",
|
||||
|
||||
@@ -23,7 +23,7 @@ tauri = { version = "2.1.0", features = [ "macos-private-api",
|
||||
window-vibrancy = "0.5.2"
|
||||
tauri-plugin-process = "2.0.1"
|
||||
tauri-plugin-fs = "2.0.3"
|
||||
tauri-plugin-dialog = "2.0.3"
|
||||
tauri-plugin-dialog = "2"
|
||||
tauri-plugin-os = "2.0.1"
|
||||
tauri-plugin-clipboard-manager = "2.0.2"
|
||||
tauri-plugin-shell = "2.0.2"
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
"use client"
|
||||
|
||||
import React from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { open } from "@tauri-apps/plugin-dialog"
|
||||
|
||||
const Home = () => {
|
||||
const router = useRouter()
|
||||
const [file, setFile] = React.useState<string | null>("")
|
||||
|
||||
const openFile = async () => {
|
||||
const filePath = await open({
|
||||
multiple: true,
|
||||
directory: false,
|
||||
})
|
||||
|
||||
setFile(filePath?.join("\n") || " ")
|
||||
}
|
||||
return (
|
||||
<main
|
||||
className="flex flex-col items-center justify-center w-full h-screen gap-6"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">
|
||||
CS 工具箱
|
||||
</h1>
|
||||
<h1 className="text-4xl font-bold tracking-wide text-zinc-800">CS 工具箱</h1>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => router.push("/home")}
|
||||
@@ -19,6 +29,10 @@ const Home = () => {
|
||||
>
|
||||
进入
|
||||
</button>
|
||||
<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>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user