Fonte publicada
Transferir fonte ZIP
CH-J Tools
Navegue por diretórios e arquivos para uma versão específica do aplicativo.
CH-J / Server Manager
1704 arquivos
0.1.2-beta
Adicionado: · Construído:
1
//! Module manager commands for the main window (formerly `plugins:*`).3
use super::{logged, main_core, text, CommandResult};4
use crate::core::app::CoreSlot;5
use serde_json::Value;6
use tauri::{State, Webview};8
#[tauri::command]9
pub async fn core_modules_list(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {10
let core = main_core(&webview, &slot)?;11
logged(&core, "plugins:list", core.services.modules.registry.list_installed().map(Value::Array))12
}14
#[tauri::command]15
pub async fn core_modules_get_state(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {16
let core = main_core(&webview, &slot)?;17
logged(&core, "plugins:getState", core.services.modules.get_state())18
}20
#[tauri::command]21
pub async fn core_modules_check_catalog(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {22
let core = main_core(&webview, &slot)?;23
let result = core.services.modules.check_catalog(&core).await;24
logged(&core, "plugins:checkCatalog", result)25
}27
#[tauri::command]28
pub async fn core_modules_install(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {29
let core = main_core(&webview, &slot)?;30
let payload = super::payload(payload);31
let result = async {32
core.services.biometrics.require_sensitive_action().await?;33
core.services.modules.install(&core, text(&payload, "releaseId")).await34
}35
.await;36
logged(&core, "plugins:install", result)37
}39
#[tauri::command]40
pub async fn core_modules_uninstall(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {41
let core = main_core(&webview, &slot)?;42
let payload = super::payload(payload);43
let result = async {44
core.services.biometrics.require_sensitive_action().await?;45
core.services.modules.uninstall(&core, text(&payload, "pluginId")).await46
}47
.await;48
logged(&core, "plugins:uninstall", result)49
}51
#[tauri::command]52
pub async fn core_modules_open(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {53
let core = main_core(&webview, &slot)?;54
let payload = super::payload(payload);55
logged(&core, "plugins:open", core.services.modules.open(&core, text(&payload, "pluginId")))56
}58
/// The main page reports where the module area is; `null` hides embedded modules while another view is open.59
#[tauri::command]60
pub async fn core_modules_set_area(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {61
let core = main_core(&webview, &slot)?;62
let payload = super::payload(payload);63
let number = |key: &str| payload.get(key).and_then(Value::as_f64).filter(|value| value.is_finite());64
let area = match (number("x"), number("y"), number("width"), number("height")) {65
(Some(x), Some(y), Some(width), Some(height)) if width >= 1.0 && height >= 1.0 => {66
let top = crate::windows::page_top(&core.app, number("pageHeight").unwrap_or(0.0));67
Some(crate::core::modules::service::Area { x, y: y + top, width, height })68
}69
_ => None,70
};71
core.services.modules.set_area(&core, area);72
Ok(Value::Null)73
}75
/// The module bar of the main window: moves the shown module to its own window.76
#[tauri::command]77
pub async fn core_modules_detach(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {78
let core = main_core(&webview, &slot)?;79
let payload = super::payload(payload);80
let result = core.services.modules.label_of(text(&payload, "pluginId")).and_then(|label| core.services.modules.detach(&core, &label));81
logged(&core, "plugins:detach", result)82
}84
#[tauri::command]85
pub async fn core_modules_collapse(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {86
let core = main_core(&webview, &slot)?;87
let payload = super::payload(payload);88
let result = core.services.modules.label_of(text(&payload, "pluginId")).map(|label| {89
core.services.modules.minimize_label(&core, &label, false);90
Value::Null91
});92
logged(&core, "plugins:collapse", result)93
}95
/// Closing asks about unsaved changes first, like closing a module window.96
#[tauri::command]97
pub async fn core_modules_close(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {98
let core = main_core(&webview, &slot)?;99
let payload = super::payload(payload);100
core.services.modules.close(&core, text(&payload, "pluginId"));101
Ok(Value::Null)102
}SHA-256
ae4357f6dc2fca9b150e414d200fa2d8f7c55cb8292baba3700f80be071afe9dCH-J Proprietary Software License 1.14 · A fonte é fornecida sob o CH-J Proprietary Software License 1.14. A sua disponibilidade não altera os termos licença nem concede direitos adicionais.
Ficheiro SHA-256
ac8fe790f4ba60fc098f8c985fc2656cfcc6cdc21fb34b30e308a2b54e62258f