mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 08:55:50 +00:00
Update index.js
This commit is contained in:
12
index.js
12
index.js
@@ -328,6 +328,7 @@ jQuery(async () => {
|
|||||||
context.registerMacro('Amily2EditContent', () => {
|
context.registerMacro('Amily2EditContent', () => {
|
||||||
const content = generateTableContent();
|
const content = generateTableContent();
|
||||||
if (content) {
|
if (content) {
|
||||||
|
// 只有当宏被实际调用并生成内容时,才设置标志
|
||||||
window.AMILY2_MACRO_REPLACED = true;
|
window.AMILY2_MACRO_REPLACED = true;
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
@@ -454,16 +455,19 @@ jQuery(async () => {
|
|||||||
eventSource.on(event_types.IMPERSONATE_READY, onMessageReceived);
|
eventSource.on(event_types.IMPERSONATE_READY, onMessageReceived);
|
||||||
eventSource.on(event_types.MESSAGE_RECEIVED, (chat_id) => handleTableUpdate(chat_id));
|
eventSource.on(event_types.MESSAGE_RECEIVED, (chat_id) => handleTableUpdate(chat_id));
|
||||||
eventSource.on(event_types.MESSAGE_SWIPED, (chat_id) => {
|
eventSource.on(event_types.MESSAGE_SWIPED, (chat_id) => {
|
||||||
|
log(`【监察系统】检测到消息滑动 (SWIPED),开始回滚并刷新状态。`, 'warn');
|
||||||
clearHighlights();
|
clearHighlights();
|
||||||
|
loadTables(); // 【V140.0 核心修复】滑动时,从聊天记录末尾重新加载正确的表格状态
|
||||||
handleTableUpdate(chat_id);
|
handleTableUpdate(chat_id);
|
||||||
updateOrInsertTableInChat();
|
updateOrInsertTableInChat(); // Also update in-chat table on swipe
|
||||||
});
|
});
|
||||||
eventSource.on(event_types.MESSAGE_EDITED, (mes_id) => {
|
eventSource.on(event_types.MESSAGE_EDITED, (mes_id) => {
|
||||||
handleTableUpdate(mes_id);
|
handleTableUpdate(mes_id);
|
||||||
updateOrInsertTableInChat();
|
updateOrInsertTableInChat(); // Update in-chat table on edit
|
||||||
});
|
});
|
||||||
|
|
||||||
eventSource.on(event_types.CHAT_CHANGED, () => {
|
eventSource.on(event_types.CHAT_CHANGED, () => {
|
||||||
|
// 【新增】切换聊天时,清除上一次的优化结果
|
||||||
window.lastPreOptimizationResult = null;
|
window.lastPreOptimizationResult = null;
|
||||||
document.dispatchEvent(new CustomEvent('preOptimizationTextUpdated'));
|
document.dispatchEvent(new CustomEvent('preOptimizationTextUpdated'));
|
||||||
|
|
||||||
@@ -483,6 +487,7 @@ jQuery(async () => {
|
|||||||
renderTables();
|
renderTables();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 【新增】监听多种事件,以在聊天窗口中渲染表格,确保在各种情况下都能正确显示
|
||||||
eventSource.on(event_types.MESSAGE_RECEIVED, updateOrInsertTableInChat);
|
eventSource.on(event_types.MESSAGE_RECEIVED, updateOrInsertTableInChat);
|
||||||
eventSource.on(event_types.chat_updated, updateOrInsertTableInChat);
|
eventSource.on(event_types.chat_updated, updateOrInsertTableInChat);
|
||||||
|
|
||||||
@@ -504,6 +509,8 @@ jQuery(async () => {
|
|||||||
console.log('[Amily2-核心引擎] 开始执行统一注入 (聊天长度:', args[0]?.length || 0, ')');
|
console.log('[Amily2-核心引擎] 开始执行统一注入 (聊天长度:', args[0]?.length || 0, ')');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 调用 injectTableData。该函数现在内部包含逻辑,
|
||||||
|
// 如果宏已被替换,它将自动跳过执行,从而避免重复注入。
|
||||||
injectTableData(...args);
|
injectTableData(...args);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[Amily2-内存储司] 表格注入失败:', error);
|
console.error('[Amily2-内存储司] 表格注入失败:', error);
|
||||||
@@ -528,6 +535,7 @@ jQuery(async () => {
|
|||||||
|
|
||||||
console.log("【Amily2号】帝国秩序已完美建立。Amily2号的府邸已恭候陛下的莅临。");
|
console.log("【Amily2号】帝国秩序已完美建立。Amily2号的府邸已恭候陛下的莅临。");
|
||||||
|
|
||||||
|
// 初始化版本检测功能
|
||||||
console.log("[Amily2号-开国大典] 步骤七:初始化版本显示系统...");
|
console.log("[Amily2号-开国大典] 步骤七:初始化版本显示系统...");
|
||||||
if (typeof window.amily2Updater !== 'undefined') {
|
if (typeof window.amily2Updater !== 'undefined') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user