feat: default plugin info
This commit is contained in:
1 parent
39e38917d6
commit
bbc9e1b3a2
3 files changed
+8
-3
No files matched your search
Whitespace-only changes.
+8
-2
@@ -6,9 +6,15 @@ use std::{collections::HashMap, fs::File, io::Read, path::PathBuf};
|
|||||||
pub struct DioxusConfig {
|
pub struct DioxusConfig {
|
||||||
pub application: ApplicationConfig,
|
pub application: ApplicationConfig,
|
||||||
pub web: WebConfig,
|
pub web: WebConfig,
|
||||||
|
|
||||||
|
#[serde(default = "default_plugin")]
|
||||||
pub plugin: toml::Value,
|
pub plugin: toml::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_plugin() -> toml::Value {
|
||||||
|
toml::Value::Boolean(true)
|
||||||
|
}
|
||||||
|
|
||||||
impl DioxusConfig {
|
impl DioxusConfig {
|
||||||
pub fn load() -> crate::error::Result<DioxusConfig> {
|
pub fn load() -> crate::error::Result<DioxusConfig> {
|
||||||
let crate_dir = crate::cargo::crate_root()?;
|
let crate_dir = crate::cargo::crate_root()?;
|
||||||
@@ -23,7 +29,7 @@ impl DioxusConfig {
|
|||||||
dioxus_conf_file.read_to_string(&mut meta_str)?;
|
dioxus_conf_file.read_to_string(&mut meta_str)?;
|
||||||
|
|
||||||
toml::from_str::<DioxusConfig>(&meta_str)
|
toml::from_str::<DioxusConfig>(&meta_str)
|
||||||
.map_err(|_| crate::Error::Unique("Dioxus.toml parse failed".into()))
|
.map_err(|_| crate::Error::Unique("Dioxus.toml parse failed".into()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +65,7 @@ impl Default for DioxusConfig {
|
|||||||
script: Some(vec![]),
|
script: Some(vec![]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugin: toml::Value::Table(toml::map::Map::new())
|
plugin: toml::Value::Table(toml::map::Map::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
|||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| vec![PathBuf::from("src")]);
|
.unwrap_or_else(|| vec![PathBuf::from("src")]);
|
||||||
|
|
||||||
let watcher_config = config.clone();
|
|
||||||
let watcher_config = config.clone();
|
let watcher_config = config.clone();
|
||||||
let mut watcher = RecommendedWatcher::new(
|
let mut watcher = RecommendedWatcher::new(
|
||||||
move |evt: notify::Result<notify::Event>| {
|
move |evt: notify::Result<notify::Event>| {
|
||||||
|
|||||||
Reference in new issue
Block a user