mirror of
https://github.com/venera-app/venera-configs.git
synced 2025-09-27 08:27:24 +00:00
refactor: 优化漫画详情解析逻辑 (#101)
* refactor: 优化漫画详情解析逻辑并格式化代码 - 将漫画详情返回对象改为 ComicDetails 实例 - 新增 updateDate 字段并转换日期格式 * chore: 更新包子漫画版本号至1.0.5
This commit is contained in:
46
baozi.js
46
baozi.js
@@ -5,7 +5,7 @@ class Baozi extends ComicSource {
|
|||||||
// 唯一标识符
|
// 唯一标识符
|
||||||
key = "baozi"
|
key = "baozi"
|
||||||
|
|
||||||
version = "1.0.4"
|
version = "1.0.5"
|
||||||
|
|
||||||
minAppVersion = "1.0.0"
|
minAppVersion = "1.0.0"
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class Baozi extends ComicSource {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 退出登录时将会调用此函数
|
// 退出登录时将会调用此函数
|
||||||
logout: function() {
|
logout: function () {
|
||||||
Network.deleteCookies(this.loadSetting('domains') || this.settings.domains.default)
|
Network.deleteCookies(this.loadSetting('domains') || this.settings.domains.default)
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -290,21 +290,21 @@ class Baozi extends ComicSource {
|
|||||||
tags = [...tags.filter(e => e !== "")]
|
tags = [...tags.filter(e => e !== "")]
|
||||||
let updateTime = document.querySelector("div.supporting-text > div > span > em")?.text.trim().replace('(', '').replace(')', '')
|
let updateTime = document.querySelector("div.supporting-text > div > span > em")?.text.trim().replace('(', '').replace(')', '')
|
||||||
if (!updateTime) {
|
if (!updateTime) {
|
||||||
const getLastChapterText = () => {
|
const getLastChapterText = () => {
|
||||||
// 合并所有章节容器(处理可能存在多个列表的情况)
|
// 合并所有章节容器(处理可能存在多个列表的情况)
|
||||||
const containers = [
|
const containers = [
|
||||||
...document.querySelectorAll("#chapter-items, #chapters_other_list")
|
...document.querySelectorAll("#chapter-items, #chapters_other_list")
|
||||||
];
|
];
|
||||||
let allChapters = [];
|
let allChapters = [];
|
||||||
containers.forEach(container => {
|
containers.forEach(container => {
|
||||||
const chapters = container.querySelectorAll(".comics-chapters > a");
|
const chapters = container.querySelectorAll(".comics-chapters > a");
|
||||||
allChapters.push(...Array.from(chapters));
|
allChapters.push(...Array.from(chapters));
|
||||||
});
|
});
|
||||||
const lastChapter = allChapters[allChapters.length - 1];
|
const lastChapter = allChapters[allChapters.length - 1];
|
||||||
return lastChapter?.querySelector("div > span")?.text.trim() || "暂无更新信息";
|
return lastChapter?.querySelector("div > span")?.text.trim() || "暂无更新信息";
|
||||||
};
|
};
|
||||||
updateTime = getLastChapterText();
|
updateTime = getLastChapterText();
|
||||||
}
|
}
|
||||||
let description = document.querySelector("p.comics-detail__desc").text.trim()
|
let description = document.querySelector("p.comics-detail__desc").text.trim()
|
||||||
let chapters = new Map()
|
let chapters = new Map()
|
||||||
let i = 0
|
let i = 0
|
||||||
@@ -338,19 +338,21 @@ class Baozi extends ComicSource {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// updateTime 将 Y年 M月 D日 转化为 Y-M-D
|
||||||
|
let updateDate = updateTime.replace(/年/g, '-').replace(/月/g, '-').replace(/日/g, '');
|
||||||
|
|
||||||
return {
|
return new ComicDetails({
|
||||||
title: title,
|
title: title,
|
||||||
cover: cover,
|
cover: cover,
|
||||||
description: description,
|
description: description,
|
||||||
tags: {
|
tags: {
|
||||||
"作者": [author],
|
"作者": [author],
|
||||||
"更新": [updateTime],
|
|
||||||
"标签": tags
|
"标签": tags
|
||||||
},
|
},
|
||||||
chapters: chapters,
|
chapters: chapters,
|
||||||
recommend: recommend
|
recommend: recommend,
|
||||||
}
|
updateTime: updateDate,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
loadEp: async (comicId, epId) => {
|
loadEp: async (comicId, epId) => {
|
||||||
const images = [];
|
const images = [];
|
||||||
@@ -377,7 +379,7 @@ class Baozi extends ComicSource {
|
|||||||
}
|
}
|
||||||
maxAttempts--;
|
maxAttempts--;
|
||||||
}
|
}
|
||||||
// 代理后图片水印更少
|
// 代理后图片水印更少
|
||||||
return { images };
|
return { images };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
"name": "包子漫画",
|
"name": "包子漫画",
|
||||||
"fileName": "baozi.js",
|
"fileName": "baozi.js",
|
||||||
"key": "baozi",
|
"key": "baozi",
|
||||||
"version": "1.0.4"
|
"version": "1.0.5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Picacg",
|
"name": "Picacg",
|
||||||
|
Reference in New Issue
Block a user