feat: 内置阅读器、批注笔记与 AI 助手,发布 1.3.0

新增 PDF/EPUB/MOBI/AZW 内置阅读器,PDF 分段读取支持超大文件,
批注、读书与画布笔记、封面生成与本地导入。AI 助手支持三种协议、
图像上下文与安全 Markdown 渲染,上下文范围改为 选中/当前页/全文,
页面与全文无需选中文本即可发送,全文会提示可能超出模型限制。

便携版输出目录固定为 PeopleLib-windows-x64,不再随版本号变化,
避免升级后 data/ 被遗留在旧目录。

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
lofyer
2026-08-03 12:13:02 +08:00
co-authored by factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent b8c8d24107
commit 3ccd044527
307 changed files with 98477 additions and 1148 deletions
+14 -9
View File
@@ -3,7 +3,7 @@
// 模块会明确抛错并提示用户在浏览器中打开。
const { fetchText, clampPage, decodeEntities } = require('./http');
const { tryMirrors } = require('./mirror');
const { tryMirrors, contentError } = require('./mirror');
const MIRRORS = [
'https://sci-hub.se',
@@ -48,17 +48,21 @@ function extractTitle(html, doi) {
return doi;
}
// 每个 pattern 都要遍历全部匹配:首个 iframe 常是广告/统计框,
// 只看第一个会漏掉后面真正的 PDF。
// 用 matchAll 而不是 while(re.exec):后者在正则漏掉 g 标志时会死循环。
function extractPdf(html, base) {
const patterns = [
/<iframe[^>]+src\s*=\s*["']([^"']+)["']/i,
/<embed[^>]+src\s*=\s*["']([^"']+)["']/i,
/location\.href\s*=\s*['"]([^'"]+)['"]/i,
/<a[^>]+href\s*=\s*["']([^"']*\.pdf[^"']*)["']/i
/<iframe[^>]+src\s*=\s*["']([^"']+)["']/gi,
/<embed[^>]+src\s*=\s*["']([^"']+)["']/gi,
/location\.href\s*=\s*['"]([^'"]+)['"]/gi,
/<a[^>]+href\s*=\s*["']([^"']*\.pdf[^"']*)["']/gi
];
for (const re of patterns) {
const m = html.match(re);
if (m && m[1] && /\.pdf|\/downloads?\//i.test(m[1])) {
return absUrl(base, m[1].replace(/#.*$/, ''));
for (const m of html.matchAll(re)) {
if (m[1] && /\.pdf|\/downloads?\//i.test(m[1])) {
return absUrl(base, m[1].replace(/#.*$/, ''));
}
}
}
return '';
@@ -73,7 +77,8 @@ async function fetchSciHub(base, doi) {
const pdfUrl = extractPdf(html, base);
const title = extractTitle(html, doi);
const notFound = /article not found|не найдена|抱歉/i.test(html);
if (!pdfUrl && notFound) throw new Error('该 DOI 在 Sci-Hub 中不存在');
// 镜像明确答复"没有这篇":换镜像结果相同,不该拉黑镜像也不该继续串行等待
if (!pdfUrl && notFound) throw contentError('该 DOI 在 Sci-Hub 中不存在');
return { pdfUrl, title, url, base };
}