mirror of
https://github.com/Wx-2025/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 12:45:51 +00:00
Update table-bindings.js
This commit is contained in:
@@ -11,6 +11,7 @@ import { world_names, loadWorldInfo } from '/scripts/world-info.js';
|
|||||||
import { safeCharLorebooks, safeLorebookEntries } from '../core/tavernhelper-compatibility.js';
|
import { safeCharLorebooks, safeLorebookEntries } from '../core/tavernhelper-compatibility.js';
|
||||||
import { characters, this_chid, eventSource, event_types } from "/script.js";
|
import { characters, this_chid, eventSource, event_types } from "/script.js";
|
||||||
import { fetchNccsModels, testNccsApiConnection } from '../core/api/NccsApi.js';
|
import { fetchNccsModels, testNccsApiConnection } from '../core/api/NccsApi.js';
|
||||||
|
import { showGraphVisualization } from '../core/relationship-graph/visualizer.js';
|
||||||
|
|
||||||
const isTouchDevice = () => window.matchMedia('(pointer: coarse)').matches;
|
const isTouchDevice = () => window.matchMedia('(pointer: coarse)').matches;
|
||||||
const getAllTablesContainer = () => document.getElementById('all-tables-container');
|
const getAllTablesContainer = () => document.getElementById('all-tables-container');
|
||||||
@@ -1247,13 +1248,14 @@ export function bindTableEvents() {
|
|||||||
log('开始为表格视图绑定交互事件...', 'info');
|
log('开始为表格视图绑定交互事件...', 'info');
|
||||||
|
|
||||||
const fillingModeRadios = panel.querySelectorAll('input[name="filling-mode"]');
|
const fillingModeRadios = panel.querySelectorAll('input[name="filling-mode"]');
|
||||||
const contextSliderContainer = document.getElementById('context-reading-slider-container');
|
|
||||||
const contextSlider = document.getElementById('context-reading-slider');
|
|
||||||
const contextValueSpan = document.getElementById('context-reading-value');
|
|
||||||
|
|
||||||
const delaySliderContainer = document.getElementById('secondary-filler-delay-container');
|
// 获取新的分步填表控制容器
|
||||||
const delaySlider = document.getElementById('secondary-filler-delay-slider');
|
const secondaryFillerControls = document.getElementById('secondary-filler-controls');
|
||||||
const delayValueSpan = document.getElementById('secondary-filler-delay-value');
|
|
||||||
|
// 获取新的滑块元素
|
||||||
|
const contextSlider = document.getElementById('secondary-filler-context');
|
||||||
|
const batchSlider = document.getElementById('secondary-filler-batch');
|
||||||
|
const bufferSlider = document.getElementById('secondary-filler-buffer');
|
||||||
|
|
||||||
const independentRulesContainer = document.getElementById('table-independent-rules-container');
|
const independentRulesContainer = document.getElementById('table-independent-rules-container');
|
||||||
const independentRulesToggle = document.getElementById('table-independent-rules-enabled');
|
const independentRulesToggle = document.getElementById('table-independent-rules-enabled');
|
||||||
@@ -1267,12 +1269,8 @@ export function bindTableEvents() {
|
|||||||
|
|
||||||
const isSecondaryMode = currentMode === 'secondary-api';
|
const isSecondaryMode = currentMode === 'secondary-api';
|
||||||
|
|
||||||
if (contextSliderContainer) {
|
if (secondaryFillerControls) {
|
||||||
contextSliderContainer.style.display = isSecondaryMode ? 'block' : 'none';
|
secondaryFillerControls.style.display = isSecondaryMode ? 'block' : 'none';
|
||||||
}
|
|
||||||
|
|
||||||
if (delaySliderContainer) {
|
|
||||||
delaySliderContainer.style.display = isSecondaryMode ? 'block' : 'none';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (independentRulesContainer) {
|
if (independentRulesContainer) {
|
||||||
@@ -1298,33 +1296,36 @@ export function bindTableEvents() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (contextSlider && contextValueSpan) {
|
// 绑定上下文深度输入框
|
||||||
const contextReadingValue = extension_settings[extensionName]?.context_reading_level || 4;
|
if (contextSlider) {
|
||||||
contextSlider.value = contextReadingValue;
|
const value = extension_settings[extensionName]?.secondary_filler_context || 2;
|
||||||
contextValueSpan.textContent = contextReadingValue;
|
contextSlider.value = value;
|
||||||
|
|
||||||
contextSlider.addEventListener('input', function() {
|
|
||||||
contextValueSpan.textContent = this.value;
|
|
||||||
});
|
|
||||||
|
|
||||||
contextSlider.addEventListener('change', function() {
|
contextSlider.addEventListener('change', function() {
|
||||||
updateAndSaveTableSetting('context_reading_level', parseInt(this.value, 10));
|
updateAndSaveTableSetting('secondary_filler_context', parseInt(this.value, 10));
|
||||||
toastr.info(`上下文读取级别已设置为 ${this.value}。`);
|
toastr.info(`上下文深度已设置为 ${this.value}。`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delaySlider && delayValueSpan) {
|
// 绑定填表批次输入框
|
||||||
const delayValue = extension_settings[extensionName]?.secondary_filler_delay || 0;
|
if (batchSlider) {
|
||||||
delaySlider.value = delayValue;
|
const value = extension_settings[extensionName]?.secondary_filler_batch || 0;
|
||||||
delayValueSpan.textContent = delayValue;
|
batchSlider.value = value;
|
||||||
|
|
||||||
delaySlider.addEventListener('input', function() {
|
|
||||||
delayValueSpan.textContent = this.value;
|
|
||||||
});
|
|
||||||
|
|
||||||
delaySlider.addEventListener('change', function() {
|
batchSlider.addEventListener('change', function() {
|
||||||
updateAndSaveTableSetting('secondary_filler_delay', parseInt(this.value, 10));
|
updateAndSaveTableSetting('secondary_filler_batch', parseInt(this.value, 10));
|
||||||
toastr.info(`填表延迟已设置为 ${this.value} 楼层。`);
|
toastr.info(`填表批次已设置为 ${this.value}。`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绑定保留楼层输入框
|
||||||
|
if (bufferSlider) {
|
||||||
|
const value = extension_settings[extensionName]?.secondary_filler_buffer || 0;
|
||||||
|
bufferSlider.value = value;
|
||||||
|
|
||||||
|
bufferSlider.addEventListener('change', function() {
|
||||||
|
updateAndSaveTableSetting('secondary_filler_buffer', parseInt(this.value, 10));
|
||||||
|
toastr.info(`保留楼层已设置为 ${this.value}。`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1378,12 +1379,19 @@ export function bindTableEvents() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openGraphBtn = document.getElementById('amily2-open-relationship-graph-btn');
|
||||||
const exportBtn = document.getElementById('amily2-export-preset-btn');
|
const exportBtn = document.getElementById('amily2-export-preset-btn');
|
||||||
const exportFullBtn = document.getElementById('amily2-export-preset-full-btn');
|
const exportFullBtn = document.getElementById('amily2-export-preset-full-btn');
|
||||||
const importBtn = document.getElementById('amily2-import-preset-btn');
|
const importBtn = document.getElementById('amily2-import-preset-btn');
|
||||||
const importGlobalBtn = document.getElementById('amily2-import-global-preset-btn');
|
const importGlobalBtn = document.getElementById('amily2-import-global-preset-btn');
|
||||||
const clearGlobalBtn = document.getElementById('amily2-clear-global-preset-btn');
|
const clearGlobalBtn = document.getElementById('amily2-clear-global-preset-btn');
|
||||||
|
|
||||||
|
if (openGraphBtn) {
|
||||||
|
openGraphBtn.addEventListener('click', () => {
|
||||||
|
showGraphVisualization();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (exportBtn) {
|
if (exportBtn) {
|
||||||
exportBtn.addEventListener('click', () => TableManager.exportPreset());
|
exportBtn.addEventListener('click', () => TableManager.exportPreset());
|
||||||
}
|
}
|
||||||
@@ -2076,11 +2084,9 @@ function bindChatTableDisplaySetting() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize states from settings
|
|
||||||
showInChatToggle.checked = settings.show_table_in_chat === true;
|
showInChatToggle.checked = settings.show_table_in_chat === true;
|
||||||
continuousRenderToggle.checked = settings.render_on_every_message === true;
|
continuousRenderToggle.checked = settings.render_on_every_message === true;
|
||||||
|
|
||||||
// Function to update the dependency
|
|
||||||
const updateContinuousRenderState = () => {
|
const updateContinuousRenderState = () => {
|
||||||
if (showInChatToggle.checked) {
|
if (showInChatToggle.checked) {
|
||||||
continuousRenderToggle.disabled = false;
|
continuousRenderToggle.disabled = false;
|
||||||
@@ -2091,10 +2097,8 @@ function bindChatTableDisplaySetting() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initial state update
|
|
||||||
updateContinuousRenderState();
|
updateContinuousRenderState();
|
||||||
|
|
||||||
// Event listener for the main toggle
|
|
||||||
showInChatToggle.addEventListener('change', () => {
|
showInChatToggle.addEventListener('change', () => {
|
||||||
settings.show_table_in_chat = showInChatToggle.checked;
|
settings.show_table_in_chat = showInChatToggle.checked;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
@@ -2102,7 +2106,6 @@ function bindChatTableDisplaySetting() {
|
|||||||
updateContinuousRenderState();
|
updateContinuousRenderState();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event listener for the continuous render toggle
|
|
||||||
continuousRenderToggle.addEventListener('change', () => {
|
continuousRenderToggle.addEventListener('change', () => {
|
||||||
settings.render_on_every_message = continuousRenderToggle.checked;
|
settings.render_on_every_message = continuousRenderToggle.checked;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
|
|||||||
Reference in New Issue
Block a user