feat(app): tauri get_config/set_config bridge commands
This commit is contained in:
@@ -327,3 +327,22 @@ pub async fn mark_read(state: BridgeState<'_>, target: Value) -> Result<Value, S
|
|||||||
pub async fn health(state: BridgeState<'_>) -> Result<Value, String> {
|
pub async fn health(state: BridgeState<'_>) -> Result<Value, String> {
|
||||||
data_of(state.request(Cmd::Health).await.map_err(|e| e.to_string())?)
|
data_of(state.request(Cmd::Health).await.map_err(|e| e.to_string())?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Settings commands ----
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn get_config(state: BridgeState<'_>) -> Result<Value, String> {
|
||||||
|
data_of(state.request(Cmd::GetConfig).await.map_err(|e| e.to_string())?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn set_config(
|
||||||
|
state: BridgeState<'_>,
|
||||||
|
default_shell: Option<String>,
|
||||||
|
font_family: Option<String>,
|
||||||
|
font_size: Option<u16>,
|
||||||
|
theme: Option<String>,
|
||||||
|
accent: Option<String>,
|
||||||
|
) -> Result<Value, String> {
|
||||||
|
data_of(state.request(Cmd::SetConfig { default_shell, font_family, font_size, theme, accent }).await.map_err(|e| e.to_string())?)
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ pub fn run() {
|
|||||||
bridge::event_log,
|
bridge::event_log,
|
||||||
bridge::mark_read,
|
bridge::mark_read,
|
||||||
bridge::health,
|
bridge::health,
|
||||||
|
bridge::get_config,
|
||||||
|
bridge::set_config,
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running spacesh");
|
.expect("error while running spacesh");
|
||||||
|
|||||||
Reference in New Issue
Block a user