Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
add loading indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
waozixyz committed Sep 25, 2024
1 parent 1017e96 commit d2f6e9e
Showing 1 changed file with 53 additions and 23 deletions.
76 changes: 53 additions & 23 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
<!DOCTYPE html>
<html>
<head>
<title>{app_title}</title>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(
'/sw.js'
);
}
</script>
<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}
<title>{app_title}</title>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js');
}
</script>
<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}
<style>
#loading {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-size: 24px;
}
.spinner {
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-right: 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div id="main"></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}
<div id="loading">
<div class="spinner"></div>
Loading...
</div>
<div id="main" style="display: none;"></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();
}
// Hide loading indicator and show main content
document.getElementById('loading').style.display = 'none';
document.getElementById('main').style.display = 'block';
}).catch(error => {
console.error('Failed to load WASM:', error);
document.getElementById('loading').innerHTML = 'Failed to load. Please try again.';
});
</script>
{script_include}
</body>
</html>

0 comments on commit d2f6e9e

Please sign in to comment.