Update public/index.html
Browse files- public/index.html +209 -52
public/index.html
CHANGED
|
@@ -54,28 +54,78 @@
|
|
| 54 |
.result-item {
|
| 55 |
margin-top: 20px;
|
| 56 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
.result-item img {
|
| 60 |
display: block;
|
| 61 |
-
max-width:
|
|
|
|
| 62 |
margin: 0 auto 10px;
|
|
|
|
| 63 |
}
|
| 64 |
|
| 65 |
.result-item button {
|
| 66 |
background-color: #1f84d4;
|
| 67 |
color: #fff;
|
| 68 |
border: none;
|
| 69 |
-
padding:
|
| 70 |
border-radius: 4px;
|
| 71 |
cursor: pointer;
|
| 72 |
-
margin-
|
|
|
|
| 73 |
}
|
| 74 |
|
| 75 |
.result-item p {
|
| 76 |
margin: 5px 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
}
|
| 78 |
</style>
|
|
|
|
| 79 |
</head>
|
| 80 |
|
| 81 |
<body>
|
|
@@ -90,63 +140,170 @@
|
|
| 90 |
<div id="result-container"></div>
|
| 91 |
</div>
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
<script>
|
| 94 |
function search() {
|
| 95 |
var name = document.getElementById("name").value;
|
| 96 |
if (name === "") {
|
| 97 |
alert("请先输入昵称哦~");
|
| 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 |
-
itemDiv.appendChild(button);
|
| 138 |
-
|
| 139 |
-
resultContainer.appendChild(itemDiv);
|
| 140 |
});
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
</script>
|
| 151 |
</body>
|
| 152 |
|
|
|
|
| 54 |
.result-item {
|
| 55 |
margin-top: 20px;
|
| 56 |
text-align: center;
|
| 57 |
+
border: 1px solid #eee;
|
| 58 |
+
padding: 15px;
|
| 59 |
+
border-radius: 8px;
|
| 60 |
+
background-color: #fafafa;
|
| 61 |
}
|
| 62 |
|
| 63 |
.result-item img {
|
| 64 |
display: block;
|
| 65 |
+
max-width: 100px;
|
| 66 |
+
height: auto;
|
| 67 |
margin: 0 auto 10px;
|
| 68 |
+
border-radius: 50%;
|
| 69 |
}
|
| 70 |
|
| 71 |
.result-item button {
|
| 72 |
background-color: #1f84d4;
|
| 73 |
color: #fff;
|
| 74 |
border: none;
|
| 75 |
+
padding: 8px 16px;
|
| 76 |
border-radius: 4px;
|
| 77 |
cursor: pointer;
|
| 78 |
+
margin-top: 10px;
|
| 79 |
+
margin-right: 5px;
|
| 80 |
}
|
| 81 |
|
| 82 |
.result-item p {
|
| 83 |
margin: 5px 0;
|
| 84 |
+
font-size: 14px;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* Modal Styles */
|
| 88 |
+
.modal {
|
| 89 |
+
display: none;
|
| 90 |
+
position: fixed;
|
| 91 |
+
z-index: 1000;
|
| 92 |
+
left: 0;
|
| 93 |
+
top: 0;
|
| 94 |
+
width: 100%;
|
| 95 |
+
height: 100%;
|
| 96 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
.modal-content {
|
| 100 |
+
position: relative;
|
| 101 |
+
background-color: #fff;
|
| 102 |
+
margin: 10% auto;
|
| 103 |
+
padding: 20px;
|
| 104 |
+
border-radius: 8px;
|
| 105 |
+
width: 90%;
|
| 106 |
+
max-width: 400px;
|
| 107 |
+
text-align: center;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.close-btn {
|
| 111 |
+
position: absolute;
|
| 112 |
+
top: 10px;
|
| 113 |
+
right: 15px;
|
| 114 |
+
font-size: 24px;
|
| 115 |
+
color: #aaa;
|
| 116 |
+
cursor: pointer;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.close-btn:hover {
|
| 120 |
+
color: #000;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.detail-info p {
|
| 124 |
+
margin: 8px 0;
|
| 125 |
+
font-size: 16px;
|
| 126 |
}
|
| 127 |
</style>
|
| 128 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
|
| 129 |
</head>
|
| 130 |
|
| 131 |
<body>
|
|
|
|
| 140 |
<div id="result-container"></div>
|
| 141 |
</div>
|
| 142 |
|
| 143 |
+
<!-- Detail Modal -->
|
| 144 |
+
<div id="detailModal" class="modal">
|
| 145 |
+
<span class="close-btn" onclick="closeDetailModal()">×</span>
|
| 146 |
+
<div class="modal-content">
|
| 147 |
+
<div class="detail-info" id="detailInfo"></div>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
|
| 151 |
<script>
|
| 152 |
function search() {
|
| 153 |
var name = document.getElementById("name").value;
|
| 154 |
if (name === "") {
|
| 155 |
alert("请先输入昵称哦~");
|
| 156 |
+
return;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
const url = `/search?name=${encodeURIComponent(name)}`;
|
| 160 |
+
fetch(url)
|
| 161 |
+
.then(response => {
|
| 162 |
+
if (!response.ok) {
|
| 163 |
+
throw new Error('Network response was not ok');
|
| 164 |
+
}
|
| 165 |
+
return response.json();
|
| 166 |
+
})
|
| 167 |
+
.then(data => {
|
| 168 |
+
var code = data.code;
|
| 169 |
+
var resultContainer = document.getElementById("result-container");
|
| 170 |
+
resultContainer.innerHTML = '';
|
| 171 |
+
|
| 172 |
+
if (code === 200) {
|
| 173 |
+
var list = data.data.list;
|
| 174 |
+
list.forEach(item => {
|
| 175 |
+
var itemDiv = document.createElement('div');
|
| 176 |
+
itemDiv.classList.add('result-item');
|
| 177 |
+
|
| 178 |
+
var img = document.createElement('img');
|
| 179 |
+
img.src = item.avatar || 'https://web.bldimg.com/cblued/static/default.1c2b240hi2sg3rh.png';
|
| 180 |
+
itemDiv.appendChild(img);
|
| 181 |
+
|
| 182 |
+
var uidP = document.createElement('p');
|
| 183 |
+
uidP.textContent = `UID: ${item.uid}`;
|
| 184 |
+
itemDiv.appendChild(uidP);
|
| 185 |
+
|
| 186 |
+
var unionUidP = document.createElement('p');
|
| 187 |
+
unionUidP.textContent = `ID: ${item.uuid}`;
|
| 188 |
+
itemDiv.appendChild(unionUidP);
|
| 189 |
+
|
| 190 |
+
// 普通跳转按钮
|
| 191 |
+
var homeBtn = document.createElement('button');
|
| 192 |
+
homeBtn.textContent = "打开主页";
|
| 193 |
+
homeBtn.addEventListener('click', function () {
|
| 194 |
+
window.location.href = `/home?id=${item.uid}`;
|
|
|
|
|
|
|
|
|
|
| 195 |
});
|
| 196 |
+
itemDiv.appendChild(homeBtn);
|
| 197 |
+
|
| 198 |
+
// 查看详细信息按钮
|
| 199 |
+
var detailBtn = document.createElement('button');
|
| 200 |
+
detailBtn.textContent = "查看信息";
|
| 201 |
+
detailBtn.addEventListener('click', function () {
|
| 202 |
+
fetchDetail(item.uid, item.uuid);
|
| 203 |
+
});
|
| 204 |
+
itemDiv.appendChild(detailBtn);
|
| 205 |
+
|
| 206 |
+
resultContainer.appendChild(itemDiv);
|
| 207 |
+
});
|
| 208 |
+
} else {
|
| 209 |
+
alert("查无此人");
|
| 210 |
+
}
|
| 211 |
+
})
|
| 212 |
+
.catch(error => {
|
| 213 |
+
console.error('Fetch Error:', error);
|
| 214 |
+
alert("查询出错,请稍后再试");
|
| 215 |
+
});
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
function fetchDetail(uid, uuid) {
|
| 219 |
+
fetch(`/getDetail?id=${encodeURIComponent(uid)}`)
|
| 220 |
+
.then(response => response.json())
|
| 221 |
+
.then(data => {
|
| 222 |
+
if (data && data.userInfo) {
|
| 223 |
+
fetch('/viewPhone?id=' + a(uuid))
|
| 224 |
+
.then(response => response.json())
|
| 225 |
+
.then(phonedata => {
|
| 226 |
+
const info = data.userInfo;
|
| 227 |
+
const detailHtml = `
|
| 228 |
+
<p><strong>昵称:</strong>${info.name || '未知'}</p>
|
| 229 |
+
<p><strong>信息:</strong>${info.age}/${info.height}/${info.weight}</p>
|
| 230 |
+
<p><strong>角色:</strong>${info.role}</p>
|
| 231 |
+
<p><strong>地区:</strong>${info.area || '未知'}</p>
|
| 232 |
+
<p><strong>bind:</strong>${phonedata.data[0].bind}</p>
|
| 233 |
+
<p><strong>relation:</strong>${phonedata.data[0].relation}</p>
|
| 234 |
+
`;
|
| 235 |
+
document.getElementById('detailInfo').innerHTML = detailHtml;
|
| 236 |
+
document.getElementById('detailModal').style.display = 'block';
|
| 237 |
+
})
|
| 238 |
+
.catch(err => {
|
| 239 |
+
console.error('Phone fetch error:', err);
|
| 240 |
+
})
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
} else {
|
| 245 |
+
alert("未获取到详细信息");
|
| 246 |
+
}
|
| 247 |
+
})
|
| 248 |
+
.catch(err => {
|
| 249 |
+
console.error('Detail fetch error:', err);
|
| 250 |
+
alert("加载详细信息失败");
|
| 251 |
+
});
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
function closeDetailModal() {
|
| 255 |
+
document.getElementById('detailModal').style.display = 'none';
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
window.onclick = function (event) {
|
| 259 |
+
const modal = document.getElementById('detailModal');
|
| 260 |
+
if (event.target === modal) {
|
| 261 |
+
closeDetailModal();
|
| 262 |
}
|
| 263 |
+
};
|
| 264 |
+
|
| 265 |
+
const PREFIX = "df0b".toLowerCase();
|
| 266 |
+
const KEY = CryptoJS.enc.Base64.parse("VlEc5qsEDXWChrWJ0AzMXQ==");
|
| 267 |
+
const IV = CryptoJS.enc.Base64.parse("MC8Lpxk9zqyuRPXMdO8rJQ==");
|
| 268 |
+
|
| 269 |
+
// 加密函数
|
| 270 |
+
function a(strData) {
|
| 271 |
+
// 生成16字节随机密钥
|
| 272 |
+
const randomKey = CryptoJS.lib.WordArray.random(16);
|
| 273 |
+
|
| 274 |
+
// 加密数据
|
| 275 |
+
const encryptedData = encryptData(KEY, strData, randomKey);
|
| 276 |
+
const encryptedHex = bytesToHex(encryptedData);
|
| 277 |
+
|
| 278 |
+
// 编码随机密钥
|
| 279 |
+
const encodedKey = bytesToHex(randomKey);
|
| 280 |
+
|
| 281 |
+
// 计算前缀的第一个字符作为十六进制数的值
|
| 282 |
+
const prefixValue = parseInt(PREFIX[0], 16);
|
| 283 |
+
|
| 284 |
+
// 组合结果
|
| 285 |
+
return PREFIX + encryptedHex.substring(0, prefixValue) + encodedKey + encryptedHex.substring(prefixValue);
|
| 286 |
}
|
| 287 |
+
|
| 288 |
+
function encryptData(key, data, iv) {
|
| 289 |
+
// 使用CBC模式和PKCS7填充
|
| 290 |
+
const encrypted = CryptoJS.AES.encrypt(
|
| 291 |
+
data,
|
| 292 |
+
key,
|
| 293 |
+
{
|
| 294 |
+
iv: iv,
|
| 295 |
+
mode: CryptoJS.mode.CBC,
|
| 296 |
+
padding: CryptoJS.pad.Pkcs7
|
| 297 |
+
}
|
| 298 |
+
);
|
| 299 |
+
return encrypted.ciphertext;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
function bytesToHex(byteArray) {
|
| 303 |
+
return byteArray.toString(CryptoJS.enc.Hex).toUpperCase();
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
|
| 307 |
</script>
|
| 308 |
</body>
|
| 309 |
|