增加更多匹配的域名信息

This commit is contained in:
Alex Yang
2026-01-14 23:08:46 +08:00
parent f247eaeaa8
commit 8159577be0
60 changed files with 11716 additions and 1022 deletions

View File

@@ -280,45 +280,45 @@ async function getDomainInfo(domain) {
// 如果有URL属性直接检查域名
if (website.url) {
// 处理字符串类型的URL
if (typeof website.url === 'string') {
console.log(' 检查字符串URL:', website.url);
if (isDomainMatch(website.url, normalizedDomain, website.categoryId)) {
console.log(' 匹配成功,返回网站信息');
return {
name: website.name,
icon: website.icon,
categoryId: website.categoryId,
categoryName: domainInfoDatabase.categories[website.categoryId] || '未知',
company: website.company || companyName
};
}
if (typeof website.url === 'string') {
console.log(' 检查字符串URL:', website.url);
if (isDomainMatch(website.url, normalizedDomain, website.categoryId)) {
console.log(' 匹配成功,返回网站信息');
return {
name: website.name,
icon: website.icon,
categoryId: website.categoryId,
categoryName: domainInfoDatabase.categories[website.categoryId] || '未知',
company: website.company || companyName
};
}
// 处理对象类型的URL
else if (typeof website.url === 'object') {
console.log(' 检查对象类型URL包含', Object.keys(website.url).length, '个URL');
for (const urlKey in website.url) {
if (website.url.hasOwnProperty(urlKey)) {
const urlValue = website.url[urlKey];
console.log(' 检查URL', urlKey, ':', urlValue);
if (isDomainMatch(urlValue, normalizedDomain, website.categoryId)) {
console.log(' 匹配成功,返回网站信息');
return {
name: website.name,
icon: website.icon,
categoryId: website.categoryId,
categoryName: domainInfoDatabase.categories[website.categoryId] || '未知',
company: website.company || companyName
};
}
}
// 处理对象类型的URL
else if (typeof website.url === 'object') {
console.log(' 检查对象类型URL包含', Object.keys(website.url).length, '个URL');
for (const urlKey in website.url) {
if (website.url.hasOwnProperty(urlKey)) {
const urlValue = website.url[urlKey];
console.log(' 检查URL', urlKey, ':', urlValue);
if (isDomainMatch(urlValue, normalizedDomain, website.categoryId)) {
console.log(' 匹配成功,返回网站信息');
return {
name: website.name,
icon: website.icon,
categoryId: website.categoryId,
categoryName: domainInfoDatabase.categories[website.categoryId] || '未知',
company: website.company || companyName
};
}
}
}
}
} else if (typeof website === 'object' && website !== null) {
// 没有URL属性可能是嵌套的类别
console.log(' 发现嵌套类别,进一步检查');
for (const nestedWebsiteKey in website) {
if (website.hasOwnProperty(nestedWebsiteKey) && nestedWebsiteKey !== 'company') {
console.log(' 检查嵌套网站:', nestedWebsiteKey);
console.log(' 检查嵌套网站/类别:', nestedWebsiteKey);
const nestedWebsite = website[nestedWebsiteKey];
if (nestedWebsite.url) {
@@ -356,8 +356,54 @@ async function getDomainInfo(domain) {
}
}
}
} else if (typeof nestedWebsite === 'object' && nestedWebsite !== null) {
// 嵌套类别中的嵌套类别,递归检查
console.log(' 发现二级嵌套类别,进一步检查');
for (const secondNestedWebsiteKey in nestedWebsite) {
if (nestedWebsite.hasOwnProperty(secondNestedWebsiteKey) && secondNestedWebsiteKey !== 'company') {
console.log(' 检查二级嵌套网站:', secondNestedWebsiteKey);
const secondNestedWebsite = nestedWebsite[secondNestedWebsiteKey];
if (secondNestedWebsite.url) {
// 处理字符串类型的URL
if (typeof secondNestedWebsite.url === 'string') {
console.log(' 检查字符串URL:', secondNestedWebsite.url);
if (isDomainMatch(secondNestedWebsite.url, normalizedDomain, secondNestedWebsite.categoryId)) {
console.log(' 匹配成功,返回网站信息');
return {
name: secondNestedWebsite.name,
icon: secondNestedWebsite.icon,
categoryId: secondNestedWebsite.categoryId,
categoryName: domainInfoDatabase.categories[secondNestedWebsite.categoryId] || '未知',
company: secondNestedWebsite.company || companyName
};
}
}
// 处理对象类型的URL
else if (typeof secondNestedWebsite.url === 'object') {
console.log(' 检查对象类型URL包含', Object.keys(secondNestedWebsite.url).length, '个URL');
for (const urlKey in secondNestedWebsite.url) {
if (secondNestedWebsite.url.hasOwnProperty(urlKey)) {
const urlValue = secondNestedWebsite.url[urlKey];
console.log(' 检查URL', urlKey, ':', urlValue);
if (isDomainMatch(urlValue, normalizedDomain, secondNestedWebsite.categoryId)) {
console.log(' 匹配成功,返回网站信息');
return {
name: secondNestedWebsite.name,
icon: secondNestedWebsite.icon,
categoryId: secondNestedWebsite.categoryId,
categoryName: domainInfoDatabase.categories[secondNestedWebsite.categoryId] || '未知',
company: secondNestedWebsite.company || companyName
};
}
}
}
}
}
}
}
} else {
console.log(' 嵌套网站没有URL属性');
console.log(' 嵌套网站没有URL属性且不是对象类型');
}
}
}
@@ -1891,7 +1937,7 @@ async function showLogDetailModal(log) {
<span class="flex-grow">${domainInfo.categoryName || '未知'}</span>
</div>
<div class="flex items-center flex-wrap">
<span class="text-gray-500 mr-2">所属单位:</span>
<span class="text-gray-500 mr-2">所属单位/公司</span>
<span class="flex-grow">${domainInfo.company || '未知'}</span>
</div>
</div>