diff --git a/CharacterWorldBook/src/cwb_lorebookManager.js b/CharacterWorldBook/src/cwb_lorebookManager.js index b8f0143..9385e59 100644 --- a/CharacterWorldBook/src/cwb_lorebookManager.js +++ b/CharacterWorldBook/src/cwb_lorebookManager.js @@ -1,696 +1,320 @@ -import { SCRIPT_ID_PREFIX, CHAR_CARD_VIEWER_BUTTON_ID, CHAR_CARD_VIEWER_POPUP_ID, state } from './cwb_state.js'; -import { logDebug, logError, showToastr, escapeHtml, parseCustomFormat, buildCustomFormat, isCwbEnabled } from './cwb_utils.js'; -import { deleteLorebookEntries, getTargetWorldBook } from './cwb_lorebookManager.js'; -import { manualUpdateLogic } from './cwb_core.js'; -import { testCwbConnection, fetchCwbModels } from './cwb_apiService.js'; -import { extensionName } from '../../utils/settings.js'; -import { extension_settings } from '/scripts/extensions.js'; -import { saveSettingsDebounced } from '/script.js'; +import { state } from './cwb_state.js'; +import { logError, logDebug, showToastr, parseCustomFormat } from './cwb_utils.js'; +import { + safeLorebooks, + safeCharLorebooks, + safeLorebookEntries, + safeUpdateLorebookEntries, + compatibleWriteToLorebook, +} from '../../core/tavernhelper-compatibility.js'; +import { amilyHelper } from '../../core/tavern-helper/main.js'; -const { jQuery: $, SillyTavern, TavernHelper } = window; +const { SillyTavern } = window; -function createCharCardViewerPopupHtml(displayItems) { - const pathToLabelMap = { - 'narrative_essence.core_traits.name': '特质名称', - 'narrative_essence.key_relationships.name': '关系人姓名', - }; - const keyToLabelMap = { - 'name': '姓名', - 'archetype': '身份原型', - 'gender': '性别', - 'age': '年龄', - 'race': '种族', - 'current_status': '当前状态', - - 'first_impression': '第一印象', - 'key_features': '显著特征', - 'attire': '衣着风格', - 'mannerisms': '习惯举止', - 'voice': '声音特征', - - 'tags': '性格标签', - 'description': '性格详述', - 'motivation': '内在驱动', - 'values': '价值观', - 'inner_conflict': '内心挣扎', - - 'interaction_style': '互动风格', - 'skills': '技能能力', - 'reputation': '他人声望', - - 'core_traits': '核心特质', - 'verbal_patterns': '语言范式', - 'key_relationships': '关键关系', - 'definition': '特质定义', - 'evidence': '具体事例', - 'style_summary': '风格总结', - 'quotes': '代表性引言', - 'summary': '关系概述', - }; - const getLabel = (key, path) => { - const pathKey = path.replace(/\.\d+\./g, '.'); - if (pathToLabelMap[pathKey]) { - return pathToLabelMap[pathKey]; - } - return keyToLabelMap[key] || key.replace(/_/g, ' '); - }; - - const renderField = (label, path, value, isTextarea = false, isArray = false) => { - const escapedLabel = escapeHtml(label); - const escapedValue = escapeHtml(isArray ? value.join('\n') : value || ''); - - const isLongContent = (value && String(value).length > 50) || (Array.isArray(value) && value.length > 1); - const rows = isArray ? Math.max(3, value.length) : (isLongContent ? 4 : 2); - - const inputElement = ``; - - return `
看什么?没更新角色条目就等着我给你显示出来条目吗?想关悬浮窗就点角色世界,功能设置关掉。