mirror of
https://github.com/Wx-2025/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 05:45:51 +00:00
Compare commits
4 Commits
b77122d025
...
6cc8b3f358
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cc8b3f358 | |||
| a7e97eb127 | |||
| 47575e763f | |||
| c278972b75 |
@@ -291,6 +291,15 @@
|
||||
<button class="menu_button primary interactable" id="amily2_test"><i class="fas fa-search"></i> 测试检查</button>
|
||||
<button class="menu_button accent interactable" id="amily2_fix_now"><i class="fas fa-magic"></i> 立即修复</button>
|
||||
</div>
|
||||
<div class="amily2_settings_block" style="display: flex; flex-direction: row; gap: 10px; align-items: center; margin-top: 10px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 15px;">
|
||||
<div style="position: relative; flex-shrink: 0;">
|
||||
<input type="number" id="amily2_jump_to_message_id" class="text_pole" placeholder="楼层" style="width: 100px !important; padding-left: 30px;">
|
||||
<i class="fas fa-hashtag" style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.5);"></i>
|
||||
</div>
|
||||
<button id="amily2_jump_to_message_btn" class="menu_button interactable" style="flex-grow: 1; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<i class="fas fa-share"></i> <span>跳转到楼层</span>
|
||||
</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -729,3 +729,25 @@ hr.header-divider {
|
||||
#amily2_test_api_connection {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
/* === 消息高亮样式 === */
|
||||
.highlight_message {
|
||||
animation: highlight-pulse 2s ease-out;
|
||||
border: 2px solid #ff9800 !important;
|
||||
box-shadow: 0 0 15px rgba(255, 152, 0, 0.5);
|
||||
}
|
||||
|
||||
@keyframes highlight-pulse {
|
||||
0% {
|
||||
background-color: rgba(255, 152, 0, 0.3);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
50% {
|
||||
background-color: rgba(255, 152, 0, 0.1);
|
||||
transform: scale(1);
|
||||
}
|
||||
100% {
|
||||
background-color: transparent;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, '<br>');
|
||||
}
|
||||
|
||||
const html = `
|
||||
<div style="padding: 10px;">
|
||||
<div style="margin-bottom: 10px; font-size: 1.1em; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 5px;">
|
||||
<strong style="color: var(--smart-theme-color, #ffcc00);">${sender}</strong>
|
||||
<span style="opacity: 0.6; font-size: 0.8em;">(楼层 #${targetId})</span>
|
||||
</div>
|
||||
<div class="mes_text" style="max-height: 60vh; overflow-y: auto;">
|
||||
${formattedContent}
|
||||
</div>
|
||||
<div style="margin-top: 15px; font-size: 0.9em; opacity: 0.7; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 5px;">
|
||||
<i class="fas fa-info-circle"></i> 该楼层未在当前页面渲染(可能已被清理以节省内存),无法直接跳转,已为您在弹窗中显示。
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
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) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user