- set index on 404 to true (highly desired for SPA)
- add support for web.base_path in dioxus.toml to allow multi level routes
This commit is contained in:
1 parent
e84851bdfb
commit
280480de6b
3 files changed
+36
-25
No files matched your search
+24
-21
@@ -1,23 +1,26 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
|
||||||
<title>{app_title}</title>
|
|
||||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
{style_include}
|
|
||||||
|
|
||||||
</head>
|
<head>
|
||||||
<body>
|
<title>{app_title}</title>
|
||||||
<div id="main"></div>
|
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
|
||||||
<!-- Note the usage of `type=module` here as this is an ES6 module -->
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<script type="module">
|
<meta charset="UTF-8" />
|
||||||
import init from "./assets/dioxus/{app_name}.js";
|
{style_include}
|
||||||
init("./assets/dioxus/{app_name}_bg.wasm").then(wasm => {
|
|
||||||
if (wasm.__wbindgen_start == undefined) {
|
</head>
|
||||||
wasm.main();
|
|
||||||
}
|
<body>
|
||||||
});
|
<div id="main"></div>
|
||||||
</script>
|
<!-- Note the usage of `type=module` here as this is an ES6 module -->
|
||||||
{script_include}
|
<script type="module">
|
||||||
</body>
|
import init from "{base_path}/assets/dioxus/{app_name}.js";
|
||||||
</html>
|
init("{base_path}/assets/dioxus/{app_name}_bg.wasm").then(wasm => {
|
||||||
|
if (wasm.__wbindgen_start == undefined) {
|
||||||
|
wasm.main();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{script_include}
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
+9
-3
@@ -82,20 +82,21 @@ pub fn build(config: &CrateConfig) -> Result<()> {
|
|||||||
|
|
||||||
bindgen_builder
|
bindgen_builder
|
||||||
.input_path(input_path)
|
.input_path(input_path)
|
||||||
.web(true).unwrap()
|
.web(true)
|
||||||
|
.unwrap()
|
||||||
.debug(true)
|
.debug(true)
|
||||||
.demangle(true)
|
.demangle(true)
|
||||||
.keep_debug(true)
|
.keep_debug(true)
|
||||||
.remove_name_section(false)
|
.remove_name_section(false)
|
||||||
.remove_producers_section(false)
|
.remove_producers_section(false)
|
||||||
.out_name(&dioxus_config.application.name)
|
.out_name(&dioxus_config.application.name)
|
||||||
.generate(&bindgen_outdir).unwrap();
|
.generate(&bindgen_outdir)
|
||||||
|
.unwrap();
|
||||||
});
|
});
|
||||||
if bindgen_result.is_err() {
|
if bindgen_result.is_err() {
|
||||||
log::error!("Bindgen build failed! \nThis is probably due to the Bindgen version, dioxus-cli using `0.2.79` Bindgen crate.");
|
log::error!("Bindgen build failed! \nThis is probably due to the Bindgen version, dioxus-cli using `0.2.79` Bindgen crate.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this code will copy all public file to the output dir
|
// this code will copy all public file to the output dir
|
||||||
let copy_options = fs_extra::dir::CopyOptions {
|
let copy_options = fs_extra::dir::CopyOptions {
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
@@ -278,6 +279,11 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String {
|
|||||||
|
|
||||||
html = html.replace("{app_name}", &config.application.name);
|
html = html.replace("{app_name}", &config.application.name);
|
||||||
|
|
||||||
|
html = match &config.web.app.base_path {
|
||||||
|
Some(path) => html.replace("{base_path}", path),
|
||||||
|
None => html.replace("{base_path}", "."),
|
||||||
|
};
|
||||||
|
|
||||||
let title = config
|
let title = config
|
||||||
.web
|
.web
|
||||||
.app
|
.app
|
||||||
|
|||||||
+3
-1
@@ -39,11 +39,12 @@ impl Default for DioxusConfig {
|
|||||||
web: WebConfig {
|
web: WebConfig {
|
||||||
app: WebAppConfing {
|
app: WebAppConfing {
|
||||||
title: Some("dioxus | ⛺".into()),
|
title: Some("dioxus | ⛺".into()),
|
||||||
|
base_path: None,
|
||||||
},
|
},
|
||||||
watcher: WebWatcherConfing {
|
watcher: WebWatcherConfing {
|
||||||
watch_path: Some(vec![PathBuf::from("src")]),
|
watch_path: Some(vec![PathBuf::from("src")]),
|
||||||
reload_html: Some(false),
|
reload_html: Some(false),
|
||||||
index_on_404: Some(false),
|
index_on_404: Some(true),
|
||||||
},
|
},
|
||||||
resource: WebResourceConfing {
|
resource: WebResourceConfing {
|
||||||
dev: WebDevResourceConfing {
|
dev: WebDevResourceConfing {
|
||||||
@@ -77,6 +78,7 @@ pub struct WebConfig {
|
|||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct WebAppConfing {
|
pub struct WebAppConfing {
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
|
pub base_path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
Reference in new issue
Block a user