From 6f747cb24a7e5a77e0414b3ca36cf972a9a4d588 Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 16 May 2024 18:34:37 +0800 Subject: [PATCH 1/4] Improvements --- frontend/App.vue | 44 +++--- frontend/components/Advanced.vue | 2 +- frontend/components/ConnectivityTest.vue | 112 +++++++++------ frontend/components/DnsLeaksTest.vue | 174 +++++++++++++---------- frontend/components/IpInfos.vue | 26 +++- frontend/components/SpeedTest.vue | 2 +- frontend/components/WebRtcTest.vue | 80 ++++++----- frontend/components/widgets/InfoMask.vue | 6 +- frontend/store.js | 15 +- frontend/utils/getips/cloudflare-cn.js | 8 +- frontend/utils/getips/cloudflare-v4.js | 15 +- frontend/utils/getips/cloudflare-v6.js | 15 +- frontend/utils/getips/ipchecking.js | 22 +-- frontend/utils/getips/ipify-v4.js | 15 +- frontend/utils/getips/ipify-v6.js | 18 ++- frontend/utils/getips/ipipnet.js | 32 +++-- frontend/utils/getips/qqvideo.js | 13 +- frontend/utils/getips/upai.js | 19 ++- 18 files changed, 396 insertions(+), 222 deletions(-) diff --git a/frontend/App.vue b/frontend/App.vue index 5a01d093..5c409493 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -13,7 +13,7 @@ - @@ -61,7 +61,7 @@ const store = useMainStore(); const configs = computed(() => store.configs); const userPreferences = computed(() => store.userPreferences); const shouldRefreshEveryThing = computed(() => store.shouldRefreshEveryThing); -const Status = computed(() => store.loadingStatus); +const Status = computed(() => store.mountingStatus); // Template 里的 Ref const navBarRef = ref(null); @@ -88,6 +88,7 @@ const alertMessage = ref(""); const alertTitle = ref(""); const alertToShow = ref(false); const autoStart = ref(userPreferences.value.autoStart); +const showMaskButton = ref(false); // // 加载相关 @@ -103,9 +104,8 @@ hideLoading(); // 事件控制 -const loadingControl = (t1 = 0, t2 = 0, t3 = 4000, t4 = 2500) => { +const loadingControl = (t1 = 0, t2 = 2000, t3 = 3000, t4 = 2500) => { const mountedStatus = Object.values(Status.value).every(Boolean); - setInfosLoaded(); if (mountedStatus) { setTimeout(() => { IPCheckRef.value.checkAllIPs(); @@ -120,6 +120,11 @@ const loadingControl = (t1 = 0, t2 = 0, t3 = 4000, t4 = 2500) => { setTimeout(() => { dnsLeaksRef.value.checkAllDNSLeakTest(false); }, t4); + } else { + // 如果不自动运行,将剩余的加载状态设置为 true + store.setLoadingStatus('connectivity', true); + store.setLoadingStatus('webrtc', true); + store.setLoadingStatus('dnsleaktest', true); } } else { // 递归检查 @@ -129,13 +134,6 @@ const loadingControl = (t1 = 0, t2 = 0, t3 = 4000, t4 = 2500) => { } }; -// 延迟设置 isInfosLoaded.value -const setInfosLoaded = () => { - setTimeout(() => { - isInfosLoaded.value = true; - }, 6000); -}; - // // 刷新相关 // @@ -153,10 +151,17 @@ const scheduleTimedTasks = (tasks) => { // 刷新所有 const refreshEverything = () => { + + // 重置加载状态 + store.setLoadingStatus('connectivity', false); + store.setLoadingStatus('webrtc', false); + store.setLoadingStatus('dnsleaktest', false); + store.setLoadingStatus('ipcheck', false); + const refreshTasks = [ { action: () => IPCheckRef.value.checkAllIPs(), delay: 0 }, - { action: () => connectivityRef.value.checkAllConnectivity(false, true, true), delay: 2000 }, - { action: () => webRTCRef.value.checkAllWebRTC(true), delay: 4000 }, + { action: () => connectivityRef.value.handelCheckStart(true), delay: 2000 }, + { action: () => webRTCRef.value.checkAllWebRTC(true), delay: 3000 }, { action: () => dnsLeaksRef.value.checkAllDNSLeakTest(true), delay: 2500 }, { action: () => refreshingAlert(), delay: 500 }, ]; @@ -321,7 +326,7 @@ const ShortcutKeys = (isOriginalSite) => { keys: "c", action: () => { scrollToElement("Connectivity", 80); - connectivityRef.value.checkAllConnectivity(false, true, true); + connectivityRef.value.handelCheckStart(true); trackEvent('ShortCut', 'ShortCut', 'Connectivity'); }, description: t('shortcutKeys.RefreshConnectivityTests'), @@ -500,19 +505,20 @@ const loadShortcuts = () => { }, 2000); }; +// 监控刷新动作 watch(shouldRefreshEveryThing, (newVal) => { if (newVal) { navBarRef.value.loaded = false; isInfosLoaded.value = false; refreshEverything(); - setInfosLoaded(); } }); -watch(isInfosLoaded, (newVal) => { - if (newVal) { - navBarRef.value.loaded = true; - } +// 监控加载状态并传递 +watch(() => store.allHasLoaded, (newValue) => { + navBarRef.value.loaded = newValue; + isInfosLoaded.value = newValue; + showMaskButton.value = true; }); onMounted(() => { diff --git a/frontend/components/Advanced.vue b/frontend/components/Advanced.vue index 281940fa..e3dc7802 100644 --- a/frontend/components/Advanced.vue +++ b/frontend/components/Advanced.vue @@ -150,7 +150,7 @@ const fullScreen = () => { onMounted(() => { - store.setLoadingStatus('advancedtools', true); + store.setMountingStatus('advancedtools', true); // 监听滚动事件 scrollContainer.value.addEventListener('scroll', handleScroll); diff --git a/frontend/components/ConnectivityTest.vue b/frontend/components/ConnectivityTest.vue index 207cf6c7..2c16fb70 100644 --- a/frontend/components/ConnectivityTest.vue +++ b/frontend/components/ConnectivityTest.vue @@ -46,7 +46,7 @@ diff --git a/frontend/utils/shortcut.js b/frontend/utils/shortcut.js index 4a29f408..1988666f 100644 --- a/frontend/utils/shortcut.js +++ b/frontend/utils/shortcut.js @@ -53,7 +53,7 @@ const navigateCards = (direction) => { currentCard.setAttribute('data-keyboard-hover', 'true'); const cardTop = currentCard.getBoundingClientRect().top + window.pageYOffset; - window.scrollTo({ top: cardTop - 60, behavior: 'smooth' }); + window.scrollTo({ top: cardTop - 200, behavior: 'smooth' }); }; From b6ad56f5c5d00c197b7f730e36321488663d9711 Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 16 May 2024 19:35:19 +0800 Subject: [PATCH 3/4] Improvements --- frontend/locales/en.json | 12 +----- frontend/locales/fr.json | 12 +----- frontend/locales/zh.json | 12 +----- frontend/utils/transform-ip-data.js | 67 ++++++++++++++++++++++------- 4 files changed, 57 insertions(+), 46 deletions(-) diff --git a/frontend/locales/en.json b/frontend/locales/en.json index 207222f7..33224661 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -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", @@ -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!", @@ -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" }, diff --git a/frontend/locales/fr.json b/frontend/locales/fr.json index 402ae34b..71997b0c 100644 --- a/frontend/locales/fr.json +++ b/frontend/locales/fr.json @@ -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", @@ -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 !", @@ -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" }, diff --git a/frontend/locales/zh.json b/frontend/locales/zh.json index 1c20ad98..26338ee5 100644 --- a/frontend/locales/zh.json +++ b/frontend/locales/zh.json @@ -222,7 +222,8 @@ "Human_Pct": "人类流量占比:" }, "proxyDetect": { - "yes": "可能是代理或 VPN", + "yes": "是代理或 VPN", + "maybe": "可能是代理或 VPN", "no": "不是代理或 VPN", "unknownProxyType": "未知类型", "unknownProtocol": "未知协议", @@ -356,7 +357,6 @@ "DNSResolver": "打开 DNS 解析器面板", "ToggleMaps": "切换地图显示", "IPCheck": "IP 查询", - "AddBingMapKey": "添加 Bing Map API Key", "ToggleInfoMask": "切换信息隐藏", "Help": "显示快捷键", "HelpNote": "使用快捷键的人,是喜欢效率的人,你真棒!", @@ -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": "快捷键" }, diff --git a/frontend/utils/transform-ip-data.js b/frontend/utils/transform-ip-data.js index 198bf9cc..fbf7e4db 100644 --- a/frontend/utils/transform-ip-data.js +++ b/frontend/utils/transform-ip-data.js @@ -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); } @@ -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, @@ -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 }; \ No newline at end of file From befd3bf034c0a925f08fc56968ac08cada2569db Mon Sep 17 00:00:00 2001 From: jason5ng32 Date: Thu, 16 May 2024 21:13:04 +0800 Subject: [PATCH 4/4] Improvements --- frontend/components/widgets/Help.vue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/components/widgets/Help.vue b/frontend/components/widgets/Help.vue index ad8e00f7..4ade3252 100644 --- a/frontend/components/widgets/Help.vue +++ b/frontend/components/widgets/Help.vue @@ -4,7 +4,8 @@