🐛 修复一个会导致 500的Bug

This commit is contained in:
7836246 2024-03-03 08:03:42 +08:00
parent 2fbaf88ce2
commit e74f8b1e24
8 changed files with 128 additions and 34 deletions

View File

@ -2,7 +2,7 @@
import {SupportedTLDs} from "~/utils/domain";
const isOpen = ref(false)
const {t} = useI18n()
</script>
<template>
@ -23,7 +23,7 @@ const isOpen = ref(false)
<Icon name="lets-icons:close-ring-light" class="absolute top-2 right-2 text-gray-500 cursor-pointer" @click="isOpen = false" />
</button>
<div class="p-4 flex-1">
<div>目前仅支持以下后缀</div>
<div>{{t('index.support')}}</div>
<div class="flex flex-wrap mt-2 p-5 overflow-y-auto max-h-[95vh]">
<span
v-for="item in SupportedTLDs"

View File

@ -1,17 +1,17 @@
<script setup lang="ts">
import {useStyleStore} from "~/stores/style";
import {formatTimeAgo} from "~/composables/useFormatTime";
const isOpen = ref(false)
const styleStore = useStyleStore()
const {t} = useI18n()
const slideoverConfig = {
//
width: 'w-screen max-w-2xl', //
// ...
};
</script>
<template>
@ -36,9 +36,9 @@ const slideoverConfig = {
<div class="w-full min-h-screen bg-gray-100 p-5 overflow-y-auto max-h-[95vh]">
<div class="max-w-6xl mx-auto">
<h1 class="text-2xl font-bold text-gray-800 mb-5 flex items-center justify-between">
查询历史
{{ t('history.title') }}
<span class="text-sm text-gray-500 bg-gray-100 py-1 px-3 rounded-full">
只保留最近 30/{{ styleStore.getHistory.length }} 条记录
{{ t('history.tips', { length: styleStore.getHistory.length }) }}
</span>
</h1>
<div class="bg-white shadow-md rounded-lg">
@ -50,16 +50,16 @@ const slideoverConfig = {
<thead>
<tr>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
域名
{{ t('history.domain') }}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
查询类型
{{ t('history.type') }}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
查询时间
{{ t('history.time') }}
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
动作
{{ t('history.actions') }}
</th>
</tr>
</thead>
@ -79,7 +79,7 @@ const slideoverConfig = {
<UButton
@click="styleStore.deleteHistory(item.id)"
color="sky"
>删除</UButton>
>{{t('common.actions.delete')}}</UButton>
</td>
</tr>
</tbody>
@ -87,7 +87,7 @@ const slideoverConfig = {
</table>
</div>
<div v-else class="text-center py-5">
<p class="text-gray-500">当前没有查询历史记录</p>
<p class="text-gray-500">{{ t('history.empty') }}</p>
</div>
</div>
</div>

View File

@ -3,6 +3,11 @@ export default defineI18nLocale(async locale => {
app: {
title: 'Nuxt Whois',
},
common: {
actions: {
delete: 'Delete',
}
},
whois:{
title: 'Whois Query',
description: 'Query the Whois information of {domain}, including registrant contact information, domain status, DNS records and other detailed information. Quickly and accurately obtain domain ownership and registration information.',
@ -21,6 +26,22 @@ export default defineI18nLocale(async locale => {
//SOA record
soaRecord: 'SOA record',
},
history:{
//Query history
title: 'Query History',
//Only keep the last 30/{{ styleStore.getHistory.length }} records
tips: 'Only keep the last 30/{length} records',
//Domain
domain: 'Domain',
//Query type
type: 'Query Type',
//Query time
time: 'Query Time',
//Operation
actions: 'Actions',
//There is currently no query history.
empty: 'There is currently no query history.',
},
index: {
tips: 'The information you submit for your query will not be recorded!',
placeholder: 'Please enter a domain name',
@ -28,6 +49,7 @@ export default defineI18nLocale(async locale => {
title: 'WHOIS and Dns Query Tool Website',
description: 'Provide domain WHOIS query, domain DNS query, domain registrar query, domain registration information query and other services',
keywords: 'Domain whois query, whois query, whois information query, whois query tool, whois query website, whois query api, whois query interface',
support: 'Currently only the following suffixes are supported',
},
error:{
formatDomain: 'Error formatting domain name',

View File

@ -3,6 +3,11 @@ export default defineI18nLocale(async locale => {
app: {
title: 'Nuxt Whois',
},
common: {
actions: {
delete: '刪除',
}
},
whois: {
title: 'Whois查詢',
description: '查詢{domain}的Whois信息包括註冊者聯繫方式、域名狀態、DNS記錄等詳細信息。快速、準確地獲取域名所有權和註冊信息。',
@ -21,6 +26,22 @@ export default defineI18nLocale(async locale => {
//SOA記錄
soaRecord: 'SOA記錄',
},
history:{
//查詢歷史
title: '查詢歷史',
//只保留最近 30/{{ styleStore.getHistory.length }} 條記錄
tips: '只保留最近 30/{length} 條記錄',
//域名
domain: '域名',
//查詢型別
type: '查詢型別',
//查詢時間
time: '查詢時間',
//操作
actions: '操作',
//當前沒有查詢歷史記錄。
empty: '當前沒有查詢歷史記錄。',
},
index: {
tips: '您提交的查詢信息不會被記錄!',
placeholder: '請輸入域名',
@ -28,6 +49,7 @@ export default defineI18nLocale(async locale => {
title: 'WHOIS與Dns查詢工具網站',
description: '提供域名WHOIS查詢、域名DNS查詢、域名註冊商查詢、域名註冊信息查詢等服務',
keywords: '域名whois查詢,whois查詢,whois信息查詢,whois查詢工具,whois查詢網站,whois查詢api,whois查詢接口',
support: '目前僅支持以下後綴',
},
error: {
formatDomain: '域名格式錯誤',

View File

@ -3,6 +3,12 @@ export default defineI18nLocale(async locale => {
app: {
title: 'Nuxt Whois',
},
common: {
actions: {
//删除
delete: '删除',
}
},
whois:{
title: "Whois查询",
description: "查询{domain}的Whois信息包括注册者联系方式、域名状态、DNS记录等详细信息。快速、准确地获取域名所有权和注册信息。",
@ -21,6 +27,22 @@ export default defineI18nLocale(async locale => {
//SOA记录
soaRecord: 'SOA记录',
},
history:{
//查询历史
title: '查询历史',
//只保留最近 30/{{ styleStore.getHistory.length }} 条记录
tips: '只保留最近 30/{length} 条记录',
//域名
domain: '域名',
//查询类型
type: '查询类型',
//查询时间
time: '查询时间',
//操作
actions: '操作',
//当前没有查询历史记录。
empty: '当前没有查询历史记录。',
},
index: {
tips: '您提交的查询信息不会被记录!',
placeholder: '请输入域名',
@ -28,6 +50,8 @@ export default defineI18nLocale(async locale => {
title: 'Whois与Dns查询工具网站',
description: '提供域名WHOIS查询、域名DNS查询、域名注册商查询、域名注册信息查询等服务',
keywords: '域名whois查询,whois查询,whois信息查询,whois查询工具,whois查询网站,whois查询api,whois查询接口',
//目前仅支持以下后缀
support: '目前仅支持以下后缀',
},
error:{
formatDomain: '域名格式错误',

View File

@ -30,13 +30,12 @@ const handleAction = async (url: any) => {
const trimDomain = (domain: string): string => {
return domain.trim();
}
return domain.trim().toLowerCase(); //
};
const splitDomain = (domain: string): string[] => {
return domain.split('.');
}
};
const validateDomain = (parts: string[]): boolean => {
if (parts.length < 2) {
@ -44,19 +43,23 @@ const validateDomain = (parts: string[]): boolean => {
return false;
}
return true;
}
};
const isTLDValid = (parts: string[]): boolean => {
const potentialTLD = parts.slice(-2).join('.');
if (!SupportedTLDs.has(parts.slice(-1)[0]) && !SupportedTLDs.has(potentialTLD)) {
const lastPart = parts[parts.length - 1].toLowerCase(); //
const potentialTLD = parts.slice(-2).join('.').toLowerCase(); // TLD
if (!SupportedTLDs.has(lastPart) && !SupportedTLDs.has(potentialTLD)) {
toast.add({ title: '域名后缀不合法' });
return false;
}
return true;
}
};
const updateDomainForTLD = (parts: string[]): string => {
const potentialTLD = parts.slice(-2).join('.');
const potentialTLD = parts.slice(-2).join('.').toLowerCase(); //
let domainToKeep: string;
if (SupportedTLDs.has(potentialTLD)) {
domainToKeep = parts.length > 2 ? parts.slice(-3).join('.') : parts.join('.');
@ -64,7 +67,7 @@ const updateDomainForTLD = (parts: string[]): string => {
domainToKeep = parts.slice(-2).join('.');
}
return domainToKeep;
}
};
const styleStore = useStyleStore()
const clientMounted = ref(false);

View File

@ -59,7 +59,9 @@ useHead({
<div>
<h3 class="font-semibold text-lg text-blue-600 mb-2">{{ t('dns.aRecord') }}</h3>
<div class="border rounded-lg p-4 bg-blue-50">
<ul class="list-none space-y-2">
<ul
v-if="data.A.length > 0"
class="list-none space-y-2">
<li v-for="(record, index) in data.A" :key="'a-record-' + index" class="flex justify-between items-center">
<span class="font-medium text-gray-700">IP:</span>
<span class="font-normal text-gray-600">{{ record.Record }}</span>
@ -71,7 +73,9 @@ useHead({
<div>
<h3 class="font-semibold text-lg text-green-600 mb-2">{{ t('dns.nsRecord') }}</h3>
<div class="border rounded-lg p-4 bg-green-50">
<ul class="list-none space-y-2">
<ul
v-if="data.NS.length > 0"
class="list-none space-y-2">
<li v-for="(record, index) in data.NS" :key="'ns-record-' + index" class="flex justify-between items-center">
<span class="font-normal text-gray-600">{{ record.Record }}</span>
<span class="text-sm text-gray-500">TTL: {{ record.TTL }}</span>

View File

@ -57,7 +57,8 @@ useHead({
<table
class="w-full bg-[#fffffe] p-4 shadow-lg rounded-lg mt-5 dark:bg-gray-800 dark:text-gray-200 text-white hover:bg-none">
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr v-if="parsedInfo.domainName"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">
{{ t('result.domain') }}
</th>
@ -70,47 +71,65 @@ useHead({
</p>
</td>
</tr>
<tr class="hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.registrar"
class="hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.registrar') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">{{ parsedInfo.registrar }}</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.updatedDate"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.updateDate') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">
{{ AdjustTimeToUTCOffset(parsedInfo.updatedDate, timeStore.timeZones) }}
</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.creationDate"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.createDate') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">
{{ AdjustTimeToUTCOffset(parsedInfo.creationDate, timeStore.timeZones) }}
</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.registryExpiryDate"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.expirationDate') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">
{{ AdjustTimeToUTCOffset(parsedInfo.registryExpiryDate, timeStore.timeZones) }}
</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.registrarIANAID"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.ianaId') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">{{ parsedInfo.registrarIANAID }}</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.domainStatus"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.status') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">{{ parsedInfo.domainStatus?.join(', ') }}</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.nameServers"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.dns') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">
<p v-for="item in parsedInfo.nameServers">{{ item }}</p>
</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="parsedInfo.dnssec"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.dnssec') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">{{ parsedInfo.dnssec }}</td>
</tr>
<tr class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<tr
v-if="data"
class="hover:bg-gray-100 text-gray-900 dark:hover:bg-gray-700 text-gray-200">
<th class="p-4 text-left font-semibold text-gray-900 dark:text-gray-200">{{ t('result.rawData') }}</th>
<td class="p-4 text-gray-900 dark:text-gray-200">
<UToggle color="sky" v-model="showRawData"/>