Collapse filter rules and add code block filter

This commit is contained in:
2026-02-10 16:04:21 +08:00
parent 3650e0eda8
commit fbf34815bb
2 changed files with 55 additions and 19 deletions

View File

@@ -73,10 +73,11 @@
'陌生': 'trend-stranger', '投缘': 'trend-click', '亲密': 'trend-close', '交融': 'trend-merge' '陌生': 'trend-stranger', '投缘': 'trend-click', '亲密': 'trend-close', '交融': 'trend-merge'
}; };
const DEFAULT_FILTER_RULES = [ const DEFAULT_FILTER_RULES = [
{ start: '<think>', end: '</think>' }, { start: '<think>', end: '</think>' },
{ start: '<thinking>', end: '</thinking>' }, { start: '<thinking>', end: '</thinking>' },
]; { start: '```', end: '```' },
];
// ═══════════════════════════════════════════════════════════════════════════ // ═══════════════════════════════════════════════════════════════════════════
// State // State
@@ -209,8 +210,11 @@
list.querySelectorAll('.btn-del-rule').forEach(btn => { list.querySelectorAll('.btn-del-rule').forEach(btn => {
btn.onclick = () => { btn.onclick = () => {
btn.closest('.filter-rule-item')?.remove(); btn.closest('.filter-rule-item')?.remove();
updateFilterRulesCount();
}; };
}); });
updateFilterRulesCount();
} }
function collectFilterRules() { function collectFilterRules() {
@@ -244,8 +248,19 @@
</div> </div>
<button class="btn-del-rule">✕</button> <button class="btn-del-rule">✕</button>
`); `);
div.querySelector('.btn-del-rule').onclick = () => div.remove(); div.querySelector('.btn-del-rule').onclick = () => {
div.remove();
updateFilterRulesCount();
};
list.appendChild(div); list.appendChild(div);
updateFilterRulesCount();
}
function updateFilterRulesCount() {
const el = $('filter-rules-count');
if (!el) return;
const count = $('filter-rules-list')?.querySelectorAll('.filter-rule-item')?.length || 0;
el.textContent = count;
} }
@@ -1565,6 +1580,17 @@
}; };
} }
// Filter rules collapsible
const filterRulesToggle = $('filter-rules-toggle');
const filterRulesContent = $('filter-rules-content');
if (filterRulesToggle && filterRulesContent) {
filterRulesToggle.onclick = () => {
const collapse = filterRulesToggle.closest('.settings-collapse');
collapse.classList.toggle('open');
filterRulesContent.classList.toggle('hidden');
};
}
// Auto summary sub-options toggle // Auto summary sub-options toggle
const triggerEnabled = $('trigger-enabled'); const triggerEnabled = $('trigger-enabled');
const autoSummaryOptions = $('auto-summary-options'); const autoSummaryOptions = $('auto-summary-options');

View File

@@ -384,20 +384,30 @@
</div> </div>
<!-- 文本过滤规则 --> <!-- 文本过滤规则 -->
<div class="filter-rules-section"> <div class="settings-collapse" id="filter-rules-collapse">
<div class="filter-rules-header"> <div class="settings-collapse-header" id="filter-rules-toggle">
<label>文本过滤规则</label> <span>文本过滤规则 · <strong id="filter-rules-count">0</strong></span>
<button class="btn btn-sm btn-add" id="btn-add-filter-rule"> <svg class="collapse-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor"
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke-width="2">
stroke="currentColor" stroke-width="2"> <polyline points="6 9 12 15 18 9"></polyline>
<line x1="12" y1="5" x2="12" y2="19"></line> </svg>
<line x1="5" y1="12" x2="19" y2="12"></line> </div>
</svg> <div class="settings-collapse-content hidden" id="filter-rules-content">
添加 <div class="filter-rules-section" style="margin-top:0">
</button> <div class="filter-rules-header">
<p class="settings-hint" style="margin:0">过滤干扰内容(如思考标签)</p>
<button class="btn btn-sm btn-add" id="btn-add-filter-rule">
<svg viewBox="0 0 24 24" width="14" height="14" fill="none"
stroke="currentColor" stroke-width="2">
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
添加
</button>
</div>
<div id="filter-rules-list" class="filter-rules-list"></div>
</div>
</div> </div>
<p class="settings-hint">过滤干扰内容(如思考标签)</p>
<div id="filter-rules-list" class="filter-rules-list"></div>
</div> </div>
<!-- ═══════════════════════════════════════════════════════════ --> <!-- ═══════════════════════════════════════════════════════════ -->
@@ -790,4 +800,4 @@
<script src="story-summary-ui.js"></script> <script src="story-summary-ui.js"></script>
</body> </body>
</html> </html>