- 重构加载模式
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>丑橘文化传媒GEO内容优化平台</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
background: #f7fafc;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||
}
|
||||
.loader {
|
||||
text-align: center;
|
||||
}
|
||||
.spinner {
|
||||
width: 40px; height: 40px;
|
||||
border: 4px solid #e2e8f0;
|
||||
border-top-color: #2563eb;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin: 0 auto 16px;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
p { color: #4a5568; font-size: 14px; }
|
||||
</style>
|
||||
<script>
|
||||
// 等待 streamlit 服务就绪后跳转
|
||||
(function() {
|
||||
var retries = 0;
|
||||
var maxRetries = 50;
|
||||
function check() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'http://127.0.0.1:8501', true);
|
||||
xhr.timeout = 2000;
|
||||
xhr.onload = function() {
|
||||
window.location.href = 'http://127.0.0.1:8501';
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
retries++;
|
||||
if (retries < maxRetries) {
|
||||
setTimeout(check, 500);
|
||||
}
|
||||
};
|
||||
xhr.ontimeout = function() {
|
||||
retries++;
|
||||
if (retries < maxRetries) {
|
||||
setTimeout(check, 500);
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
// 等待 500ms 后开始轮询(给 streamlit 启动时间)
|
||||
setTimeout(check, 500);
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="loader">
|
||||
<div class="spinner"></div>
|
||||
<p>正在加载...</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user