优化部分网址获取信息失败的问题。

This commit is contained in:
unknown 2024-09-13 21:03:20 +08:00
parent 0ad813a315
commit 0327dfc0cc
2 changed files with 10 additions and 2 deletions

View File

@ -209,6 +209,9 @@ function analysisHTML(windowName: string, url: string, data: string) {
let $ = cheerio.load(data); let $ = cheerio.load(data);
// 获取标题 // 获取标题
result.name = $("head").find("title").text(); result.name = $("head").find("title").text();
if (!result.name || result.name.trim() === "") {
result.name = $("title").text();
}
// 获取图标URL // 获取图标URL
let iconURL: string | null = null; let iconURL: string | null = null;
let icon = $("link[rel='icon']"); let icon = $("link[rel='icon']");
@ -272,6 +275,9 @@ function analysisHTML(windowName: string, url: string, data: string) {
result.status = true; result.status = true;
sendUrlInfo(windowName, result); sendUrlInfo(windowName, result);
} else { } else {
if (result.name && result.name.trim() !== "") {
result.status = true;
}
sendUrlInfo(windowName, result); sendUrlInfo(windowName, result);
} }
} }

View File

@ -833,8 +833,10 @@ onMounted(() => {
getURLInfoLoading.value = false; getURLInfoLoading.value = false;
let res: Result = data; let res: Result = data;
if (res.status) { if (res.status) {
if (res.icon && res.icon.trim() !== "") {
form.data.icon = res.icon; form.data.icon = res.icon;
form.data.htmlIcon = null; form.data.htmlIcon = null;
}
form.name = res.name ?? ""; form.name = res.name ?? "";
} else { } else {
window.api.showErrorMessageBox( window.api.showErrorMessageBox(