移除响应指令管理规则测试功能及接口
1. 删除页面中的规则测试区域,简化管理端交互。 2. 删除前端关联状态与方法,避免无用请求与冗余代码。 3. 删除后端/api/test_match接口,保持蓝图能力与页面一致。
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -80,39 +80,6 @@
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="hover" style="margin-top:14px;">
|
||||
<div slot="header"><strong>规则测试</strong></div>
|
||||
<el-form inline>
|
||||
<el-form-item label="作用域">
|
||||
<el-select v-model="tester.scope_type" style="width:120px">
|
||||
<el-option label="群聊" value="group"></el-option>
|
||||
<el-option label="私聊" value="private"></el-option>
|
||||
<el-option label="全局" value="global"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="作用域ID">
|
||||
<el-input v-model="tester.scope_id" placeholder="群ID/用户ID" style="width:220px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="事件">
|
||||
<el-select v-model="tester.event_key" clearable placeholder="无" style="width:140px">
|
||||
<el-option label="PAT(拍一拍)" value="PAT"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="内容">
|
||||
<el-input v-model="tester.content" placeholder="测试文案" style="width:260px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="testMatch">测试命中</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-alert
|
||||
v-if="testResult"
|
||||
:type="testResult.matched ? 'success' : 'info'"
|
||||
:title="testResult.matched ? ('命中规则:#' + testResult.data.id + ' ' + testResult.data.rule_name) : '未命中规则'"
|
||||
:closable="false">
|
||||
</el-alert>
|
||||
</el-card>
|
||||
|
||||
<el-dialog :title="editing ? '编辑规则' : '新增规则'" :visible.sync="dialogVisible" width="980px">
|
||||
<el-form label-width="110px">
|
||||
<el-form-item label="规则名称">
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user