✨ Pass pakeConfig to web
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct WindowConfig {
|
||||
pub url: String,
|
||||
pub transparent: bool,
|
||||
@@ -10,9 +10,10 @@ pub struct WindowConfig {
|
||||
pub resizable: bool,
|
||||
pub url_type: String,
|
||||
pub always_on_top: bool,
|
||||
pub disabled_web_shortcuts: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PlatformSpecific<T> {
|
||||
pub macos: T,
|
||||
pub linux: T,
|
||||
@@ -44,7 +45,7 @@ where
|
||||
pub type UserAgent = PlatformSpecific<String>;
|
||||
pub type FunctionON = PlatformSpecific<bool>;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct PakeConfig {
|
||||
pub windows: Vec<WindowConfig>,
|
||||
pub user_agent: UserAgent,
|
||||
|
||||
@@ -19,6 +19,11 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
||||
_ => panic!("url type can only be web or local"),
|
||||
};
|
||||
|
||||
let config_script = format!(
|
||||
"window.pakeConfig = {}",
|
||||
serde_json::to_string(&window_config).unwrap()
|
||||
);
|
||||
|
||||
let mut window_builder = WindowBuilder::new(app, "pake", url)
|
||||
.title("")
|
||||
.user_agent(user_agent)
|
||||
@@ -28,18 +33,13 @@ pub fn get_window(app: &mut App, config: PakeConfig, _data_dir: PathBuf) -> Wind
|
||||
.inner_size(window_config.width, window_config.height)
|
||||
.disable_file_drop_handler()
|
||||
.always_on_top(window_config.always_on_top)
|
||||
.initialization_script(&config_script)
|
||||
.initialization_script(include_str!("../inject/component.js"))
|
||||
.initialization_script(include_str!("../inject/event.js"))
|
||||
.initialization_script(include_str!("../inject/style.js"))
|
||||
//This is necessary to allow for file injection by external developers for customization purposes.
|
||||
.initialization_script(include_str!("../inject/custom.js"));
|
||||
|
||||
// For dynamic display of header styles
|
||||
if window_config.transparent {
|
||||
let transparent_script = "window.pakeWindowTitleTransparent = true;";
|
||||
window_builder = window_builder.initialization_script(transparent_script);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
let title_bar_style = if window_config.transparent {
|
||||
|
||||
Reference in New Issue
Block a user