feat(config): migrate app_config_dir to Tauri Store for independent management (#109)

This commit is contained in:
ZyphrZero
2025-10-15 09:15:53 +08:00
committed by GitHub
parent 3e4df2c96a
commit 3b6048b1e8
14 changed files with 456 additions and 10 deletions

View File

@@ -1222,6 +1222,13 @@ pub async fn save_settings(settings: crate::settings::AppSettings) -> Result<boo
Ok(true)
}
/// 重启应用程序(当 app_config_dir 变更后使用)
#[tauri::command]
pub async fn restart_app(app: tauri::AppHandle) -> Result<bool, String> {
// 使用 tauri-plugin-process 重启应用
app.restart();
}
/// 检查更新
#[tauri::command]
pub async fn check_for_updates(handle: tauri::AppHandle) -> Result<bool, String> {
@@ -1469,3 +1476,20 @@ pub async fn update_endpoint_last_used(
state.save()?;
Ok(())
}
/// 获取 app_config_dir 覆盖配置 (从 Store)
#[tauri::command]
pub async fn get_app_config_dir_override(app: tauri::AppHandle) -> Result<Option<String>, String> {
Ok(crate::app_store::get_app_config_dir_from_store(&app)
.map(|p| p.to_string_lossy().to_string()))
}
/// 设置 app_config_dir 覆盖配置 (到 Store)
#[tauri::command]
pub async fn set_app_config_dir_override(
app: tauri::AppHandle,
path: Option<String>,
) -> Result<bool, String> {
crate::app_store::set_app_config_dir_to_store(&app, path.as_deref())?;
Ok(true)
}