From 4df5375b92001e3c06f1bdce4d5f0b60e61ca7a7 Mon Sep 17 00:00:00 2001 From: Zain Date: Wed, 25 Mar 2026 19:42:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E8=A7=84=E5=88=99=E6=A8=A1=E6=9D=BF=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/components/config-panel.ts | 58 ++++++++++++------- src/content/components/file-selector-panel.ts | 6 ++ src/locales/en.json | 5 +- src/locales/zh_CN.json | 5 +- src/locales/zh_TW.json | 5 +- tests/unit/config-panel-rule-presets.test.ts | 31 ++++++++++ .../file-selector-panel-rule-presets.test.ts | 28 +++++++++ 7 files changed, 114 insertions(+), 24 deletions(-) diff --git a/src/content/components/config-panel.ts b/src/content/components/config-panel.ts index e7b3cfb..a692ab0 100644 --- a/src/content/components/config-panel.ts +++ b/src/content/components/config-panel.ts @@ -11,6 +11,7 @@ import { type RulePresetRecord, } from '../../types/rule-preset'; import { I18nService } from '../../utils/i18n'; +import { buildRulePresetSummary, isRulePresetConfigValid } from '../../utils/rule-presets'; /** * Config Panel Component @@ -225,6 +226,10 @@ export class ConfigPanel extends LitElement { } private handleApplyPreset(record: RulePresetRecord): void { + if (!isRulePresetConfigValid(record.config)) { + return; + } + this.dispatchEvent( new CustomEvent('apply-rule-preset', { detail: { presetId: record.id, source: record.source }, @@ -818,16 +823,26 @@ export class ConfigPanel extends LitElement { private renderPresetItem(record: RulePresetRecord, deletable: boolean) { const summary = this.buildPresetSummary(record); + const isValid = isRulePresetConfigValid(record.config); return html` -
+
-
${record.name || summary}
+
+ ${record.name || summary} + ${isValid + ? '' + : html`${I18nService.t('rule_preset_invalid_badge')}`} +
${summary}
+ ${isValid + ? '' + : html`
${I18nService.t('rule_preset_invalid_hint')}
`}