Skip to main content

Mountain/RPC/CocoonService/GenericRequest/WindowDialogs/
CreateWebviewPanel.rs

1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::{Value, json};
4use tauri::Emitter;
5use tonic::Response;
6
7use crate::{Environment::MountainEnvironment::MountainEnvironment, Vine::Generated::GenericResponse};
8
9pub fn Fn(RequestId:u64, Params:Value, Env:&MountainEnvironment) -> Response<GenericResponse> {
10	let ViewType = Params.get("viewType").and_then(|V| V.as_str()).unwrap_or("").to_string();
11
12	let Title = Params.get("title").and_then(|V| V.as_str()).unwrap_or("").to_string();
13
14	let Handle = std::time::SystemTime::now()
15		.duration_since(std::time::UNIX_EPOCH)
16		.map(|D| D.as_millis() as u64)
17		.unwrap_or(0);
18
19	let _ = Env.ApplicationHandle.emit(
20		"sky://webview/create",
21		json!({
22			"handle": Handle,
23			"viewType": ViewType,
24			"title": Title,
25			"viewColumn": Params.get("viewColumn"),
26			"preserveFocus": Params.get("preserveFocus").and_then(|V| V.as_bool()).unwrap_or(false),
27		}),
28	);
29
30	super::super::FileSystem::OkResponse(RequestId, &json!({ "handle": Handle }))
31}