Migrate to Tauri v2 and fix configuration issues

This commit is contained in:
Rbanh 2025-04-01 00:08:58 -04:00
parent 7b772bb1bb
commit 340ce3d834
6 changed files with 115 additions and 83 deletions

View File

@ -7,17 +7,19 @@
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview", "preview": "vite preview",
"tauri": "tauri" "tauri": "tauri",
"typecheck": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^2.4.0", "@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.2.0", "@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-opener": "^2", "@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1" "react-dom": "^18.3.1"
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^2", "@tauri-apps/cli": "^2.0.0",
"@types/react": "^18.3.1", "@types/react": "^18.3.1",
"@types/react-dom": "^18.3.1", "@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4", "@vitejs/plugin-react": "^4.3.4",

View File

@ -1,48 +1,48 @@
[package] [package]
name = "plugsnatcher" name = "app"
version = "0.1.0" version = "0.1.0"
description = "A Tauri App" description = "A Tauri App"
authors = ["you"] authors = ["you"]
license = ""
repository = ""
edition = "2021" edition = "2021"
rust-version = "1.77.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib] [lib]
# The `_lib` suffix may seem redundant but it is necessary name = "app_lib"
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "plugsnatcher_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies] [build-dependencies]
tauri-build = { version = "2", features = [] } tauri-build = { version = "2.1.0", features = [] }
[dependencies] [dependencies]
tauri = { version = "2", features = [] } # Tauri dependencies
tauri-plugin-opener = "2" serde_json = "1.0"
tauri-plugin-dialog = "2" serde = { version = "1.0", features = ["derive"] }
serde = { version = "1", features = ["derive"] } log = "0.4"
serde_json = "1" tauri = { version = "2.4.0", features = [] }
zip = "0.6" tauri-plugin-log = "2.0.0-rc"
yaml-rust = "0.4" tauri-plugin-shell = "~2.0"
# walkdir = "2.4" # Not currently used, commented out tauri-plugin-dialog = "~2.0"
regex = "1.10" # Still needed elsewhere in the codebase tauri-plugin-fs = "~2.0"
sha2 = "0.10"
reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-features = false } # Updated version, enabled rustls
# scraper = "0.19.0" # No longer used for SpigotMCCrawler
urlencoding = "2.1.3" # Reverted version
semver = "1.0"
url = "2.5"
futures = "0.3"
async-trait = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] } # Changed features from "full"
# --- Add Caching Dependencies ---
cached = { version = "0.52", features = ["proc_macro", "async", "tokio"] }
async-mutex = "1.4" # For locking cache access within HttpClient
# --- End Caching Dependencies ---
base64 = "0.21" # For decoding SpigotMC changelog data
walkdir = "2.5.0"
[features] # Plugin scanner dependencies
# default = ["custom-protocol"] walkdir = "2.3.3"
regex = "1.9.1"
yaml-rust = "0.4.5"
zip = "0.6.6"
sha2 = "0.10.7"
# Network and async dependencies
reqwest = { version = "0.11.18", features = ["json"] }
tokio = { version = "1.29.1", features = ["full"] }
futures = "0.3.28"
async-trait = "0.1.71"
cached = "0.44.0"
urlencoding = "2.1.2"
base64 = "0.21.2"
# Version management
semver = "1.0.18"

View File

@ -1,12 +1,24 @@
{ {
"$schema": "../gen/schemas/desktop-schema.json", "$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default", "identifier": "default",
"description": "Capability for the main window", "description": "Default capability set for the main window",
"windows": ["main"], "windows": [
"main"
],
"permissions": [ "permissions": [
"core:default", { "identifier": "core:default" },
"opener:default", { "identifier": "dialog:default" },
"dialog:default", { "identifier": "dialog:allow-open" },
"dialog:allow-open" { "identifier": "shell:default" },
{ "identifier": "shell:allow-open" },
{ "identifier": "fs:default" },
{
"identifier": "fs:allow-read-dir",
"allow": ["**", "//**"]
},
{
"identifier": "fs:allow-read-file",
"allow": ["**", "//**"]
}
] ]
} }

View File

@ -289,39 +289,51 @@ pub async fn lib_download_plugin_from_repository(
} }
} }
/// Configure and run the Tauri application // Tauri v2 plugin initialization
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
// Build the Tauri application tauri::Builder::default()
tauri::Builder::default() .plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())
.invoke_handler(tauri::generate_handler![ .plugin(tauri_plugin_fs::init())
// Plugin discovery commands .setup(|app| {
scan_server_dir, if cfg!(debug_assertions) {
scan_server_dir_sync, app.handle().plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)?;
}
Ok(())
})
.invoke_handler(tauri::generate_handler![
// Plugin discovery commands
scan_server_dir,
scan_server_dir_sync,
// Plugin repository commands // Plugin repository commands
search_plugins, search_plugins,
get_plugin_details, get_plugin_details,
// Update commands // Update commands
update_plugin, update_plugin,
check_plugin_updates, check_plugin_updates,
check_single_plugin_update_command, check_single_plugin_update_command,
backup_plugin_command, backup_plugin_command,
// Plugin management commands // Plugin management commands
download_plugin, download_plugin,
set_plugin_repository, set_plugin_repository,
get_plugin_versions, get_plugin_versions,
load_plugin_data, load_plugin_data,
save_plugin_data, save_plugin_data,
// Utility commands // Utility commands
get_potential_plugin_matches, get_potential_plugin_matches,
compare_versions, compare_versions,
is_plugin_compatible, is_plugin_compatible,
greet greet
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");
} }

View File

@ -2,5 +2,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() { fn main() {
plugsnatcher_lib::run(); app_lib::run();
} }

View File

@ -1,28 +1,31 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"identifier": "com.plugsnatcher.app",
"productName": "PlugSnatcher", "productName": "PlugSnatcher",
"version": "0.1.0", "version": "0.1.0",
"identifier": "com.plugsnatcher.app",
"build": { "build": {
"beforeDevCommand": "npm run dev", "beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build", "beforeBuildCommand": "npm run build",
"frontendDist": "../dist" "frontendDist": "../dist",
"devUrl": "http://localhost:1420"
}, },
"app": { "app": {
"security": {
"csp": null
},
"windows": [ "windows": [
{ {
"label": "main",
"title": "PlugSnatcher", "title": "PlugSnatcher",
"width": 1024, "width": 1024,
"height": 768, "height": 768,
"minWidth": 800, "minWidth": 800,
"minHeight": 600, "minHeight": 600,
"resizable": true,
"fullscreen": false,
"center": true "center": true
} }
], ]
"security": {
"csp": null
}
}, },
"bundle": { "bundle": {
"active": true, "active": true,
@ -36,7 +39,10 @@
] ]
}, },
"plugins": { "plugins": {
"shell": {
"open": true
},
"dialog": null, "dialog": null,
"opener": null "fs": null
} }
} }