mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-01-31 09:03:19 +08:00
Feat:上传支持记录IP具体位置
This commit is contained in:
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
css/83.d49213f5.css.gz
Normal file
BIN
css/83.d49213f5.css.gz
Normal file
Binary file not shown.
@@ -73,44 +73,13 @@ async function dealByIP(data) {
|
||||
}
|
||||
});
|
||||
|
||||
const promises = Array.from(ipSet).map(async ip => {
|
||||
ipSet.forEach(async ip => {
|
||||
let ipData = data.filter(item => item.metadata?.UploadIP === ip);
|
||||
let count = ipData.length;
|
||||
let address = await getIPAddress(ip);
|
||||
return {ip, address, count, data: ipData};
|
||||
let address = ipData[0].metadata?.UploadAddress || '未知';
|
||||
dealedData.push({ip, address, count, data: ipData});
|
||||
});
|
||||
|
||||
dealedData = await Promise.all(promises);
|
||||
return dealedData;
|
||||
}
|
||||
|
||||
// 获取IP地址
|
||||
async function getIPAddress(ip) {
|
||||
let address = '未知';
|
||||
try {
|
||||
const ipInfo = await fetch(`https://apimobile.meituan.com/locate/v2/ip/loc?rgeo=true&ip=${ip}`);
|
||||
const ipData = await ipInfo.json();
|
||||
|
||||
if (ipInfo.ok && ipData.data) {
|
||||
const lng = ipData.data?.lng || 0;
|
||||
const lat = ipData.data?.lat || 0;
|
||||
|
||||
// 读取具体地址
|
||||
const addressInfo = await fetch(`https://apimobile.meituan.com/group/v1/city/latlng/${lat},${lng}?tag=0`);
|
||||
const addressData = await addressInfo.json();
|
||||
|
||||
if (addressInfo.ok && addressData.data) {
|
||||
// 根据各字段是否存在,拼接地址
|
||||
address = [
|
||||
addressData.data.detail,
|
||||
addressData.data.city,
|
||||
addressData.data.province,
|
||||
addressData.data.country
|
||||
].filter(Boolean).join(', ');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching IP address:', error);
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ export async function onRequestPost(context) { // Contents of context object
|
||||
if (isBlockedIp) {
|
||||
return new Response('Error: Your IP is blocked', { status: 403 });
|
||||
}
|
||||
// 获取IP地址
|
||||
const ipAddress = await getIPAddress(uploadIp);
|
||||
|
||||
// 读取上传配置
|
||||
uploadConfig = await fetchUploadConfig(env);
|
||||
@@ -147,6 +149,7 @@ export async function onRequestPost(context) { // Contents of context object
|
||||
FileType: fileType,
|
||||
FileSize: fileSize,
|
||||
UploadIP: uploadIp,
|
||||
UploadAddress: ipAddress,
|
||||
ListType: "None",
|
||||
TimeStamp: time,
|
||||
Label: "None",
|
||||
@@ -720,3 +723,35 @@ function generateShortId(length = 8) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// 获取IP地址
|
||||
async function getIPAddress(ip) {
|
||||
let address = '未知';
|
||||
try {
|
||||
const ipInfo = await fetch(`https://apimobile.meituan.com/locate/v2/ip/loc?rgeo=true&ip=${ip}`);
|
||||
const ipData = await ipInfo.json();
|
||||
|
||||
if (ipInfo.ok && ipData.data) {
|
||||
const lng = ipData.data?.lng || 0;
|
||||
const lat = ipData.data?.lat || 0;
|
||||
|
||||
// 读取具体地址
|
||||
const addressInfo = await fetch(`https://apimobile.meituan.com/group/v1/city/latlng/${lat},${lng}?tag=0`);
|
||||
const addressData = await addressInfo.json();
|
||||
|
||||
if (addressInfo.ok && addressData.data) {
|
||||
// 根据各字段是否存在,拼接地址
|
||||
address = [
|
||||
addressData.data.detail,
|
||||
addressData.data.city,
|
||||
addressData.data.province,
|
||||
addressData.data.country
|
||||
].filter(Boolean).join(', ');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching IP address:', error);
|
||||
}
|
||||
return address;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/logo.png"><title>Sanyue ImgHub</title><script defer="defer" src="/js/app.7ebf278b.js"></script><link href="/css/app.9a1a6b51.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but sanyue_imghub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html><style>/* 下拉菜单样式 */
|
||||
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/logo.png"><title>Sanyue ImgHub</title><script defer="defer" src="/js/app.91b8220c.js"></script><link href="/css/app.9a1a6b51.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but sanyue_imghub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html><style>/* 下拉菜单样式 */
|
||||
.el-dropdown__popper.el-popper {
|
||||
border-radius: 12px;
|
||||
border: none;
|
||||
|
||||
BIN
index.html.gz
BIN
index.html.gz
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
js/320.00292d8a.js.gz
Normal file
BIN
js/320.00292d8a.js.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
js/320.00292d8a.js.map.gz
Normal file
BIN
js/320.00292d8a.js.map.gz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
2
js/83.d626d64b.js
Normal file
2
js/83.d626d64b.js
Normal file
File diff suppressed because one or more lines are too long
BIN
js/83.d626d64b.js.gz
Normal file
BIN
js/83.d626d64b.js.gz
Normal file
Binary file not shown.
1
js/83.d626d64b.js.map
Normal file
1
js/83.d626d64b.js.map
Normal file
File diff suppressed because one or more lines are too long
BIN
js/83.d626d64b.js.map.gz
Normal file
BIN
js/83.d626d64b.js.map.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
46
js/app.91b8220c.js
Normal file
46
js/app.91b8220c.js
Normal file
File diff suppressed because one or more lines are too long
BIN
js/app.91b8220c.js.gz
Normal file
BIN
js/app.91b8220c.js.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
js/app.91b8220c.js.map.gz
Normal file
BIN
js/app.91b8220c.js.map.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user