From 66703928cf2c050eba866cbc2a8783b019dbc80f Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Thu, 23 Oct 2025 22:17:27 +0800 Subject: [PATCH] Update WorldEditor.js --- WorldEditor/WorldEditor.js | 61 +++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/WorldEditor/WorldEditor.js b/WorldEditor/WorldEditor.js index bd1b878..70f87ad 100644 --- a/WorldEditor/WorldEditor.js +++ b/WorldEditor/WorldEditor.js @@ -2,21 +2,18 @@ import { world_names, loadWorldInfo, saveWorldInfo, deleteWorldInfo, updateWorldInfoList } from "/scripts/world-info.js"; import { eventSource, event_types } from '/script.js'; import { showHtmlModal } from '/scripts/extensions/third-party/ST-Amily2-Chat-Optimisation/ui/page-window.js'; -import { safeLorebooks, safeLorebookEntries, safeUpdateLorebookEntries } from '../core/tavernhelper-compatibility.js'; -import { writeToLorebookWithTavernHelper } from '../core/lore.js'; -const { SillyTavern, TavernHelper } = window; +import { safeLorebooks, safeLorebookEntries, safeUpdateLorebookEntries, compatibleWriteToLorebook } from '../core/tavernhelper-compatibility.js'; +import { amilyHelper } from '../core/tavern-helper/main.js'; +const { SillyTavern } = window; class WorldEditor { constructor() { - // 通用状态 this.isLoading = false; - // 世界书视图状态 this.allWorldBooks = []; this.filteredWorldBooks = []; this.selectedWorldBooks = new Set(); - // 条目视图状态 this.currentWorldBook = null; this.entries = []; this.selectedEntries = new Set(); @@ -204,7 +201,7 @@ class WorldEditor { if (bookName && bookName.trim()) { const trimmedBookName = bookName.trim(); try { - await writeToLorebookWithTavernHelper(trimmedBookName, '新条目', () => '这是一个新条目', {}); + await compatibleWriteToLorebook(trimmedBookName, '新条目', () => '这是一个新条目', {}); if (window.toastr) window.toastr.success(`世界书 "${trimmedBookName}" 创建成功!`); this.loadAvailableWorldBooks(); } catch (error) { @@ -305,7 +302,7 @@ class WorldEditor { this.entries = (rawEntries || []).map(e => ({ uid: e.uid, enabled: e.enabled, type: e.type || (e.constant ? 'constant' : 'selective'), keys: e.keys || [], content: e.content || '', position: e.position || 'before_character_definition', - depth: (e.position?.startsWith('at_depth')) ? e.depth : null, order: e.order || 100, comment: e.comment || '', + depth: (String(e.position)?.startsWith('at_depth')) ? e.depth : null, order: e.order || 100, comment: e.comment || '', exclude_recursion: e.exclude_recursion, prevent_recursion: e.prevent_recursion })); this.filteredEntries = [...this.entries]; @@ -381,7 +378,7 @@ class WorldEditor {