From aa56a7ca022f94b3d7fa073d625191517639a1f2 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 23 Apr 2026 14:23:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=93=8D=E5=BA=94=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E7=AE=A1=E7=90=86=E8=A7=84=E5=88=99=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=8A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 删除页面中的规则测试区域,简化管理端交互。 2. 删除前端关联状态与方法,避免无用请求与冗余代码。 3. 删除后端/api/test_match接口,保持蓝图能力与页面一致。 --- .../dashboard/blueprints/fun_command_rules.py | 28 ---------- .../templates/fun_command_rules.html | 56 ------------------- 2 files changed, 84 deletions(-) diff --git a/admin/dashboard/blueprints/fun_command_rules.py b/admin/dashboard/blueprints/fun_command_rules.py index 5170884..081f3bb 100644 --- a/admin/dashboard/blueprints/fun_command_rules.py +++ b/admin/dashboard/blueprints/fun_command_rules.py @@ -235,31 +235,3 @@ def api_toggle_rule(rule_id: int): return jsonify({"success": False, "message": "切换失败"}), 500 return jsonify({"success": True, "message": "状态已更新"}) - - -@fun_command_rules_bp.route("/api/test_match", methods=["POST"]) -@login_required -def api_test_match(): - """提供后台测试入口,便于快速验证规则命中结果。""" - server = current_app.dashboard_server - service = server.fun_command_rule_service - - raw = request.get_json(silent=True) or {} - scope_type = str(raw.get("scope_type", "group") or "group").strip().lower() - scope_id = str(raw.get("scope_id", "") or "").strip() - content = str(raw.get("content", "") or "").strip() - event_key = str(raw.get("event_key", "") or "").strip().upper() - - session_key = scope_id or "test-session" - matched = service.match_rule( - scope_type=scope_type, - scope_id=scope_id, - content=content, - event_key=event_key, - session_key=session_key, - ) - - if not matched: - return jsonify({"success": True, "matched": False, "data": None}) - - return jsonify({"success": True, "matched": True, "data": matched}) diff --git a/admin/dashboard/templates/fun_command_rules.html b/admin/dashboard/templates/fun_command_rules.html index ae72521..9c1a0ef 100644 --- a/admin/dashboard/templates/fun_command_rules.html +++ b/admin/dashboard/templates/fun_command_rules.html @@ -80,39 +80,6 @@ - -
规则测试
- - - - - - - - - - - - - - - - - - - - - 测试命中 - - - - -
- @@ -288,13 +255,6 @@ new Vue({ dialogVisible: false, editing: false, editingRuleId: 0, - testResult: null, - tester: { - scope_type: 'group', - scope_id: '', - event_key: '', - content: '' - }, form: { rule_name: '', scope_type: 'global', @@ -613,22 +573,6 @@ new Vue({ this.$message.error(msg) } row.enabled = !enabled - }, - async testMatch() { - try { - const resp = await axios.post('/fun_command_rules/api/test_match', this.tester) - if (resp.data && resp.data.success) { - this.testResult = { - matched: !!resp.data.matched, - data: resp.data.data || null - } - return - } - this.$message.error((resp.data && resp.data.message) || '测试失败') - } catch (error) { - const msg = (error.response && error.response.data && error.response.data.message) || '测试失败' - this.$message.error(msg) - } } } })