From 6600e5bad50817985ae9eda5dbe66a26e0ac9a2f Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Tue, 9 Dec 2025 00:54:26 +0800 Subject: [PATCH] Update lore.js --- core/lore.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/core/lore.js b/core/lore.js index 84e979f..8780b35 100644 --- a/core/lore.js +++ b/core/lore.js @@ -281,11 +281,16 @@ export async function getPlotOptimizedWorldbookContent(context, apiSettings) { liveSettings.selectedWorldbooks = []; if (liveSettings.worldbookSource === 'manual') { - panel.find('#amily2_opt_worldbook_checkbox_list input[type="checkbox"]:checked').each(function() { + panel.find('#amily2_opt_worldbook_checkbox_list input[type="checkbox"]:not(.amily2_opt_wb_auto_check):checked').each(function() { liveSettings.selectedWorldbooks.push($(this).val()); }); } + liveSettings.autoSelectWorldbooks = []; + panel.find('#amily2_opt_worldbook_checkbox_list input.amily2_opt_wb_auto_check:checked').each(function() { + liveSettings.autoSelectWorldbooks.push($(this).data('book')); + }); + liveSettings.worldbookCharLimit = parseInt(panel.find('#amily2_opt_worldbook_char_limit').val(), 10) || 60000; let enabledEntries = {}; @@ -311,6 +316,7 @@ export async function getPlotOptimizedWorldbookContent(context, apiSettings) { worldbookEnabled: apiSettings.plotOpt_worldbook_enabled, worldbookSource: apiSettings.plotOpt_worldbook_source || 'character', // Default to 'character' selectedWorldbooks: apiSettings.plotOpt_worldbook_selected_worldbooks, + autoSelectWorldbooks: apiSettings.plotOpt_autoSelectWorldbooks || [], worldbookCharLimit: apiSettings.plotOpt_worldbook_char_limit, enabledWorldbookEntries: apiSettings.plotOpt_worldbook_selected_entries, }; @@ -351,11 +357,23 @@ export async function getPlotOptimizedWorldbookContent(context, apiSettings) { if (allEntries.length === 0) return ''; const enabledEntriesMap = liveSettings.enabledWorldbookEntries || {}; + const autoSelectedBooks = liveSettings.autoSelectWorldbooks || []; + const userEnabledEntries = allEntries.filter(entry => { if (!entry.enabled) return false; + + // 检查是否在UI中被勾选(或被自动全选) + const isAuto = autoSelectedBooks.includes(entry.bookName); const bookConfig = enabledEntriesMap[entry.bookName]; - // 同时检查数字和字符串类型的UID,以兼容从实时UI(数字)和已保存设置(可能为字符串)中读取的配置 - return bookConfig ? (bookConfig.includes(entry.uid) || bookConfig.includes(String(entry.uid))) : false; + const isChecked = isAuto || (bookConfig ? (bookConfig.includes(entry.uid) || bookConfig.includes(String(entry.uid))) : false); + + if (isChecked) { + // 勾选状态下必读 (强制设为 Constant) + entry.constant = true; + } + // 不勾选则依靠蓝绿灯 (保持原样,不返回 false) + + return true; }); if (userEnabledEntries.length === 0) return '';