mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 11:15:50 +00:00
Update cwb_uiManager.js
This commit is contained in:
@@ -282,14 +282,6 @@ function bindCharCardViewerPopupEvents($popup) {
|
|||||||
setNestedValue(collectedData, path, value);
|
setNestedValue(collectedData, path, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let localTavernHelper = TavernHelper;
|
|
||||||
if (!localTavernHelper) {
|
|
||||||
// TavernHelper 未定义的情况下触发,但是为什么?
|
|
||||||
(localTavernHelper = window.TavernHelper);
|
|
||||||
if (localTavernHelper) {
|
|
||||||
TavernHelper = localTavernHelper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const finalContentToSave = buildCustomFormat(collectedData);
|
const finalContentToSave = buildCustomFormat(collectedData);
|
||||||
const allEntries = await TavernHelper.getLorebookEntries(book);
|
const allEntries = await TavernHelper.getLorebookEntries(book);
|
||||||
const entryToUpdate = allEntries.find(e => e.uid === targetUid);
|
const entryToUpdate = allEntries.find(e => e.uid === targetUid);
|
||||||
@@ -334,14 +326,7 @@ function bindCharCardViewerPopupEvents($popup) {
|
|||||||
order: finalEntryData.order,
|
order: finalEntryData.order,
|
||||||
hasDepthField: 'depth' in finalEntryData
|
hasDepthField: 'depth' in finalEntryData
|
||||||
});
|
});
|
||||||
localTavernHelper = TavernHelper;
|
|
||||||
if (!localTavernHelper) {
|
|
||||||
// TavernHelper 未定义的情况下触发,但是为什么?
|
|
||||||
(localTavernHelper = window.TavernHelper);
|
|
||||||
if (localTavernHelper) {
|
|
||||||
TavernHelper = localTavernHelper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await TavernHelper.setLorebookEntries(book, [finalEntryData]);
|
await TavernHelper.setLorebookEntries(book, [finalEntryData]);
|
||||||
showToastr('success', '角色卡已成功保存!');
|
showToastr('success', '角色卡已成功保存!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -368,14 +353,6 @@ export async function showCharCardViewerPopup() {
|
|||||||
bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`));
|
bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let localTavernHelper = TavernHelper;
|
|
||||||
if (!localTavernHelper) {
|
|
||||||
// TavernHelper 未定义的情况下触发,但是为什么?
|
|
||||||
(localTavernHelper = window.TavernHelper);
|
|
||||||
if (localTavernHelper) {
|
|
||||||
TavernHelper = localTavernHelper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const allEntries = await TavernHelper.getLorebookEntries(book);
|
const allEntries = await TavernHelper.getLorebookEntries(book);
|
||||||
let currentChatId = state.currentChatFileIdentifier;
|
let currentChatId = state.currentChatFileIdentifier;
|
||||||
|
|
||||||
@@ -430,6 +407,7 @@ export async function showCharCardViewerPopup() {
|
|||||||
const characterEntries = relevantEntries
|
const characterEntries = relevantEntries
|
||||||
.filter(entry => !entry.keys.includes('Amily2角色总集'))
|
.filter(entry => !entry.keys.includes('Amily2角色总集'))
|
||||||
.map(entry => {
|
.map(entry => {
|
||||||
|
try {
|
||||||
logDebug(`[DEBUG] 原始条目数据 UID:${entry.uid}`, {
|
logDebug(`[DEBUG] 原始条目数据 UID:${entry.uid}`, {
|
||||||
position: entry.position,
|
position: entry.position,
|
||||||
depth: entry.depth,
|
depth: entry.depth,
|
||||||
@@ -469,8 +447,12 @@ export async function showCharCardViewerPopup() {
|
|||||||
insertionDepth: finalDepth,
|
insertionDepth: finalDepth,
|
||||||
insertionOrder: entry.order ?? 7001,
|
insertionOrder: entry.order ?? 7001,
|
||||||
};
|
};
|
||||||
|
} catch (e) {
|
||||||
|
logError(`解析角色条目失败 (UID: ${entry.uid}),已跳过。`, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.filter(c => c.parsed && Object.keys(c.parsed).length > 0);
|
.filter(c => c && c.parsed && Object.keys(c.parsed).length > 0);
|
||||||
|
|
||||||
displayItems = displayItems.concat(characterEntries);
|
displayItems = displayItems.concat(characterEntries);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user