Update cwb_uiManager.js

This commit is contained in:
2025-09-08 03:34:49 +08:00
committed by GitHub
parent 0a57c42edc
commit 4bcf82a51f

View File

@@ -219,28 +219,32 @@ function bindCharCardViewerPopupEvents($popup) {
$popup.find('.cwb-cyber-tab__delete').on('click', async function(e) { $popup.find('.cwb-cyber-tab__delete').on('click', async function(e) {
e.stopPropagation(); e.stopPropagation();
const uidToDelete = $(this).data('char-uid'); if (confirm('您确定要删除这个角色条目吗?此操作不可撤销。')) {
await deleteLorebookEntries([uidToDelete]); const uidToDelete = $(this).data('char-uid');
const $wrapper = $(this).closest('.cwb-cyber-tab'); await deleteLorebookEntries([uidToDelete]);
const $pane = $popup.find(`#cwb-char-content-${uidToDelete}`); const $wrapper = $(this).closest('.cwb-cyber-tab');
const wasActive = $wrapper.hasClass('active'); const $pane = $popup.find(`#cwb-char-content-${uidToDelete}`);
$wrapper.remove(); const wasActive = $wrapper.hasClass('active');
$pane.remove(); $wrapper.remove();
if (wasActive && $popup.find('.cwb-cyber-tab').length > 0) { $pane.remove();
$popup.find('.cwb-cyber-tab').first().find('.cwb-cyber-tab__button').trigger('click'); if (wasActive && $popup.find('.cwb-cyber-tab').length > 0) {
} else if ($popup.find('.cwb-cyber-tab').length === 0) { $popup.find('.cwb-cyber-tab').first().find('.cwb-cyber-tab__button').trigger('click');
showCharCardViewerPopup(); } else if ($popup.find('.cwb-cyber-tab').length === 0) {
showCharCardViewerPopup();
}
} }
}); });
$popup.find('#cwb-viewer-delete-all').on('click', async function() { $popup.find('#cwb-viewer-delete-all').on('click', async function() {
const allUids = $popup.find('.cwb-cyber-tab__button').map(function() { if (confirm('您确定要清除当前聊天中的所有角色卡和总览吗?此操作将删除所有相关条目,且不可撤销。')) {
return $(this).data('char-uid'); const allUids = $popup.find('.cwb-cyber-tab__button').map(function() {
}).get(); return $(this).data('char-uid');
if (allUids.length > 0) { }).get();
await deleteLorebookEntries(allUids); if (allUids.length > 0) {
await deleteLorebookEntries(allUids);
}
showCharCardViewerPopup();
} }
showCharCardViewerPopup();
}); });
$popup.find('.cwb-save-button').on('click', async function () { $popup.find('.cwb-save-button').on('click', async function () {