v0.1.0-pre.051
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/tauri.rs
|
||||
// version: 7
|
||||
// version: 8
|
||||
|
||||
//! Tauri runtime assembly and private command wrappers.
|
||||
|
||||
@@ -64,21 +64,10 @@ pub fn run() -> kb_core::Result<()> {
|
||||
load_demo_sql_replay_programs,
|
||||
load_demo_sql_replay_entities,
|
||||
export_demo_sql_replay_csv,
|
||||
open_demo_config_window,
|
||||
load_demo_config,
|
||||
]);
|
||||
builder = builder.plugin(tracing_builder.build::<tauri::Wry>());
|
||||
builder = builder.on_window_event(|window, event| {
|
||||
if window.label() != "demo_ws" {
|
||||
return;
|
||||
}
|
||||
if !matches!(event, tauri::WindowEvent::Destroyed) {
|
||||
return;
|
||||
}
|
||||
let app_handle = window.app_handle().clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let state = app_handle.state::<crate::AppState>();
|
||||
crate::disconnect_demo_ws_app_state(&state, false).await;
|
||||
});
|
||||
});
|
||||
builder = builder.setup(|app| {
|
||||
let splash_window = match app.get_webview_window("splash") {
|
||||
std::option::Option::Some(window) => window,
|
||||
@@ -194,6 +183,46 @@ fn install_default_rustls_provider() -> kb_core::Result<()> {
|
||||
};
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn open_demo_config_window(
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> std::result::Result<(), std::string::String> {
|
||||
if let std::option::Option::Some(window) = app_handle.get_webview_window("demo_config") {
|
||||
if let std::result::Result::Err(error) = window.show() {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
}
|
||||
if let std::result::Result::Err(error) = window.set_focus() {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
}
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
let builder = tauri::WebviewWindowBuilder::new(
|
||||
&app_handle,
|
||||
"demo_config",
|
||||
tauri::WebviewUrl::App("demo_config.html".into()),
|
||||
)
|
||||
.title("Khadhroony Bot3 - Configuration")
|
||||
.inner_size(1280.0, 820.0)
|
||||
.min_inner_size(960.0, 640.0);
|
||||
let window = match builder.build() {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
},
|
||||
};
|
||||
if let std::result::Result::Err(error) = window.set_focus() {
|
||||
return std::result::Result::Err(error.to_string());
|
||||
}
|
||||
return std::result::Result::Ok(());
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn load_demo_config(
|
||||
state: tauri::State<'_, crate::AppState>,
|
||||
) -> crate::DemoConfigPayload {
|
||||
return crate::demo_config_payload(state.inner());
|
||||
}
|
||||
|
||||
fn into_ipc_result<T>(
|
||||
result: kb_core::Result<T>,
|
||||
) -> std::result::Result<T, std::string::String> {
|
||||
|
||||
Reference in New Issue
Block a user