Skip to content

Commit

Permalink
Add IP Score
Browse files Browse the repository at this point in the history
  • Loading branch information
jason5ng32 committed Dec 9, 2024
1 parent 4d2a59b commit dcf94be
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 7 deletions.
24 changes: 24 additions & 0 deletions frontend/components/IpInfos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,30 @@
</span>
</li>

<li v-show="(!isMobile || !isCardsCollapsed) && ipGeoSource === 0" class="jn-list-group-item"
:class="{ 'dark-mode': isDarkMode }">
<span class="jn-text col-auto">
<i class="bi bi-speedometer"></i>
{{ t('ipInfos.qualityScore') }} :&nbsp;
</span>

<span v-if="card.qualityScore !== 'unknown'" class="col-3 jn-risk-score ">
<span class="progress border" :class="[isDarkMode ? 'border-light bg-dark' : 'border-dark']"
role="progressbar" aria-label="Quality Score" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<span class="progress-bar" :class="[isDarkMode ? 'bg-light' : 'bg-dark']"
:style='"width:" + card.qualityScore +"%"'></span>
</span>
</span>

<span class="ps-2">
<span v-if="card.qualityScore === 'unknown'">
{{ t('ipInfos.qualityScoreUnknown') }}
</span>
<span v-else>{{ card.qualityScore }}%</span>
</span>

</li>

<li v-show="!isMobile || !isCardsCollapsed" class="jn-list-group-item border-0"
:class="{ 'dark-mode': isDarkMode }">
<span class="jn-text col-auto">
Expand Down
35 changes: 30 additions & 5 deletions frontend/components/widgets/QueryIP.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<!-- Search BTN -->
<button class="btn btn-primary queryip"
data-bs-toggle="modal" aria-label="IP Check" data-bs-target="#IPCheck" @click="openQueryIP"
v-tooltip="t('Tooltips.QueryIP')"><i class="bi bi-search"></i></button>
<button class="btn btn-primary queryip" data-bs-toggle="modal" aria-label="IP Check" data-bs-target="#IPCheck"
@click="openQueryIP" v-tooltip="t('Tooltips.QueryIP')"><i class="bi bi-search"></i></button>

<!-- Search Modal -->
<div class="modal fade" id="IPCheck" tabindex="-1" aria-labelledby="IPCheck" aria-hidden="true">
Expand Down Expand Up @@ -82,6 +81,32 @@
</span>
</li>

<li v-if="ipGeoSource === 0" class="jn-list-group-item"
:class="{ 'dark-mode': isDarkMode }">
<span class="jn-text col-auto">
<i class="bi bi-speedometer"></i>
{{ t('ipInfos.qualityScore') }} :&nbsp;
</span>

<span v-if="modalQueryResult.qualityScore !== 'unknown'"
class="col-3 jn-risk-score ">
<span class="progress border"
:class="[isDarkMode ? 'border-light bg-dark' : 'border-dark']"
role="progressbar" aria-label="Quality Score" aria-valuenow="0"
aria-valuemin="0" aria-valuemax="100">
<span class="progress-bar" :class="[isDarkMode ? 'bg-light' : 'bg-dark']"
:style='"width:" + modalQueryResult.qualityScore +"%"'></span>
</span>
</span>

<span class="ps-2">
<span v-if="modalQueryResult.qualityScore === 'unknown'">
{{ t('ipInfos.qualityScoreUnknown') }}
</span>
<span v-else>{{ modalQueryResult.qualityScore }}%</span>
</span>

</li>

<li class="list-group-item jn-list-group-item" :class="{ 'dark-mode': isDarkMode }">
<span class="jn-text col-auto">
Expand Down Expand Up @@ -122,7 +147,7 @@ import { transformDataFromIPapi } from '@/utils/transform-ip-data.js';
import { useI18n } from 'vue-i18n';
import { trackEvent } from '@/utils/use-analytics';
const {t} = useI18n();
const { t } = useI18n();
// 引入 Store
const store = useMainStore();
Expand Down Expand Up @@ -204,7 +229,7 @@ const fetchIPForModal = async (ip, sourceID = null) => {
if (data.error) {
throw new Error(data.reason || "IP lookup failed");
}
modalQueryResult.value = transformDataFromIPapi(data, source.id, t,lang.value);
modalQueryResult.value = transformDataFromIPapi(data, source.id, t, lang.value);
isChecking.value = "idle";
break;
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@
"SelectSource": "Select IP Geolocation Source",
"type": "Type",
"isProxy": "Proxy",
"qualityScore": "IP Quality",
"qualityScoreUnknown": "Score Unknown",
"ASNInfo": {
"note": "Related data for this AS:",
"asnName": "AS Name:",
Expand Down
2 changes: 2 additions & 0 deletions frontend/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@
"SelectSource": "Source de géolocalisation IP",
"type": "Type",
"isProxy": "Proxy",
"qualityScore": "Qualité IP",
"qualityScoreUnknown": "Score inconnu",
"ASNInfo": {
"note": "Données associées à cet AS :",
"asnName": "Nom de l'AS :",
Expand Down
2 changes: 2 additions & 0 deletions frontend/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@
"SelectSource": "选择 IP 归属地数据来源",
"type": "类型",
"isProxy": "代理",
"qualityScore": "IP 质量分",
"qualityScoreUnknown": "未知分数",
"ASNInfo": {
"note": "此 AS 的相关数据:",
"asnName": "AS 名称:",
Expand Down
8 changes: 7 additions & 1 deletion frontend/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}

.jn-ip-card1 {
min-height: 488px;
min-height: 538px;
}

.jn-ip-card2 {
Expand Down Expand Up @@ -268,6 +268,12 @@ footer {
zoom: 0.8;
}

.jn-risk-score {
display: flex;
justify-content: center;
flex-direction: column;
}

.jn-speedtest-note {
background-color: #b2d6c33b;
border: 1px solid #1a8754;
Expand Down
1 change: 1 addition & 0 deletions frontend/utils/masked-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function maskedInfo(t) {
fakecard.showASNInfo = false;
fakecard.isProxy = t('ipInfos.proxyDetect.no');
fakecard.type = t('ipInfos.proxyDetect.type.Business');
fakecard.qualityScore = 100;
fakecard.proxyProtocol = t('ipInfos.proxyDetect.unknownProtocol');
fakecard.proxyOperator = "unknown";

Expand Down
3 changes: 2 additions & 1 deletion frontend/utils/transform-ip-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ function transformDataFromIPapi(data, ipGeoSource, t, mapLanguage) {
function extractProxyDetails(proxyDetect = {}, t) {
const isProxy = determineIsProxy(proxyDetect, t);
const type = determineType(proxyDetect, t);
const qualityScore = proxyDetect.risk === 'unknown' ? 'unknown' : (100 - proxyDetect.risk);
const proxyProtocol = determineProtocol(proxyDetect, t);
const proxyOperator = proxyDetect.operator || "";

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

// 判断是否代理
Expand Down

0 comments on commit dcf94be

Please sign in to comment.