From 81d47ea71de645d938027846f4eebdd0b8f91200 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sat, 14 Feb 2026 13:03:31 -0700 Subject: [PATCH] Replace rust version of this with frontend logic --- src-tauri/capabilities/default.json | 6 ++++++ src-tauri/src/lib.rs | 27 --------------------------- src/app/game/page.tsx | 5 ++--- src/app/layout.tsx | 5 ++--- src/lib/Util.ts | 27 +++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 33 deletions(-) create mode 100644 src/lib/Util.ts diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 6a215a8..a94f1a0 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -32,6 +32,12 @@ "allow": [ { "path": "$APPLOCALDATA/game/**" } ] + }, + { + "identifier": "opener:allow-open-path", + "allow": [ + { "path": "$APPLOCALDATA/game/**" } + ] } ] } \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index bb832c8..79d1a2e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -12,8 +12,6 @@ use std::{ }; use sysinfo::System; use tauri::{AppHandle, Emitter, Manager}; -use tauri_plugin_dialog::{DialogExt, MessageDialogKind}; -use tauri_plugin_opener::OpenerExt; use tauri_plugin_os::platform; use tokio::io::AsyncReadExt; use tokio::{io::AsyncWriteExt, time::timeout}; @@ -324,30 +322,6 @@ fn launch_game( } } -#[tauri::command] -async fn open_folder(app: AppHandle, name: String) { - let game_path = app - .path() - .app_local_data_dir() - .unwrap() - .join("game") - .join(&name); - if game_path.exists() { - app.opener() - .open_path(game_path.to_string_lossy(), None::<&str>) - .unwrap(); - } else { - app.dialog() - .message(format!( - "Game folder \"{}\" not found.", - game_path.display() - )) - .kind(MessageDialogKind::Error) - .title("Folder not found") - .show(|_| {}); - } -} - #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { #[allow(unused_variables)] @@ -369,7 +343,6 @@ pub fn run() { .invoke_handler(tauri::generate_handler![ download, launch_game, - open_folder, folder_size ]) .setup(|app| { diff --git a/src/app/game/page.tsx b/src/app/game/page.tsx index 056ad69..6c16b69 100644 --- a/src/app/game/page.tsx +++ b/src/app/game/page.tsx @@ -11,6 +11,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { ask, message } from '@tauri-apps/plugin-dialog' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' import { writeVersionsConfig } from '@/lib/BazookaManager' +import { openFolder } from '@/lib/Util' export default function Installs () { const { @@ -359,9 +360,7 @@ export default function Installs () { setSelectedVersionList([entry]) downloadVersions([entry]) } else { - invoke('open_folder', { - name: entry - }) + openFolder(entry) } }} hidden={ diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 14d5645..9b07688 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -45,6 +45,7 @@ import { requestPermission } from '@tauri-apps/plugin-notification' import { BaseDirectory, exists, remove } from '@tauri-apps/plugin-fs' +import { openFolder } from '@/lib/Util' const roboto = Roboto({ subsets: ['latin'] @@ -930,9 +931,7 @@ export default function RootLayout ({