Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jason5ng32 committed May 16, 2024
1 parent bd8c38d commit b6ad56f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 46 deletions.
12 changes: 2 additions & 10 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@
"Human_Pct": "Human Traffic Percentage:"
},
"proxyDetect": {
"yes": "Possibly a proxy or VPN",
"yes": "Must be a proxy or VPN",
"maybe": "Possibly a proxy or VPN",
"no": "Not a proxy or VPN",
"unknownProxyType": "Unknown type",
"unknownProtocol": "Unknown protocol",
Expand Down Expand Up @@ -356,7 +357,6 @@
"DNSResolver": "Open DNS Resolution panel",
"ToggleMaps": "Toggle Maps",
"IPCheck": "Query IP Address",
"AddBingMapKey": "Add Bing Map API Key",
"ToggleInfoMask": "Toggle Info Masking",
"Help": "Show Shortcut Keys",
"HelpNote": "People who use shortcuts are really awesome!",
Expand All @@ -379,14 +379,6 @@
"copyRightLink": "https://ipcheck.ing",
"copyRightLinkName": "IPCheck.ing"
},
"addBingMapKey": {
"Title": "Add Bing Map API Key",
"Note": "After adding, the map can be displayed in the IP information. The API Key will only be saved in the current browser for the next use, and will not be uploaded to the server.",
"Placeholder": "Please enter Bing Map API Key",
"Button": "Save",
"removeButton": "Remove",
"Error": "Please enter a valid Bing Map API Key."
},
"helpModal": {
"Title": "Keyboard Shortcuts"
},
Expand Down
12 changes: 2 additions & 10 deletions frontend/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@
"Human_Pct": "Pourcentage de trafic humain :"
},
"proxyDetect": {
"yes": "Possiblement un proxy ou un VPN",
"yes": "Doit être un proxy ou un VPN",
"maybe": "Possiblement un proxy ou un VPN",
"no": "Pas un proxy ou un VPN",
"unknownProxyType": "Type inconnu",
"unknownProtocol": "Protocole inconnu",
Expand Down Expand Up @@ -356,7 +357,6 @@
"DNSResolver": "Ouvrir le Résolution DNS",
"ToggleMaps": "Activer/désactiver les cartes",
"IPCheck": "Vérification IP",
"AddBingMapKey": "Ajouter une clé API Bing Map",
"ToggleInfoMask": "Activer/désactiver le masquage des informations",
"Help": "Afficher les raccourcis clavier",
"HelpNote": "Les personnes qui utilisent des raccourcis clavier sont vraiment géniales !",
Expand All @@ -379,14 +379,6 @@
"copyRightLink": "https://ipcheck.ing",
"copyRightLinkName": "IPCheck.ing"
},
"addBingMapKey": {
"Title": "Ajouter une clé API Bing Map",
"Note": "Après l'ajout, la carte peut être affichée dans les informations IP. La clé API sera uniquement enregistrée dans le navigateur actuel pour une utilisation ultérieure et ne sera pas téléchargée sur le serveur.",
"Placeholder": "Veuillez entrer une clé API Bing Map valide",
"Button": "Enregistrer",
"removeButton": "Supprimer",
"Error": "Veuillez entrer une clé API Bing Map valide."
},
"helpModal": {
"Title": "Raccourcis"
},
Expand Down
12 changes: 2 additions & 10 deletions frontend/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@
"Human_Pct": "人类流量占比:"
},
"proxyDetect": {
"yes": "可能是代理或 VPN",
"yes": "是代理或 VPN",
"maybe": "可能是代理或 VPN",
"no": "不是代理或 VPN",
"unknownProxyType": "未知类型",
"unknownProtocol": "未知协议",
Expand Down Expand Up @@ -356,7 +357,6 @@
"DNSResolver": "打开 DNS 解析器面板",
"ToggleMaps": "切换地图显示",
"IPCheck": "IP 查询",
"AddBingMapKey": "添加 Bing Map API Key",
"ToggleInfoMask": "切换信息隐藏",
"Help": "显示快捷键",
"HelpNote": "使用快捷键的人,是喜欢效率的人,你真棒!",
Expand All @@ -379,14 +379,6 @@
"copyRightLink": "https://ipcheck.ing",
"copyRightLinkName": "IPCheck.ing"
},
"addBingMapKey": {
"Title": "添加 Bing Map API Key",
"Note": "添加后,可以在 IP 信息中显示地图。API Key 只会在当前浏览器中保存,方便下次使用,不会上传到服务器。",
"Placeholder": "请输入 Bing Map API Key",
"Button": "保存",
"removeButton": "删除",
"Error": "请输入有效的 Bing Map API Key。"
},
"helpModal": {
"Title": "快捷键"
},
Expand Down
67 changes: 51 additions & 16 deletions frontend/utils/transform-ip-data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 解析IP数据
function transformDataFromIPapi(data,ipGeoSource,t,bingMapLanguage) {
function transformDataFromIPapi(data, ipGeoSource, t, bingMapLanguage) {
if (data.error) {
throw new Error(data.reason);
}
Expand All @@ -19,7 +19,7 @@ function transformDataFromIPapi(data,ipGeoSource,t,bingMapLanguage) {
};

if (ipGeoSource === 0) {
const proxyDetails = extractProxyDetails(data.proxyDetect,t);
const proxyDetails = extractProxyDetails(data.proxyDetect, t);
return {
...baseData,
...proxyDetails,
Expand All @@ -29,21 +29,56 @@ function transformDataFromIPapi(data,ipGeoSource,t,bingMapLanguage) {
return baseData;
};

// 提取代理信息
function extractProxyDetails(proxyDetect = {},t) {
const isProxy = proxyDetect.proxy === 'yes' ? t('ipInfos.proxyDetect.yes') :
proxyDetect.proxy === 'no' ? t('ipInfos.proxyDetect.no') :
t('ipInfos.proxyDetect.unknownProxyType');
const type = proxyDetect.type === 'Business' ? t('ipInfos.proxyDetect.type.Business') :
proxyDetect.type === 'Residential' ? t('ipInfos.proxyDetect.type.Residential') :
proxyDetect.type === 'Wireless' ? t('ipInfos.proxyDetect.type.Wireless') :
proxyDetect.type === 'Hosting' || proxyDetect.type === 'VPN' ? t('ipInfos.proxyDetect.type.Hosting') :
proxyDetect.type ? proxyDetect.type : t('ipInfos.proxyDetect.type.unknownType');
const proxyProtocol = proxyDetect.protocol === 'unknown' ? t('ipInfos.proxyDetect.unknownProtocol') :
proxyDetect.protocol ? proxyDetect.protocol : t('ipInfos.proxyDetect.unknownProtocol');
const proxyOperator = proxyDetect.operator ? proxyDetect.operator : "";
// 解析代理数据
function extractProxyDetails(proxyDetect = {}, t) {
const isProxy = determineIsProxy(proxyDetect, t);
const type = determineType(proxyDetect, t);
const proxyProtocol = determineProtocol(proxyDetect, t);
const proxyOperator = proxyDetect.operator || "";

return { isProxy, type, proxyProtocol, proxyOperator };
};
}

// 判断是否代理
function determineIsProxy(proxyDetect, t) {
if (proxyDetect.proxy === 'yes' && proxyDetect.protocol !== 'unknown') {
return t('ipInfos.proxyDetect.yes');
} else if (proxyDetect.proxy === 'yes') {
return t('ipInfos.proxyDetect.maybe');
} else if (proxyDetect.proxy === 'no') {
return t('ipInfos.proxyDetect.no');
} else {
return t('ipInfos.proxyDetect.unknownProxyType');
}
}

// 判断代理类型
function determineType(proxyDetect, t) {
switch (proxyDetect.type) {
case 'Business':
return t('ipInfos.proxyDetect.type.Business');
case 'Residential':
return t('ipInfos.proxyDetect.type.Residential');
case 'Wireless':
return t('ipInfos.proxyDetect.type.Wireless');
case 'Hosting':
return t('ipInfos.proxyDetect.type.Hosting');
case 'VPN':
if (proxyDetect.protocol === 'unknown') {
return t('ipInfos.proxyDetect.type.Hosting');
}
default:
return proxyDetect.type || t('ipInfos.proxyDetect.type.unknownType');
}
}

// 判断代理协议
function determineProtocol(proxyDetect, t) {
if (proxyDetect.protocol === 'unknown' || !proxyDetect.protocol) {
return t('ipInfos.proxyDetect.unknownProtocol');
} else {
return proxyDetect.protocol;
}
}

export { transformDataFromIPapi, extractProxyDetails };

0 comments on commit b6ad56f

Please sign in to comment.