fix: 修复 Flutter Web 白屏问题

- main.dart: 添加全局错误处理和 FlutterError.onError
- index.html: 添加加载指示器,vconsole 仅在开发环境启用
- dio_client.dart: 添加详细错误日志,优化超时配置

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 18:54:01 +08:00
parent 9cd9e8d0bf
commit 6bf54eb849
6 changed files with 263 additions and 29 deletions

View File

@@ -1 +1 @@
2b1d2ed877ca1d041aef5d6561fbfcf5
cd059bcd8df9e9b2b7bfff5ee9fb7ba7

View File

@@ -37,6 +37,6 @@ _flutter.buildConfig = {"engineRevision":"e4b8dca3f1b4ede4c30371002441c88c12187e
_flutter.loader.load({
serviceWorkerSettings: {
serviceWorkerVersion: "2873482940" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
serviceWorkerVersion: "1409326861" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
}
});

View File

@@ -18,21 +18,79 @@
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="A new Flutter project.">
<meta name="description" content="Monisuo - Crypto Trading App">
<!-- iOS meta tags & icons -->
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="flutter_monisuo">
<meta name="apple-mobile-web-app-title" content="Monisuo">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<title>flutter_monisuo</title>
<title>Monisuo</title>
<link rel="manifest" href="manifest.json">
<style>
/* 加载指示器样式 */
.loading-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
z-index: 9999;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 3px solid rgba(255, 255, 255, 0.1);
border-top: 3px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
.loading-text {
margin-top: 20px;
color: #ffffff;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
font-size: 16px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* 隐藏加载指示器 */
.loading-hidden {
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease-out;
}
</style>
</head>
<body>
<!-- 加载指示器 -->
<div id="loading" class="loading-container">
<div class="loading-spinner"></div>
<div class="loading-text">Loading...</div>
</div>
<noscript>
<div style="text-align: center; padding: 50px; font-family: sans-serif;">
<h1>JavaScript Required</h1>
<p>Please enable JavaScript to run this application.</p>
</div>
</noscript>
<!--
You can customize the "flutter_bootstrap.js" script.
This is useful to provide a custom configuration to the Flutter loader
@@ -43,12 +101,34 @@
-->
<script src="flutter_bootstrap.js" async></script>
<!-- vConsole 调试控制台 -->
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<!-- 隐藏加载指示器 -->
<script>
window.addEventListener('load', function() {
new VConsole();
window.addEventListener('flutter-first-frame', function() {
var loading = document.getElementById('loading');
if (loading) {
loading.classList.add('loading-hidden');
setTimeout(function() {
loading.remove();
}, 300);
}
});
</script>
<!-- vConsole 调试控制台 - 仅在开发环境启用 -->
<script>
// 检测是否为开发环境localhost 或特定端口)
var isDev = window.location.hostname === 'localhost' ||
window.location.hostname === '127.0.0.1' ||
window.location.port !== '' && window.location.port !== '80' && window.location.port !== '443';
if (isDev) {
var script = document.createElement('script');
script.src = 'https://unpkg.com/vconsole@latest/dist/vconsole.min.js';
script.onload = function() {
new VConsole();
};
document.body.appendChild(script);
}
</script>
</body>
</html>