From a7e97eb127aff612058851a392ab3e6ed61fb8f0 Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Thu, 22 Jan 2026 00:02:12 +0800 Subject: [PATCH] Update print statement from 'Hello' to 'Goodbye' --- ui/bindings.js | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/ui/bindings.js b/ui/bindings.js index c7f368f..015ad75 100644 --- a/ui/bindings.js +++ b/ui/bindings.js @@ -579,6 +579,84 @@ export function bindModalEvents() { }, ); + container + .off("click.amily2.jump") + .on("click.amily2.jump", "#amily2_jump_to_message_btn", function() { + const targetId = parseInt($("#amily2_jump_to_message_id").val()); + if (isNaN(targetId)) { + toastr.warning("请输入有效的楼层号"); + return; + } + + // 1. 尝试查找 DOM 元素 + const targetElement = document.querySelector(`.mes[mesid="${targetId}"]`); + + if (targetElement) { + // 【V60.1】增强跳转:自动展开被隐藏的楼层及其上下文 + const allMessages = Array.from(document.querySelectorAll('.mes')); + const targetIndex = allMessages.indexOf(targetElement); + + if (targetIndex !== -1) { + // 展开前后各10条,确保上下文连贯 + const contextRange = 10; + const start = Math.max(0, targetIndex - contextRange); + const end = Math.min(allMessages.length - 1, targetIndex + contextRange); + + let unhiddenCount = 0; + for (let i = start; i <= end; i++) { + const msg = allMessages[i]; + if (msg.style.display === 'none') { + msg.style.removeProperty('display'); + unhiddenCount++; + } + } + if (unhiddenCount > 0) { + toastr.info(`已临时展开 ${unhiddenCount} 条被隐藏的消息以显示上下文。`); + } + } + + targetElement.scrollIntoView({ behavior: "smooth", block: "center" }); + targetElement.classList.add('highlight_message'); + setTimeout(() => targetElement.classList.remove('highlight_message'), 2000); + toastr.success(`已跳转到楼层 ${targetId}`); + } else { + // 2. DOM 中未找到,尝试从内存中获取并弹窗显示 + const context = getContext(); + if (context && context.chat && context.chat[targetId]) { + const msg = context.chat[targetId]; + const sender = msg.name; + let formattedContent = msg.mes; + + // 尝试使用 SillyTavern 的格式化函数 + if (typeof messageFormatting === 'function') { + formattedContent = messageFormatting(msg.mes, sender, false, false); + } else { + formattedContent = msg.mes.replace(/\n/g, '
'); + } + + const html = ` +
+
+ ${sender} + (楼层 #${targetId}) +
+
+ ${formattedContent} +
+
+ 该楼层未在当前页面渲染(可能已被清理以节省内存),无法直接跳转,已为您在弹窗中显示。 +
+
+ `; + + showHtmlModal(`查看历史记录`, html); + toastr.info(`楼层 ${targetId} 未渲染,已在弹窗中显示内容。`); + } else { + toastr.error(`未找到楼层 ${targetId},聊天记录中不存在该索引。`); + } + } + }); + container .off("click.amily2.expand_editor") .on("click.amily2.expand_editor", "#amily2_expand_editor", function (event) {