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'
};
const DEFAULT_FILTER_RULES = [
{ start: '<think>', end: '</think>' },
{ start: '<thinking>', end: '</thinking>' },
];
const DEFAULT_FILTER_RULES = [
{ start: '<think>', end: '</think>' },
{ start: '<thinking>', end: '</thinking>' },
{ start: '```', end: '```' },
];
// ═══════════════════════════════════════════════════════════════════════════
// State
@@ -209,8 +210,11 @@
list.querySelectorAll('.btn-del-rule').forEach(btn => {
btn.onclick = () => {
btn.closest('.filter-rule-item')?.remove();
updateFilterRulesCount();
};
});
updateFilterRulesCount();
}
function collectFilterRules() {
@@ -244,8 +248,19 @@
</div>
<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);
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
const triggerEnabled = $('trigger-enabled');
const autoSummaryOptions = $('auto-summary-options');

View File

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