-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex_github_fixed.html
More file actions
181 lines (153 loc) · 5.43 KB
/
index_github_fixed.html
File metadata and controls
181 lines (153 loc) · 5.43 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<!-- GitHub Pages 专用修复版本 -->
<script>
// 立即执行,在其他资源加载前设置正确的base href
(function() {
const hostname = window.location.hostname;
const pathname = window.location.pathname;
const pathSegments = pathname.split('/').filter(segment => segment);
let basePath = '/';
// 检测GitHub Pages环境
if (hostname.includes('github.io')) {
if (pathSegments.length > 0) {
// GitHub Pages项目页面: username.github.io/repository-name/
basePath = '/' + pathSegments[0] + '/';
}
// 如果是用户页面 (username.github.io),保持 basePath = '/'
}
// 创建并插入base元素
const base = document.createElement('base');
base.href = basePath;
document.head.appendChild(base);
console.log('Environment detected:', hostname);
console.log('Base href set to:', basePath);
console.log('Full URL will be:', window.location.origin + basePath);
})();
</script>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="description" content="Beacon World App - 现代化社交学习应用">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 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>
/* 加载动画 */
.loading-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 9999;
color: white;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 3px solid rgba(255,255,255,0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
margin-bottom: 20px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.loading-text {
font-size: 18px;
margin-bottom: 10px;
}
.loading-progress {
font-size: 14px;
opacity: 0.8;
}
/* 隐藏加载完成后的容器 */
.loading-container.hidden {
display: none;
}
</style>
</head>
<body>
<!-- 加载指示器 -->
<div id="loading" class="loading-container">
<div class="loading-spinner"></div>
<div class="loading-text">Beacon World App</div>
<div class="loading-progress">正在加载应用...</div>
</div>
<!-- Flutter应用容器 -->
<div id="app-container" style="display: none;"></div>
<script>
// 加载状态管理
let loadingTimeout;
// 显示加载进度
function updateLoadingProgress(message) {
const progressElement = document.querySelector('.loading-progress');
if (progressElement) {
progressElement.textContent = message;
}
console.log('Loading:', message);
}
// 隐藏加载界面
function hideLoading() {
const loadingElement = document.getElementById('loading');
const appContainer = document.getElementById('app-container');
if (loadingElement) {
loadingElement.classList.add('hidden');
}
if (appContainer) {
appContainer.style.display = 'block';
}
if (loadingTimeout) {
clearTimeout(loadingTimeout);
}
}
// 设置超时提醒
loadingTimeout = setTimeout(() => {
updateLoadingProgress('加载时间较长,请检查网络连接...');
setTimeout(() => {
updateLoadingProgress('如果持续无法加载,请刷新页面重试');
}, 5000);
}, 10000);
// 监听Flutter应用加载完成
window.addEventListener('flutter-first-frame', () => {
updateLoadingProgress('应用加载完成!');
setTimeout(hideLoading, 500);
});
// 错误处理
window.addEventListener('error', (event) => {
console.error('加载错误:', event.error);
updateLoadingProgress('加载出现问题,正在重试...');
});
// 开始加载Flutter应用
updateLoadingProgress('正在初始化...');
</script>
<!-- Flutter Bootstrap -->
<script src="flutter_bootstrap.js" async></script>
<script>
// 额外的调试信息
console.log('=== Beacon World App Debug Info ===');
console.log('Current URL:', window.location.href);
console.log('Base URL:', document.querySelector('base')?.href || 'Not set');
console.log('Is GitHub Pages:', window.location.hostname.includes('github.io'));
console.log('=====================================');
</script>
</body>
</html>