From e2545923aa063686a41dc77f27e42517e332c09f Mon Sep 17 00:00:00 2001 From: Wx-2025 <351320169@qq.com> Date: Tue, 23 Dec 2025 13:07:04 +0800 Subject: [PATCH] Update fmt.Println message from 'Hello' to 'Goodbye' --- ui/table-bindings.js | 112 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 105 insertions(+), 7 deletions(-) diff --git a/ui/table-bindings.js b/ui/table-bindings.js index b5e2192..212c9d5 100644 --- a/ui/table-bindings.js +++ b/ui/table-bindings.js @@ -376,14 +376,21 @@ export function renderTables() { } tableElement.appendChild(colgroup); + // Explicitly calculate and set the total table width to override CSS conflicts let totalWidth = 0; const cols = colgroup.querySelectorAll('col'); cols.forEach(col => { totalWidth += parseInt(col.style.width, 10); }); + // Set min-width instead of fixed width to allow expansion tableElement.style.minWidth = '100%'; if (totalWidth > 0) { + // Only set explicit width if it exceeds the container (handled by min-width: 100% usually, + // but here we set it as a base to ensure columns don't shrink below their defined width) tableElement.style.width = `${Math.max(totalWidth, 0)}px`; + // Actually, to allow full width expansion, we should just use min-width and let CSS handle the rest + // unless we want to force scrolling. + // Let's try setting min-width to the calculated total, and width to 100%. tableElement.style.minWidth = `${totalWidth}px`; tableElement.style.width = '100%'; } @@ -801,6 +808,12 @@ function openRuleEditor(tableIndex) { 当表格总行数超过设定值时,将在表格底部显示警告。 +
+ + + 设置一个行号 X。在填表时,第 0 行到第 X-1 行的内容将被省略并替换为“已锁定”提示。这可以节省 Token 并防止 AI 修改旧数据。 +
+
@@ -882,6 +895,7 @@ function openRuleEditor(tableIndex) { dialogElement.find('.popup-button-ok').on('click', () => { const newCharLimitRules = JSON.parse(dialogElement.find('#current-char-limit-rules').attr('data-rules') || '{}'); const rowLimitValue = parseInt(dialogElement.find('#rule-row-limit-value').val(), 10); + const simplifyThresholdValue = parseInt(dialogElement.find('#rule-simplify-threshold').val(), 10); const newRules = { note: dialogElement.find('#rule-note').val(), @@ -890,6 +904,7 @@ function openRuleEditor(tableIndex) { rule_update: dialogElement.find('#rule-update').val(), charLimitRules: newCharLimitRules, rowLimitRule: rowLimitValue, + simplifyRowThreshold: simplifyThresholdValue, // 保存新设置 }; TableManager.updateTableRules(tableIndex, newRules); closeDialog(); @@ -1356,6 +1371,7 @@ export function bindTableEvents() { bindBatchFillButton(); // 【新增】绑定批量填表按钮 bindFloorFillButtons(); // 【新增】绑定楼层填表按钮 bindReorganizeButton(); // 【新增】绑定重新整理按钮 + bindClearRecordsButton(); // 【新增】绑定清除记录按钮 bindNccsApiEvents(); // 【新增】绑定Nccs API系统事件 bindChatTableDisplaySetting(); // 【新增】绑定聊天内表格显示开关 @@ -1623,13 +1639,63 @@ function bindReorganizeButton() { return; } - try { - const { reorganizeTableContent } = await import('../core/table-system/reorganizer.js'); - await reorganizeTableContent(); - } catch (error) { - console.error('[内存储司] 重新整理功能导入失败:', error); - toastr.error('重新整理功能启动失败,请检查系统状态。'); + const tables = TableManager.getMemoryState(); + if (!tables || tables.length === 0) { + toastr.warning('当前没有表格可供整理。'); + return; } + + // 构建表格选择列表 HTML + const tableListHtml = tables.map((table, index) => ` +
+ + +
+ `).join(''); + + const modalHtml = ` +
+

建议:最好一次只选择一个表格,或少数几个相关联的表格进行整理。一次性处理过多表格可能会导致AI混淆或遗漏信息。

+

请勾选需要AI重新整理和去重的表格:

+
+ ${tableListHtml} +
+
+ + +
+
+ `; + + showHtmlModal('选择要整理的表格', modalHtml, { + onOk: async (dialogElement) => { + const selectedIndices = []; + dialogElement.find('input[type="checkbox"]:checked').each(function() { + selectedIndices.push(parseInt($(this).val(), 10)); + }); + + if (selectedIndices.length === 0) { + toastr.warning('请至少选择一个表格。'); + return false; // 阻止关闭弹窗 + } + + try { + const { reorganizeTableContent } = await import('../core/table-system/reorganizer.js'); + await reorganizeTableContent(selectedIndices); + } catch (error) { + console.error('[内存储司] 重新整理功能导入失败:', error); + toastr.error('重新整理功能启动失败,请检查系统状态。'); + } + }, + onShow: (dialogElement) => { + dialogElement.find('#reorg-select-all').on('click', () => { + dialogElement.find('input[type="checkbox"]').prop('checked', true); + }); + dialogElement.find('#reorg-deselect-all').on('click', () => { + dialogElement.find('input[type="checkbox"]').prop('checked', false); + }); + } + }); }); reorganizeBtn.dataset.reorganizeEventBound = 'true'; @@ -1637,6 +1703,37 @@ function bindReorganizeButton() { } } +function bindClearRecordsButton() { + const clearBtn = document.getElementById('clear-records-btn'); + const floorInput = document.getElementById('clear-records-before-floor'); + + if (clearBtn && floorInput) { + if (clearBtn.dataset.clearEventBound) return; + + clearBtn.addEventListener('click', async () => { + const floorIndex = parseInt(floorInput.value, 10); + if (isNaN(floorIndex) || floorIndex < 0) { + toastr.warning('请输入有效的楼层号。'); + return; + } + + if (confirm(`【警告】您确定要清除第 ${floorIndex} 楼之前的所有表格记录吗?\n\n此操作将永久删除这些消息中存储的表格快照,无法恢复。当前最新的表格状态不会受影响。`)) { + try { + const { clearTableRecordsBefore } = await import('../core/table-system/cleaner.js'); + const count = await clearTableRecordsBefore(floorIndex); + toastr.success(`已成功清除 ${count} 条消息中的表格记录。`); + } catch (error) { + console.error('[内存储司] 清除记录失败:', error); + toastr.error('清除记录失败,请检查控制台日志。'); + } + } + }); + + clearBtn.dataset.clearEventBound = 'true'; + log('"清除记录"按钮已成功绑定。', 'success'); + } +} + function bindFloorFillButtons() { const selectedFloorsBtn = document.getElementById('fill-selected-floors-btn'); @@ -2098,14 +2195,15 @@ function bindChatTableDisplaySetting() { continuousRenderToggle.closest('.control-block-with-switch').style.opacity = '0.5'; } }; + updateContinuousRenderState(); + showInChatToggle.addEventListener('change', () => { settings.show_table_in_chat = showInChatToggle.checked; saveSettingsDebounced(); toastr.info(`聊天内表格显示已${showInChatToggle.checked ? '开启' : '关闭'}。`); updateContinuousRenderState(); }); - continuousRenderToggle.addEventListener('change', () => { settings.render_on_every_message = continuousRenderToggle.checked; saveSettingsDebounced();