mirror of
https://github.com/fanchenio/DawnLauncher.git
synced 2025-07-13 21:02:10 +08:00
优化批量删除项目出现卡顿的问题。
This commit is contained in:
parent
0327dfc0cc
commit
ed77cc4fb4
@ -323,6 +323,34 @@ function del(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
function batchDel(idList: Array<number>) {
|
||||
// 批量查询
|
||||
let itemList = selectByIdList(true, idList);
|
||||
// 参数
|
||||
let params = itemList.map((item) => item.id).join(",");
|
||||
// SQL
|
||||
let sql = `DELETE FROM ${tableName} WHERE id in (?)`;
|
||||
// 运行
|
||||
let res = db.prepare(sql).run(params).changes > 0;
|
||||
if (res) {
|
||||
// 提取分类ID
|
||||
let classificationIdList = new Set<number>();
|
||||
itemList.forEach((item) => {
|
||||
classificationIdList.add(item.classificationId);
|
||||
});
|
||||
// 更新序号
|
||||
classificationIdList.forEach((classificationId) => {
|
||||
reorder(classificationId);
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param classificationId
|
||||
@ -419,6 +447,7 @@ export {
|
||||
batchAdd,
|
||||
update,
|
||||
del,
|
||||
batchDel,
|
||||
selectById,
|
||||
selectByIdList,
|
||||
deleteByClassificationId,
|
||||
|
@ -28,7 +28,15 @@ import {
|
||||
getStartMenuItemList,
|
||||
getSystemItemList,
|
||||
} from "./commons";
|
||||
import { add, del, list, selectById, update, updateOrder } from "./data";
|
||||
import {
|
||||
add,
|
||||
batchDel,
|
||||
del,
|
||||
list,
|
||||
selectById,
|
||||
update,
|
||||
updateOrder,
|
||||
} from "./data";
|
||||
import { Item } from "../../../types/item";
|
||||
import { getFileExtname, isAbsolutePath } from "../../../commons/utils/common";
|
||||
import {
|
||||
@ -579,12 +587,10 @@ export default function () {
|
||||
[global.language.ok, global.language.cancel]
|
||||
);
|
||||
if (res === 0) {
|
||||
for (const id of batchSelectedIdList) {
|
||||
// 删除数据
|
||||
del(id);
|
||||
// 快捷键
|
||||
setShortcutKey();
|
||||
}
|
||||
// 批量删除
|
||||
batchDel(batchSelectedIdList);
|
||||
// 快捷键
|
||||
setShortcutKey();
|
||||
// 通知前端删除数据
|
||||
sendToWebContent(
|
||||
"mainWindow",
|
||||
|
Loading…
Reference in New Issue
Block a user