From dd44bbd41e2faec1623c0b88f19c8a0f92a4c8bf Mon Sep 17 00:00:00 2001 From: Purp1e <438518244@qq.com> Date: Tue, 12 Nov 2024 15:03:19 +0800 Subject: [PATCH] [test] open file api --- bun.lockb | Bin 242730 -> 242730 bytes package.json | 2 +- src-tauri/Cargo.toml | 2 +- src/app/page.tsx | 20 +++++++++++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bun.lockb b/bun.lockb index ab50a328834419353166fd4128e49d0e5fe780e3..c3197fb7f374c1b5663e6c4d27b483d28db369b8 100755 GIT binary patch delta 29 lcmZ4Wf^XFezJ?aYElh3&taU~V3=Hkw1x(w$3z+Xa0|2OG3PJz? delta 29 lcmZ4Wf^XFezJ?aYElh3&tVVhUdWP-Z1x(w$3z+Xa0|2UP3V{Fs diff --git a/package.json b/package.json index a91bf5c..711f7c3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 917ea08..05a92ab 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -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" diff --git a/src/app/page.tsx b/src/app/page.tsx index f4aad10..a4504fd 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -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("") + + const openFile = async () => { + const filePath = await open({ + multiple: true, + directory: false, + }) + + setFile(filePath?.join("\n") || " ") + } return (
-

- CS 工具箱 -

+

CS 工具箱

+ +

{file}

) }