feat: 缺失文件扫描支持清理并发布 v2.1.1
构建与发布 / 发布 GitHub Release (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
构建与发布 / 单测与集成测试 (push) Waiting to run
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
构建与发布 / 发布 GitHub Release (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
构建与发布 / 单测与集成测试 (push) Waiting to run
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
This commit is contained in:
+31
-1
@@ -84,9 +84,39 @@ const Library = (() => {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '扫描中...';
|
||||
const r = await window.api.library.scan();
|
||||
btn.textContent = r.ok && r.data && r.data.added ? `新增 ${r.data.added} 本 ✓` : '已是最新 ✓';
|
||||
if (!r || !r.ok) {
|
||||
btn.textContent = '扫描失败';
|
||||
await confirmModal('扫描失败', (r && r.error) || '未知错误');
|
||||
setTimeout(() => { btn.textContent = '重新扫描'; btn.disabled = false; }, 2000);
|
||||
return;
|
||||
}
|
||||
btn.textContent = r.data && r.data.added ? `新增 ${r.data.added} 本 ✓` : '已是最新 ✓';
|
||||
dirty = true;
|
||||
await refresh(true);
|
||||
const missing = Math.max(0, Number((r.data || {}).missing) || 0);
|
||||
if (missing) {
|
||||
const clean = await confirmModal(
|
||||
'发现文件缺失',
|
||||
`扫描发现 ${missing} 条书库内容的文件均已缺失,是否从书库中清理这些条目?不再被其他书籍使用的对应分类和标签也会一并清理;笔记、书签、进度和标注会保留。`
|
||||
);
|
||||
if (clean) {
|
||||
const removed = await window.api.library.removeMissing();
|
||||
if (!removed || !removed.ok) {
|
||||
await confirmModal('清理失败', (removed && removed.error) || '未知错误');
|
||||
} else {
|
||||
const count = Math.max(0, Number((removed.data || {}).removed) || 0);
|
||||
const shelvesRemoved = Math.max(0, Number((removed.data || {}).shelvesRemoved) || 0);
|
||||
const tagsRemoved = Math.max(0, Number((removed.data || {}).tagsRemoved) || 0);
|
||||
const extras = [
|
||||
shelvesRemoved ? `${shelvesRemoved} 个分类` : '',
|
||||
tagsRemoved ? `${tagsRemoved} 个标签` : ''
|
||||
].filter(Boolean);
|
||||
btn.textContent = `已清理 ${count} 条${extras.length ? `、${extras.join('、')}` : ''} ✓`;
|
||||
dirty = true;
|
||||
await refresh(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
setTimeout(() => { btn.textContent = '重新扫描'; btn.disabled = false; }, 2000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user