feat: progressive web app support #48
@ -11,6 +11,7 @@ services:
|
||||
- ./Cargo.toml:/srv/app/Cargo.toml
|
||||
- ./diesel.toml:/srv/app/diesel.toml
|
||||
- ./Dioxus.toml:/srv/app/Dioxus.toml
|
||||
- ./index.html:/srv/app/index.html
|
||||
- ./package.json:/srv/app/package.json
|
||||
- ./package-lock.json:/srv/app/package-lock.json
|
||||
restart: always
|
||||
|
24
index.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html class="min-h-screen">
|
||||
<head>
|
||||
<title>{app_title}</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<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>
|
||||
<body class="min-h-screen">
|
||||
<div id="main" class="min-h-screen"></div>
|
||||
<script type="module">
|
||||
import init from "/{base_path}/assets/dioxus/{app_name}.js";
|
||||
|
||||
init("/{base_path}/assets/dioxus/{app_name}_bg.wasm").then(wasm => {
|
||||
if (wasm.__wbindgen_start == undefined) {
|
||||
wasm.main();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
{script_include}
|
||||
</body>
|
||||
</html>
|
||||
![]() The HTML structure looks good overall, but there are a few areas for improvement.
Here's an updated version of the code with the suggested improvements:
Make sure to replace the placeholders with actual values and include the necessary CSS and JavaScript files for the application to work as expected. Committable suggestion
**The HTML structure looks good overall, but there are a few areas for improvement.**
1. The `<html>` tag is missing the `lang` attribute, which is important for accessibility. Consider adding `lang="en"` (or the appropriate language) to the `<html>` tag.
2. The `<meta charset="UTF-8"/>` tag on line 8 is redundant since the character encoding is already specified in the `<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>` tag on line 6. Remove the redundant tag for cleaner code.
3. The script block on lines 13-21 uses placeholders like `{base_path}` and `{app_name}`. Ensure that these placeholders are properly replaced with actual values during the build process or server-side rendering.
4. The `{style_include}` and `{script_include}` placeholders on lines 9 and 22 suggest that additional styles and scripts will be included. Make sure to include the necessary CSS and JavaScript files for the application to function properly.
5. Consider adding a `<noscript>` tag to provide fallback content for users who have JavaScript disabled in their browsers.
Here's an updated version of the code with the suggested improvements:
```diff
<!DOCTYPE html>
-<html class="min-h-screen">
+<html lang="en" class="min-h-screen">
<head>
<title>{app_title}</title>
<link rel="manifest" href="manifest.json">
<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>
<body class="min-h-screen">
<div id="main" class="min-h-screen"></div>
+<noscript>
+ <p>Please enable JavaScript to use this application.</p>
+</noscript>
<script type="module">
import init from "/{base_path}/assets/dioxus/{app_name}.js";
init("/{base_path}/assets/dioxus/{app_name}_bg.wasm").then(wasm => {
if (wasm.__wbindgen_start == undefined) {
wasm.main();
}
});
</script>
{script_include}
</body>
</html>
```
Make sure to replace the placeholders with actual values and include the necessary CSS and JavaScript files for the application to work as expected.
<!-- suggestion_start -->
<details>
<summary>Committable suggestion</summary>
> :bangbang: **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
<!DOCTYPE html>
<html lang="en" class="min-h-screen">
<head>
<title>{app_title}</title>
<link rel="manifest" href="manifest.json">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
{style_include}
</head>
<body class="min-h-screen">
<div id="main" class="min-h-screen"></div>
<noscript>
<p>Please enable JavaScript to use this application.</p>
</noscript>
<script type="module">
import init from "/{base_path}/assets/dioxus/{app_name}.js";
init("/{base_path}/assets/dioxus/{app_name}_bg.wasm").then(wasm => {
if (wasm.__wbindgen_start == undefined) {
wasm.main();
}
});
</script>
{script_include}
</body>
</html>
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
|
@ -7,9 +7,4 @@
|
||||
/* noinspection CssInvalidAtRule */
|
||||
@tailwind utilities;
|
||||
|
||||
html, body, #main {
|
||||
/* noinspection CssInvalidAtRule */
|
||||
@apply min-h-screen;
|
||||
}
|
||||
|
||||
/* stylelint-enable */
|
||||
|
Dioxus application initialization may fail due to missing build artifacts
The verification process has revealed potential issues with the Dioxus application initialization:
To resolve this:
Analysis chain
Verify the Dioxus application initialization.
The script block on lines 16-20 initializes the Dioxus application by importing the
init
function from the generated JavaScript file and calling it with the path to the WebAssembly file.To ensure that the Dioxus application is initialized correctly, run the following script:
If the generated files are not found or the
main
function is not exported, there might be an issue with the Dioxus build process. Double-check the Dioxus configuration and ensure that the application is built correctly.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 267
Script:
Length of output: 745