fix: commit code

This commit is contained in:
mrxiaozhuox committed 2022-01-25 17:51:36 +08:00
1 parent 25e3ee848c
commit b01b3f519f
8 files changed
+67 -47

No files matched your search

+10 -4
View File
@@ -22,12 +22,18 @@ impl Build {
crate_config.as_example(self.build.example.unwrap());
}
if self.build.platform.is_some() && self.build.platform.unwrap().to_uppercase() == "DESKTOP" {
crate::builder::build_desktop(&crate_config)?;
match self.build.platform.as_str() {
"web" => {
crate::builder::build(&crate_config)?;
}
"desktop" => {
crate::builder::build_desktop(&crate_config)?;
}
_ => {
return Err(anyhow::anyhow!("Unsoppurt platform target."));
}
}
crate::builder::build(&crate_config)?;
let temp = gen_page(&crate_config.dioxus_config, false);
let mut file = std::fs::File::create(
+4 -4
View File
@@ -20,8 +20,8 @@ pub struct ConfigOptsBuild {
pub example: Option<String>,
/// Build platform: support Web & Desktop [default: "web"]
#[structopt(long)]
pub platform: Option<String>,
#[structopt(long, default_value = "web")]
pub platform: String,
}
#[derive(Clone, Debug, Default, Deserialize, StructOpt)]
@@ -40,8 +40,8 @@ pub struct ConfigOptsServe {
pub release: bool,
/// Build platform: support Web & Desktop [default: "web"]
#[structopt(long)]
pub platform: Option<String>,
#[structopt(long, default_value = "web")]
pub platform: String,
}
/// Ensure the given value for `--public-url` is formatted correctly.
+30 -17
View File
@@ -21,25 +21,38 @@ impl Serve {
crate_config.as_example(self.serve.example.unwrap());
}
if self.serve.platform.is_some() && self.serve.platform.unwrap().to_uppercase() == "DESKTOP" {
crate::builder::build_desktop(&crate_config)?;
match &crate_config.executable {
crate::ExecutableType::Binary(name)
| crate::ExecutableType::Lib(name)
| crate::ExecutableType::Example(name) => {
let mut file = crate_config.out_dir.join(name);
if cfg!(windows) {
file.set_extension("exe");
}
Command::new(crate_config.out_dir.join(file).to_str().unwrap().to_string())
.output()?;
}
match self.serve.platform.as_str() {
"web" => {
crate::builder::build(&crate_config)?;
}
return Ok(());
}
"desktop" => {
crate::builder::build_desktop(&crate_config)?;
crate::builder::build(&crate_config).expect("build failed");
match &crate_config.executable {
crate::ExecutableType::Binary(name)
| crate::ExecutableType::Lib(name)
| crate::ExecutableType::Example(name) => {
let mut file = crate_config.out_dir.join(name);
if cfg!(windows) {
file.set_extension("exe");
}
Command::new(
crate_config
.out_dir
.join(file)
.to_str()
.unwrap()
.to_string(),
)
.output()?;
}
}
return Ok(());
}
_ => {
return Err(anyhow::anyhow!("Unsoppurt platform target."));
}
}
// generate dev-index page
Serve::regen_dev_page(&crate_config)?;