refactor: remove add-rule button, keep only quick-add dropdown
All rule patterns are covered by presets, no need for blank rule creation Also fix missing Refresh icon import
This commit is contained in:
@@ -54,7 +54,6 @@
|
|||||||
<!-- 右侧:卡片式可视化编辑 -->
|
<!-- 右侧:卡片式可视化编辑 -->
|
||||||
<div style="flex:1;overflow:auto;min-height:0">
|
<div style="flex:1;overflow:auto;min-height:0">
|
||||||
<div style="display:flex;gap:8px;align-items:center;margin-bottom:10px;flex-wrap:wrap">
|
<div style="display:flex;gap:8px;align-items:center;margin-bottom:10px;flex-wrap:wrap">
|
||||||
<el-button size="small" type="primary" @click="addRule"><el-icon style="margin-right:2px"><Plus /></el-icon>添加规则</el-button>
|
|
||||||
<el-dropdown @command="addPreset">
|
<el-dropdown @command="addPreset">
|
||||||
<el-button size="small">快速添加<el-icon style="margin-left:2px"><ArrowDown /></el-icon></el-button>
|
<el-button size="small">快速添加<el-icon style="margin-left:2px"><ArrowDown /></el-icon></el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
@@ -69,7 +68,7 @@
|
|||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</template>
|
</template>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<span v-if="!parsed.length" style="color:#909399;font-size:13px">— 暂无规则,点击添加或从模板导入</span>
|
<span v-if="!parsed.length" style="color:#909399;font-size:13px">— 暂无规则,请使用「快速添加」选择模板</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 规则卡片列表 -->
|
<!-- 规则卡片列表 -->
|
||||||
@@ -193,7 +192,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, computed, onMounted } from 'vue'
|
||||||
import { Plus, ArrowDown, ArrowUp, Rank, Delete } from '@element-plus/icons-vue'
|
import { ArrowDown, ArrowUp, Rank, Delete, Refresh } from '@element-plus/icons-vue'
|
||||||
import api from '../api'
|
import api from '../api'
|
||||||
|
|
||||||
// ============ 选项配置 ============
|
// ============ 选项配置 ============
|
||||||
@@ -400,17 +399,6 @@ const editRule = async (row) => {
|
|||||||
|
|
||||||
const sync = () => { editorJson.value = JSON.stringify(parsed.value, null, 2) }
|
const sync = () => { editorJson.value = JSON.stringify(parsed.value, null, 2) }
|
||||||
|
|
||||||
const addRule = () => {
|
|
||||||
const d = typeDefaults['KILL']
|
|
||||||
const r = { type:'KILL', metric:d.metric, threshold:0, unit:d.unit, condition:d.condition,
|
|
||||||
applicable:null, description:'', _fold:false }
|
|
||||||
if (existsRule(r)) {
|
|
||||||
ElMessage.warning('活跃度(无条件)规则已存在,同类型+适用条件只能添加一次')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
parsed.value = [...parsed.value, r]
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmRemove = async (idx) => {
|
const confirmRemove = async (idx) => {
|
||||||
try { await ElMessageBox.confirm('确定删除此规则?', '确认', { type:'warning', confirmButtonText:'删除' }) } catch { return }
|
try { await ElMessageBox.confirm('确定删除此规则?', '确认', { type:'warning', confirmButtonText:'删除' }) } catch { return }
|
||||||
const arr = [...parsed.value]; arr.splice(idx, 1); parsed.value = arr
|
const arr = [...parsed.value]; arr.splice(idx, 1); parsed.value = arr
|
||||||
|
|||||||
Reference in New Issue
Block a user