-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_simple_loading.html
More file actions
85 lines (72 loc) · 3.14 KB
/
test_simple_loading.html
File metadata and controls
85 lines (72 loc) · 3.14 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Loading Test</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h1>Simple Loading Test</h1>
<button class="btn btn-primary" onclick="testLoading()">Test Loading</button>
<div id="console-output" class="mt-3 p-3 bg-light">
<h5>Console Output:</h5>
<div id="log"></div>
</div>
</div>
<!-- 简单的 CSS 加载遮罩 -->
<div id="loadingOverlay" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 9999; align-items: center; justify-content: center;">
<div style="background: white; padding: 20px; border-radius: 8px; text-align: center;">
<div class="spinner-border text-primary mb-3" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p id="loadingMessage">正在加载...</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
function log(message) {
const logDiv = document.getElementById('log');
logDiv.innerHTML += `<div>${new Date().toLocaleTimeString()}: ${message}</div>`;
console.log(message);
}
function showLoading(message = '加载中...') {
log('showLoading called with message: ' + message);
const loadingOverlay = document.getElementById('loadingOverlay');
const loadingMessage = document.getElementById('loadingMessage');
if (loadingOverlay && loadingMessage) {
loadingMessage.textContent = message;
loadingOverlay.style.display = 'flex';
log('Loading overlay shown');
} else {
log('Loading overlay elements not found');
}
}
function hideLoading() {
log('hideLoading called');
const loadingOverlay = document.getElementById('loadingOverlay');
if (loadingOverlay) {
loadingOverlay.style.display = 'none';
log('Loading overlay hidden');
} else {
log('Loading overlay element not found');
}
}
async function testLoading() {
try {
log('Test starting...');
showLoading('正在测试加载...');
// Simulate some work
await new Promise(resolve => setTimeout(resolve, 3000));
log('Test completed');
} catch (error) {
log('Test error: ' + error.message);
} finally {
log('Test finally - hiding loading');
hideLoading();
}
}
</script>
</body>
</html>