mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-07-18 00:10:45 +00:00
feat: initial plugin support
This commit is contained in:
@@ -4,6 +4,7 @@ pub mod download;
|
||||
pub mod file_dialogs;
|
||||
pub mod game;
|
||||
pub mod macos_setup;
|
||||
pub mod plugins;
|
||||
pub mod proxy_cmd;
|
||||
pub mod runners;
|
||||
pub mod skin;
|
||||
|
||||
28
src-tauri/src/commands/plugins.rs
Normal file
28
src-tauri/src/commands/plugins.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use serde::Serialize;
|
||||
use std::fs;
|
||||
#[derive(Serialize)]
|
||||
pub struct DirEntry {
|
||||
pub name: String,
|
||||
pub is_dir: bool,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_plugins_dir(app: tauri::AppHandle) -> Result<String, String> {
|
||||
let dir = crate::util::get_app_dir(&app).join("plugins");
|
||||
fs::create_dir_all(&dir).map_err(|e| e.to_string())?;
|
||||
Ok(dir.to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_directory(path: String) -> Result<Vec<DirEntry>, String> {
|
||||
let entries = fs::read_dir(&path).map_err(|e| e.to_string())?;
|
||||
let mut results = Vec::new();
|
||||
for entry in entries {
|
||||
let entry = entry.map_err(|e| e.to_string())?;
|
||||
results.push(DirEntry {
|
||||
name: entry.file_name().to_string_lossy().to_string(),
|
||||
is_dir: entry.file_type().map(|t| t.is_dir()).unwrap_or(false),
|
||||
});
|
||||
}
|
||||
Ok(results)
|
||||
}
|
||||
@@ -16,6 +16,7 @@ use commands::download;
|
||||
use commands::file_dialogs;
|
||||
use commands::game;
|
||||
use commands::macos_setup;
|
||||
use commands::plugins;
|
||||
use commands::proxy_cmd;
|
||||
use commands::runners;
|
||||
use commands::skin;
|
||||
@@ -95,6 +96,8 @@ pub fn run() {
|
||||
relay::stop_proxy,
|
||||
relay::stop_all_proxies,
|
||||
relay::join_game,
|
||||
plugins::get_plugins_dir,
|
||||
plugins::list_directory,
|
||||
])
|
||||
.setup(|app| {
|
||||
let app_handle = app.handle().clone();
|
||||
|
||||
Reference in New Issue
Block a user