Update cwb_uiManager.js

This commit is contained in:
2025-10-26 04:58:31 +08:00
committed by GitHub
parent 30c3e953e2
commit e7522e1e49

View File

@@ -284,9 +284,6 @@ function bindCharCardViewerPopupEvents($popup) {
} }
}); });
const finalContentToSave = buildCustomFormat(collectedData); const finalContentToSave = buildCustomFormat(collectedData);
const allEntries = await amilyHelper.getLorebookEntries(book);
const entryToUpdate = allEntries.find(e => e.uid === targetUid);
if (!entryToUpdate) throw new Error('无法在世界书中找到原始条目。');
const insertionPosition = $activePane.find('.cwb-insertion-position').val(); const insertionPosition = $activePane.find('.cwb-insertion-position').val();
const insertionDepth = parseInt($activePane.find('.cwb-insertion-depth').val(), 10); const insertionDepth = parseInt($activePane.find('.cwb-insertion-depth').val(), 10);
@@ -306,20 +303,18 @@ function bindCharCardViewerPopupEvents($popup) {
'at_depth': 'at_depth_as_system' 'at_depth': 'at_depth_as_system'
}; };
const finalEntryData = { ...entryToUpdate }; const finalEntryData = {
uid: targetUid,
content: finalContentToSave,
position: positionMap[insertionPosition] || 'before_character_definition',
order: isNaN(insertionOrder) ? 7001 : insertionOrder,
};
finalEntryData.content = finalContentToSave;
finalEntryData.uid = targetUid;
const newPosition = positionMap[insertionPosition];
finalEntryData.position = newPosition || 'before_character_definition';
if (insertionPosition === 'at_depth') { if (insertionPosition === 'at_depth') {
finalEntryData.depth = isNaN(insertionDepth) ? 0 : insertionDepth; finalEntryData.depth = isNaN(insertionDepth) ? 0 : insertionDepth;
} else { } else {
finalEntryData.depth = null; finalEntryData.depth = null;
} }
finalEntryData.order = isNaN(insertionOrder) ? 7001 : insertionOrder;
logDebug(`[DEBUG] 最终保存数据 UID:${targetUid}`, { logDebug(`[DEBUG] 最终保存数据 UID:${targetUid}`, {
position: finalEntryData.position, position: finalEntryData.position,