Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
207 lines (186 loc) · 6.63 KB
/
Copy pathindex.html
File metadata and controls
207 lines (186 loc) · 6.63 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IP 信息查询</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
background: #f5f5f7;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
padding: 40px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
max-width: 700px;
width: 100%;
}
.info-item {
display: flex;
align-items: center;
padding: 18px 0;
border-bottom: 1px solid #e5e5e7;
font-size: 18px;
color: #333;
}
.info-item:last-child {
border-bottom: none;
}
.icon {
width: 30px;
margin-right: 15px;
font-size: 24px;
}
.welcome {
font-size: 28px;
font-weight: 600;
margin-bottom: 30px;
display: flex;
align-items: center;
color: #1a1a1a;
}
.flag {
width: 60px;
height: 40px;
margin-left: auto;
border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
object-fit: cover;
}
.loading {
text-align: center;
color: #666;
font-size: 18px;
padding: 40px 0;
}
.error {
color: #ff3b30;
text-align: center;
font-size: 18px;
padding: 40px 0;
}
.value {
color: #007AFF;
font-weight: 500;
}
.label {
color: #666;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.container {
animation: fadeIn 0.5s ease-out;
}
.info-item {
animation: fadeIn 0.5s ease-out;
animation-fill-mode: both;
}
.info-item:nth-child(1) { animation-delay: 0.1s; }
.info-item:nth-child(2) { animation-delay: 0.2s; }
.info-item:nth-child(3) { animation-delay: 0.3s; }
.info-item:nth-child(4) { animation-delay: 0.4s; }
.info-item:nth-child(5) { animation-delay: 0.5s; }
</style>
</head>
<body>
<div class="container">
<div id="content">
<div class="loading">正在加载您的信息...</div>
</div>
</div>
<script>
// 国家代码到中文名称的映射
const countryNames = {
'US': '美国',
'CN': '中国',
'JP': '日本',
'GB': '英国',
'DE': '德国',
'FR': '法国',
'KR': '韩国',
'CA': '加拿大',
'AU': '澳大利亚',
'RU': '俄罗斯',
'IN': '印度',
'BR': '巴西',
'SG': '新加坡',
'HK': '香港',
'TW': '台湾',
'IT': '意大利',
'ES': '西班牙',
'NL': '荷兰',
'SE': '瑞典',
'CH': '瑞士'
};
// 格式化日期
function formatDate() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const weekdays = ['日', '一', '二', '三', '四', '五', '六'];
const weekday = weekdays[now.getDay()];
return `${year}年${month}月${day}日 星期${weekday}`;
}
async function fetchIPInfo() {
try {
const response = await fetch('/api/ip-info');
const data = await response.json();
// 获取中文国家名
const countryNameCN = countryNames[data.countryCode] || data.countryCode || '未知地区';
const contentDiv = document.getElementById('content');
contentDiv.innerHTML = `
<div class="welcome">
<span><span class="icon">🏠</span> 欢迎来自 ${countryNameCN} ${data.cityName || ''} 的朋友</span>
<img src="https://flagcdn.com/60x40/${(data.countryCode || 'un').toLowerCase()}.png"
alt="${countryNameCN}"
class="flag"
onerror="this.style.display='none'">
</div>
<div class="info-item">
<span class="icon">📅</span>
<span class="label">今天是 <span class="value">${formatDate()}</span></span>
</div>
<div class="info-item">
<span class="icon">🌐</span>
<span class="label">您的IP地址是: <span class="value">${data.ip || '未知'}</span></span>
</div>
<div class="info-item">
<span class="icon">💻</span>
<span class="label">您正在使用 <span class="value">${data.os || '未知'}</span> 系统</span>
</div>
<div class="info-item">
<span class="icon">🔍</span>
<span class="label">您正在使用 <span class="value">${data.browser || '未知'}</span> 浏览器</span>
</div>
`;
} catch (error) {
document.getElementById('content').innerHTML =
'<div class="error">获取信息失败,请稍后重试</div>';
}
}
// 页面加载后立即获取信息
fetchIPInfo();
</script>
</body>
</html>