mirror of
https://github.com/fireinrain/JHS-enhance.git
synced 2026-10-11 20:26:37 +08:00
强化目录删除的安全边界 保证只删除出现番号匹配的目录
This commit is contained in:
Vendored
+14
-6
@@ -8082,7 +8082,6 @@ ${err.stack}` : "");
|
|||||||
}
|
}
|
||||||
return fileId;
|
return fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: 暂时没有删除离线任务
|
//TODO: 暂时没有删除离线任务
|
||||||
// async deleteOfflineTasksByKeyword(keyword) {
|
// async deleteOfflineTasksByKeyword(keyword) {
|
||||||
// try {
|
// try {
|
||||||
@@ -8747,8 +8746,14 @@ ${err.stack}` : "");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showDeleteDialog(carNum2, matchList, afterDelete) {
|
showDeleteDialog(carNum2, matchList, afterDelete) {
|
||||||
|
const upperCarNum = carNum2.toUpperCase();
|
||||||
|
const safeMatchList = matchList.filter((m) => m.name.toUpperCase().includes(upperCarNum));
|
||||||
|
const unsafeCount = matchList.length - safeMatchList.length;
|
||||||
|
if (safeMatchList.length === 0) {
|
||||||
|
show.error(`作品 "${carNum2}" 匹配到的 ${matchList.length} 个项目均不含番号,无法安全删除。请手动在115中删除。`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const formatSize = (bytes) => {
|
const formatSize = (bytes) => {
|
||||||
if (!bytes) return "-";
|
if (!bytes) return "-";
|
||||||
const units = ["B", "KB", "MB", "GB", "TB"];
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
||||||
@@ -8757,10 +8762,13 @@ ${err.stack}` : "");
|
|||||||
return size.toFixed(2) + " " + units[unit];
|
return size.toFixed(2) + " " + units[unit];
|
||||||
};
|
};
|
||||||
let html = '<div style="padding: 15px; max-height: 400px; overflow-y: auto;">';
|
let html = '<div style="padding: 15px; max-height: 400px; overflow-y: auto;">';
|
||||||
html += `<div style="margin-bottom: 12px; font-size: 14px;">作品 <b>${carNum2}</b> 匹配到 <b>${matchList.length}</b> 个文件夹:</div>`;
|
html += `<div style="margin-bottom: 12px; font-size: 14px;">作品 <b>${carNum2}</b> 匹配到 <b>${matchList.length}</b> 个文件夹(可删除 <b>${safeMatchList.length}</b> 个):</div>`;
|
||||||
|
if (unsafeCount > 0) {
|
||||||
|
html += `<div style="margin-bottom: 10px; padding: 6px 10px; background: #fff3cd; border: 1px solid #ffc107; border-radius: 4px; font-size: 12px; color: #856404;">⚠ 已自动排除 ${unsafeCount} 个目录名不含番号的项目,防止误删</div>`;
|
||||||
|
}
|
||||||
html += '<div style="margin-bottom: 10px;"><label style="cursor: pointer;"><input type="checkbox" class="jhs-delete-select-all" checked> <b>全选</b></label></div>';
|
html += '<div style="margin-bottom: 10px;"><label style="cursor: pointer;"><input type="checkbox" class="jhs-delete-select-all" checked> <b>全选</b></label></div>';
|
||||||
for (let i = 0; i < matchList.length; i++) {
|
for (let i = 0; i < safeMatchList.length; i++) {
|
||||||
const m = matchList[i];
|
const m = safeMatchList[i];
|
||||||
html += `<div style="margin-bottom: 6px; padding: 8px 10px; border: 1px solid #e0e0e0; border-radius: 4px; background: #fafafa;">
|
html += `<div style="margin-bottom: 6px; padding: 8px 10px; border: 1px solid #e0e0e0; border-radius: 4px; background: #fafafa;">
|
||||||
<label style="display: flex; align-items: flex-start; cursor: pointer; width: 100%;">
|
<label style="display: flex; align-items: flex-start; cursor: pointer; width: 100%;">
|
||||||
<input type="checkbox" class="jhs-delete-folder-cb" data-index="${i}" checked style="margin-top: 3px; flex-shrink: 0;">
|
<input type="checkbox" class="jhs-delete-folder-cb" data-index="${i}" checked style="margin-top: 3px; flex-shrink: 0;">
|
||||||
@@ -8794,7 +8802,7 @@ ${err.stack}` : "");
|
|||||||
let deletedCount = 0;
|
let deletedCount = 0;
|
||||||
try {
|
try {
|
||||||
for (const i of selected) {
|
for (const i of selected) {
|
||||||
const m = matchList[i];
|
const m = safeMatchList[i];
|
||||||
const result = await gmHttp.postForm("https://webapi.115.com/rb/delete", {
|
const result = await gmHttp.postForm("https://webapi.115.com/rb/delete", {
|
||||||
pid: m.dirId,
|
pid: m.dirId,
|
||||||
"fid[0]": m.folderId
|
"fid[0]": m.folderId
|
||||||
|
|||||||
@@ -374,6 +374,13 @@ const _WangPan115MatchPlugin = class _WangPan115MatchPlugin extends BasePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showDeleteDialog(carNum2, matchList, afterDelete) {
|
showDeleteDialog(carNum2, matchList, afterDelete) {
|
||||||
|
const upperCarNum = carNum2.toUpperCase();
|
||||||
|
const safeMatchList = matchList.filter(m => m.name.toUpperCase().includes(upperCarNum));
|
||||||
|
const unsafeCount = matchList.length - safeMatchList.length;
|
||||||
|
if (safeMatchList.length === 0) {
|
||||||
|
show.error(`作品 "${carNum2}" 匹配到的 ${matchList.length} 个项目均不含番号,无法安全删除。请手动在115中删除。`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const formatSize = bytes => {
|
const formatSize = bytes => {
|
||||||
if (!bytes) return "-";
|
if (!bytes) return "-";
|
||||||
const units = ["B", "KB", "MB", "GB", "TB"];
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
||||||
@@ -382,10 +389,13 @@ const _WangPan115MatchPlugin = class _WangPan115MatchPlugin extends BasePlugin {
|
|||||||
return size.toFixed(2) + " " + units[unit];
|
return size.toFixed(2) + " " + units[unit];
|
||||||
};
|
};
|
||||||
let html = '<div style="padding: 15px; max-height: 400px; overflow-y: auto;">';
|
let html = '<div style="padding: 15px; max-height: 400px; overflow-y: auto;">';
|
||||||
html += `<div style="margin-bottom: 12px; font-size: 14px;">作品 <b>${carNum2}</b> 匹配到 <b>${matchList.length}</b> 个文件夹:</div>`;
|
html += `<div style="margin-bottom: 12px; font-size: 14px;">作品 <b>${carNum2}</b> 匹配到 <b>${matchList.length}</b> 个文件夹(可删除 <b>${safeMatchList.length}</b> 个):</div>`;
|
||||||
|
if (unsafeCount > 0) {
|
||||||
|
html += `<div style="margin-bottom: 10px; padding: 6px 10px; background: #fff3cd; border: 1px solid #ffc107; border-radius: 4px; font-size: 12px; color: #856404;">⚠ 已自动排除 ${unsafeCount} 个目录名不含番号的项目,防止误删</div>`;
|
||||||
|
}
|
||||||
html += '<div style="margin-bottom: 10px;"><label style="cursor: pointer;"><input type="checkbox" class="jhs-delete-select-all" checked> <b>全选</b></label></div>';
|
html += '<div style="margin-bottom: 10px;"><label style="cursor: pointer;"><input type="checkbox" class="jhs-delete-select-all" checked> <b>全选</b></label></div>';
|
||||||
for (let i = 0; i < matchList.length; i++) {
|
for (let i = 0; i < safeMatchList.length; i++) {
|
||||||
const m = matchList[i];
|
const m = safeMatchList[i];
|
||||||
html += `<div style="margin-bottom: 6px; padding: 8px 10px; border: 1px solid #e0e0e0; border-radius: 4px; background: #fafafa;">
|
html += `<div style="margin-bottom: 6px; padding: 8px 10px; border: 1px solid #e0e0e0; border-radius: 4px; background: #fafafa;">
|
||||||
<label style="display: flex; align-items: flex-start; cursor: pointer; width: 100%;">
|
<label style="display: flex; align-items: flex-start; cursor: pointer; width: 100%;">
|
||||||
<input type="checkbox" class="jhs-delete-folder-cb" data-index="${i}" checked style="margin-top: 3px; flex-shrink: 0;">
|
<input type="checkbox" class="jhs-delete-folder-cb" data-index="${i}" checked style="margin-top: 3px; flex-shrink: 0;">
|
||||||
@@ -419,7 +429,7 @@ const _WangPan115MatchPlugin = class _WangPan115MatchPlugin extends BasePlugin {
|
|||||||
let deletedCount = 0;
|
let deletedCount = 0;
|
||||||
try {
|
try {
|
||||||
for (const i of selected) {
|
for (const i of selected) {
|
||||||
const m = matchList[i];
|
const m = safeMatchList[i];
|
||||||
const result = await gmHttp.postForm("https://webapi.115.com/rb/delete", {
|
const result = await gmHttp.postForm("https://webapi.115.com/rb/delete", {
|
||||||
pid: m.dirId,
|
pid: m.dirId,
|
||||||
"fid[0]": m.folderId
|
"fid[0]": m.folderId
|
||||||
|
|||||||
Reference in New Issue
Block a user