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
|
* @param classificationId
|
||||||
@ -419,6 +447,7 @@ export {
|
|||||||
batchAdd,
|
batchAdd,
|
||||||
update,
|
update,
|
||||||
del,
|
del,
|
||||||
|
batchDel,
|
||||||
selectById,
|
selectById,
|
||||||
selectByIdList,
|
selectByIdList,
|
||||||
deleteByClassificationId,
|
deleteByClassificationId,
|
||||||
|
@ -28,7 +28,15 @@ import {
|
|||||||
getStartMenuItemList,
|
getStartMenuItemList,
|
||||||
getSystemItemList,
|
getSystemItemList,
|
||||||
} from "./commons";
|
} 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 { Item } from "../../../types/item";
|
||||||
import { getFileExtname, isAbsolutePath } from "../../../commons/utils/common";
|
import { getFileExtname, isAbsolutePath } from "../../../commons/utils/common";
|
||||||
import {
|
import {
|
||||||
@ -579,12 +587,10 @@ export default function () {
|
|||||||
[global.language.ok, global.language.cancel]
|
[global.language.ok, global.language.cancel]
|
||||||
);
|
);
|
||||||
if (res === 0) {
|
if (res === 0) {
|
||||||
for (const id of batchSelectedIdList) {
|
// 批量删除
|
||||||
// 删除数据
|
batchDel(batchSelectedIdList);
|
||||||
del(id);
|
// 快捷键
|
||||||
// 快捷键
|
setShortcutKey();
|
||||||
setShortcutKey();
|
|
||||||
}
|
|
||||||
// 通知前端删除数据
|
// 通知前端删除数据
|
||||||
sendToWebContent(
|
sendToWebContent(
|
||||||
"mainWindow",
|
"mainWindow",
|
||||||
|
Loading…
Reference in New Issue
Block a user