feat: custom scrollbars, portable storage, window state persistence
- Custom scrollbar CSS using ::-webkit-scrollbar for Tauri's Chromium WebView - Portable storage: all data written next to exe in data/ folder instead of AppData - Rust get_portable_data_dir command with runtime FS scope for exe directory - Window size/position/maximized saved to settings on close, restored on startup
This commit is contained in:
@@ -17,8 +17,9 @@
|
||||
"dialog:default",
|
||||
"shell:default",
|
||||
"fs:default",
|
||||
"fs:allow-appdata-read-recursive",
|
||||
"fs:allow-appdata-write-recursive",
|
||||
"fs:allow-appdata-meta-recursive"
|
||||
"core:window:allow-set-size",
|
||||
"core:window:allow-set-position",
|
||||
"core:window:allow-outer-size",
|
||||
"core:window:allow-outer-position"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
use tauri_plugin_fs::FsExt;
|
||||
|
||||
#[tauri::command]
|
||||
fn get_portable_data_dir() -> Result<String, String> {
|
||||
let exe_path = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let exe_dir = exe_path
|
||||
.parent()
|
||||
.ok_or_else(|| "Failed to get exe directory".to_string())?;
|
||||
let data_dir = exe_dir.join("data");
|
||||
Ok(data_dir.to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
@@ -5,6 +17,27 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.setup(|app| {
|
||||
// Get portable data directory next to the exe
|
||||
let exe_path =
|
||||
std::env::current_exe().expect("Failed to get exe path");
|
||||
let exe_dir = exe_path
|
||||
.parent()
|
||||
.expect("Failed to get exe directory");
|
||||
let data_dir = exe_dir.join("data");
|
||||
|
||||
// Ensure data directory exists
|
||||
std::fs::create_dir_all(&data_dir)
|
||||
.expect("Failed to create portable data directory");
|
||||
|
||||
// Allow FS plugin access to the portable data directory
|
||||
app.fs_scope()
|
||||
.allow_directory(&data_dir, true)
|
||||
.expect("Failed to allow data directory in FS scope");
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![get_portable_data_dir])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user