-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex_github_optimized.html
More file actions
272 lines (236 loc) · 7.8 KB
/
index_github_optimized.html
File metadata and controls
272 lines (236 loc) · 7.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Beacon World App - 现代化社交学习应用">
<!-- 动态设置base href -->
<script>
// 立即执行,在其他资源加载前设置正确的base href
(function() {
const path = window.location.pathname;
let basePath = '/';
// 检测GitHub Pages项目页面
if (path.includes('/BeaconWorld_Web_Test/')) {
basePath = '/BeaconWorld_Web_Test/';
}
// 创建并设置base元素
const base = document.createElement('base');
base.href = basePath;
document.head.appendChild(base);
console.log('Base href 设置为:', basePath);
})();
</script>
<!-- iOS meta tags & icons -->
<meta name="apple-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="Beacon World App">
<link rel="apple-touch-icon" href="icons/Icon-192.png">
<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png"/>
<!-- 使用HTTPS加载model-viewer脚本 -->
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
<script nomodule src="https://unpkg.com/@google/model-viewer/dist/model-viewer-legacy.js"></script>
<title>Beacon World App - 现代化社交学习应用</title>
<link rel="manifest" href="manifest.json">
<style>
body {
margin: 0;
padding: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
overflow: hidden;
}
.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, #667eea 0%, #764ba2 100%);
color: white;
z-index: 9999;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 4px solid rgba(255,255,255,0.3);
border-top: 4px solid white;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: 20px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-text {
font-size: 18px;
font-weight: 500;
text-align: center;
margin-bottom: 10px;
}
.loading-debug {
font-size: 12px;
opacity: 0.7;
text-align: center;
font-family: monospace;
}
.error-container {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.95);
color: #333;
padding: 30px;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
max-width: 500px;
text-align: center;
z-index: 10000;
}
.error-title {
color: #dc3545;
font-size: 20px;
font-weight: bold;
margin-bottom: 15px;
}
.error-message {
margin-bottom: 20px;
line-height: 1.5;
}
.error-actions {
display: flex;
gap: 10px;
justify-content: center;
}
.btn {
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
text-decoration: none;
display: inline-block;
}
.btn-primary {
background: #007bff;
color: white;
}
.btn-secondary {
background: #6c757d;
color: white;
}
</style>
</head>
<body>
<div class="loading-container" id="loading">
<div class="loading-spinner"></div>
<div class="loading-text">正在加载 Beacon World App...</div>
<div class="loading-debug" id="loading-debug">初始化中...</div>
</div>
<div class="error-container" id="error-container">
<div class="error-title">⚠️ 加载失败</div>
<div class="error-message" id="error-message">
应用加载遇到问题,请尝试以下解决方案:
</div>
<div class="error-actions">
<button class="btn btn-primary" onclick="location.reload()">🔄 重新加载</button>
<a class="btn btn-secondary" href="debug.html">🔧 诊断工具</a>
</div>
</div>
<script>
// 调试信息更新
function updateDebugInfo(message) {
const debugEl = document.getElementById('loading-debug');
if (debugEl) {
debugEl.textContent = message;
}
console.log('🔧', message);
}
// 显示错误
function showError(message) {
const errorContainer = document.getElementById('error-container');
const errorMessage = document.getElementById('error-message');
const loading = document.getElementById('loading');
if (errorMessage) errorMessage.textContent = message;
if (errorContainer) errorContainer.style.display = 'block';
if (loading) loading.style.display = 'none';
}
// 隐藏加载界面
function hideLoading() {
const loading = document.getElementById('loading');
if (loading) loading.style.display = 'none';
}
// 资源加载检查
function checkCriticalResources() {
updateDebugInfo('检查关键资源...');
const resources = ['flutter_bootstrap.js', 'main.dart.js', 'manifest.json'];
let loadedCount = 0;
let errorCount = 0;
resources.forEach(resource => {
fetch(resource, { method: 'HEAD' })
.then(response => {
if (response.ok) {
loadedCount++;
updateDebugInfo(`✅ ${resource} 正常 (${loadedCount}/${resources.length})`);
} else {
errorCount++;
console.error(`❌ ${resource} 状态码: ${response.status}`);
}
})
.catch(error => {
errorCount++;
console.error(`❌ ${resource} 加载失败:`, error);
})
.finally(() => {
if (loadedCount + errorCount === resources.length) {
if (errorCount > 0) {
showError(`有 ${errorCount} 个关键资源加载失败,请检查网络连接或稍后重试。`);
} else {
updateDebugInfo('所有资源检查完成,启动应用...');
}
}
});
});
}
// 错误处理
window.addEventListener('error', function(event) {
console.error('页面错误:', event.error);
if (event.target && event.target.src) {
const src = event.target.src;
if (src.includes('flutter') || src.includes('main.dart')) {
showError('Flutter 应用加载失败,请检查网络连接或清除浏览器缓存后重试。');
}
}
});
// Flutter 事件监听
window.addEventListener('flutter-first-frame', function() {
updateDebugInfo('Flutter 首帧渲染完成');
hideLoading();
});
// 超时处理
setTimeout(function() {
const loading = document.getElementById('loading');
if (loading && loading.style.display !== 'none') {
showError('应用加载超时,请检查网络连接或尝试刷新页面。');
}
}, 15000);
// 页面加载完成后检查资源
window.addEventListener('load', function() {
updateDebugInfo('页面加载完成,检查资源...');
setTimeout(checkCriticalResources, 500);
});
// 立即更新调试信息
updateDebugInfo(`当前路径: ${window.location.pathname}`);
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>