-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerInfo-Fluent.html
More file actions
300 lines (260 loc) · 9.39 KB
/
ServerInfo-Fluent.html
File metadata and controls
300 lines (260 loc) · 9.39 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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>InCraftTime服务器状态</title>
<style>
:root {
--acrylic-background: rgba(255, 255, 255, 0.6);
--acrylic-border: rgba(255, 255, 255, 0.8);
--elevation-shadow: 0 8px 16px rgba(0, 0, 0, 0.14);
--system-base: #0078D4;
--system-success: #107C10;
--system-critical: #D83B01;
--system-warning: #F2C811;
}
@media (prefers-color-scheme: dark) {
:root {
--acrylic-background: rgba(32, 32, 32, 0.6);
--acrylic-border: rgba(128, 128, 128, 0.2);
}
}
body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: #f3f3f3;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
}
.server-card {
width: 480px;
background: var(--acrylic-background);
border: 1px solid var(--acrylic-border);
border-radius: 8px;
padding: 24px;
margin: 20px;
color: #1a1a1a;
backdrop-filter: blur(20px);
box-shadow: var(--elevation-shadow);
transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
}
.server-card:hover {
transform: translateY(-2px);
}
.status-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.status-indicator {
display: flex;
align-items: center;
gap: 12px;
}
.status-dot {
width: 16px;
height: 16px;
border-radius: 50%;
box-shadow: 0 0 8px currentColor;
}
.online {
background: var(--system-success);
animation: pulse 1.5s infinite;
}
.offline {
background: var(--system-critical);
}
.refresh-btn {
background: var(--system-base);
color: white;
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-weight: 600;
transition: all 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
display: flex;
align-items: center;
gap: 8px;
}
.refresh-btn:hover {
background: #006CBE;
transform: scale(1.05);
}
.refresh-btn:active {
transform: scale(0.95);
}
.refresh-btn:disabled {
background: #E6E6E6;
color: #666;
cursor: not-allowed;
}
.server-info {
margin: 16px 0;
line-height: 1.6;
padding: 12px;
background: rgba(255, 255, 255, 0.4);
border-radius: 6px;
}
.info-label {
color: #666;
font-weight: 600;
margin-right: 8px;
}
.player-list {
background: rgba(255, 255, 255, 0.3);
border-radius: 8px;
padding: 12px;
margin-top: 16px;
max-height: 200px;
overflow-y: auto;
}
.loading {
text-align: center;
padding: 24px;
color: #666;
font-style: italic;
}
.player-percent {
color: #888;
font-size: 0.9em;
margin-left: 8px;
}
.progress-container {
width: 100%;
height: 4px;
background: rgba(0, 0, 0, 0.1);
border-radius: 2px;
margin-top: 12px;
overflow: hidden;
}
.progress-bar {
height: 100%;
background: var(--system-base);
border-radius: 2px;
width: 0;
transition: width 0.5s cubic-bezier(0.1, 0.9, 0.2, 1);
}
.progress-bar.medium-usage {
background: var(--system-warning);
}
.progress-bar.high-usage {
background: var(--system-critical);
}
@keyframes pulse {
0% { opacity: 0.8; }
50% { opacity: 1; }
100% { opacity: 0.8; }
}
</style>
</head>
<body>
<!-- 保持原有HTML结构不变 -->
<div class="server-card">
<div class="status-header">
<div class="status-indicator">
<div class="status-dot offline"></div>
<h2>服务器状态加载中...</h2>
</div>
<button class="refresh-btn" onclick="refreshData()" disabled>
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
<path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/>
</svg>
刷新
</button>
</div>
<div class="loading">正在获取服务器数据...</div>
</div>
<!-- 保持原有JavaScript逻辑不变 -->
<script>
const API_URL = 'https://api.mcstatus.io/v2/status/java/mc.incrafttime.top';
const card = document.querySelector('.server-card');
const refreshBtn = document.querySelector('.refresh-btn');
async function fetchData() {
try {
refreshBtn.disabled = true;
refreshBtn.textContent = '刷新中...';
const response = await fetch(API_URL);
if (!response.ok) throw new Error('请求失败');
const data = await response.json();
updateServerStatus(data);
refreshBtn.disabled = false;
refreshBtn.textContent = '刷新';
} catch (error) {
card.querySelector('.loading').textContent = '数据加载失败';
refreshBtn.disabled = false;
refreshBtn.textContent = '刷新';
console.error('错误详情:', error);
}
}
function refreshData() {
const oldInfo = card.querySelectorAll('.server-info, .player-list');
oldInfo.forEach(element => element.remove());
const loading = document.createElement('div');
loading.className = 'loading';
loading.textContent = '正在刷新数据...';
card.appendChild(loading);
fetchData();
}
function updateServerStatus(data) {
card.querySelectorAll('.loading').forEach(el => el.remove());
const isOnline = data.online;
const statusDot = card.querySelector('.status-dot');
statusDot.className = `status-dot ${isOnline ? 'online' : 'offline'}`;
card.querySelector('h2').innerHTML = `
${data.host} 状态:
<span style="color: ${isOnline ? '#3ba55d' : '#ed4245'}">
${isOnline ? '在线' : '离线'}
</span>
`;
const infoContainer = document.createElement('div');
const online = data.players?.online || 0;
const max = data.players?.max || 0;
const percent = max > 0 ? ((online / max) * 100).toFixed(1) : '0.0';
infoContainer.innerHTML = `
<div class="server-info">
${data.motd?.html || '未知'}
</div>
<div class="server-info">
<span class="info-label">版本:</span>
${data.version?.name_html || '未知'}
</div>
<div class="server-info">
<span class="info-label">在线玩家:</span>
${online}/${max}
<span class="player-percent">(${percent}%)</span>
<div class="progress-container">
<div class="progress-bar" id="player-progress"></div>
</div>
</div>
`;
const progressBar = infoContainer.querySelector('#player-progress');
const percentage = max > 0 ? (online / max) : 0;
progressBar.style.width = `${percentage * 100}%`;
progressBar.className = 'progress-bar';
if (percentage >= 0.9) {
progressBar.classList.add('high-usage');
} else if (percentage >= 0.8) {
progressBar.classList.add('medium-usage');
}
if (isOnline && data.players?.list?.length > 0) {
const playerList = document.createElement('div');
playerList.className = 'player-list';
playerList.innerHTML = `
<div class="info-label">在线玩家列表:</div>
${data.players.list.map(player => `
<div>${player.name_clean}</div>
`).join('')}
`;
infoContainer.appendChild(playerList);
}
card.appendChild(infoContainer);
}
fetchData();
</script>
</body>
</html>