refactor: remove redundant template import dialog, keep only quick-add dropdown

Quick-add dropdown already serves the same purpose with fewer clicks
This commit is contained in:
mediabot-pt
2026-07-06 22:45:16 +08:00
parent 110af4a79c
commit 36e05896e5

View File

@@ -35,7 +35,6 @@
<el-tag size="small" type="info">{{ parsed.length }} 条规则</el-tag> <el-tag size="small" type="info">{{ parsed.length }} 条规则</el-tag>
</div> </div>
<div style="display:flex;gap:8px"> <div style="display:flex;gap:8px">
<el-button size="small" @click="showPresets = true">从模板导入</el-button>
<el-button size="small" type="primary" @click="saveRules" :loading="saving">保存</el-button> <el-button size="small" type="primary" @click="saveRules" :loading="saving">保存</el-button>
<el-button size="small" @click="uploadRules" :loading="uploading">上传</el-button> <el-button size="small" @click="uploadRules" :loading="uploading">上传</el-button>
<el-button size="small" @click="editType=''">返回列表</el-button> <el-button size="small" @click="editType=''">返回列表</el-button>
@@ -189,33 +188,6 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 预设规则导入对话框 -->
<el-dialog v-model="showPresets" title="PT 站点管理规则模板" width="700px" :close-on-click-modal="false">
<div style="margin-bottom:12px;padding:10px 14px;background:#f0f9ff;border-radius:6px;font-size:13px;color:#606266">
<p style="margin:0 0 4px;font-weight:500">规则体系:等级豁免 → 账号存活 → 新人考核 → 流量监控 → H&R 惩罚 → 分享率</p>
<p style="margin:0;font-size:12px;color:#909399">满足豁免条件的用户不受任何规则影响。系统会自动根据风险百分比触发告警(riskPct &gt; 80%)。</p>
</div>
<div v-for="cat in presetCategories" :key="cat.title" style="margin-bottom:12px">
<div style="font-weight:600;font-size:13px;margin-bottom:6px;color:#303133">{{ cat.title }}</div>
<el-checkbox-group v-model="selectedPresets">
<div v-for="p in cat.items" :key="p.name"
style="padding:8px 12px;border:1px solid #ebeef5;border-radius:6px;margin-bottom:4px;display:flex;align-items:center;gap:8px"
:style="existsRule(p)?{background:'#f5f7fa',borderColor:'#e4e7ed'}:{}">
<el-checkbox :value="p.name" :label="p.name" :disabled="existsRule(p)" style="margin-right:0;height:auto">
<span :style="{fontWeight:500,fontSize:'13px',color:existsRule(p)?'#c0c4cc':''}">{{ p.name }}</span>
</el-checkbox>
<span :style="{fontSize:'11px',fontWeight:500,color:p.type==='EXEMPT'?'#67c23a':p.type==='RATIO'||p.type==='DRATIO'?'#e6a23c':'#f56c6c'}">{{ p.type==='EXEMPT' ? '保号' : p.type==='RATIO'||p.type==='DRATIO' ? '缓刑7天' : '封号' }}</span>
<span :style="{color:existsRule(p)?'#c0c4cc':'#909399',fontSize:'11px',flex:1}">{{ presetDesc(p) }}</span>
<span v-if="existsRule(p)" style="color:#c0c4cc;font-size:11px">(已添加)</span>
</div>
</el-checkbox-group>
</div>
<template #footer>
<el-button @click="showPresets = false">取消</el-button>
<el-button type="primary" @click="importPresets">导入选中 ({{ selectedPresets.length }})</el-button>
</template>
</el-dialog>
</div> </div>
</template> </template>
@@ -350,31 +322,10 @@ const presets = [
{ name:'等级豁免', type:'EXEMPT', permRank:'Elite User', sealExemptRank:'Power User', description:'达到等级的账号可豁免清理' }, { name:'等级豁免', type:'EXEMPT', permRank:'Elite User', sealExemptRank:'Power User', description:'达到等级的账号可豁免清理' },
] ]
const presetCategories = [
{ title:'四、账号存活策略', items: presets.filter(p => p.name.includes('不登录') || p.name.includes('账号清理')) },
{ title:'五、零活跃新用户清理', items: presets.filter(p => p.name.includes('零活跃')) },
{ title:'流量监控', items: presets.filter(p => p.type === 'TRAFFIC') },
{ title:'H&R 惩罚', items: presets.filter(p => p.type === 'HD') },
{ title:'新人考核', items: presets.filter(p => p.type === 'TASK') },
{ title:'分享率', items: presets.filter(p => p.type === 'DRATIO') },
{ title:'等级豁免', items: presets.filter(p => p.type === 'EXEMPT') },
]
const presetDesc = (p) => {
if (p.type === 'TASK') return `考核周期 ${p.threshold||30} 天,需满足上传/下载/魔力值/做种积分/做种时间要求`
if (p.type === 'DRATIO') return `下载量 ≥ ${p.threshold||100}GB 时分享率 ≥ ${p.minRatio||1.0}`
if (p.type === 'EXEMPT') return `永久保留 ≥ ${rankDisplay(p.permRank)} / 封存豁免 ≥ ${rankDisplay(p.sealExemptRank)}`
const condLabel = condOptions.find(c => c.value === p.condition)?.label || p.condition
const appLabel = applicableOptions.find(a => a.value === p.applicable)?.label || ''
return `${metricOptions.find(m=>m.value===p.metric)?.label||p.metric} ${condLabel} ${p.threshold}${p.unit||''}${appLabel?' ('+appLabel+')':''}`
}
// ============ 状态 ============ // ============ 状态 ============
const loading = ref(false), saving = ref(false), uploading = ref(false) const loading = ref(false), saving = ref(false), uploading = ref(false)
const sites = ref([]), rulesMap = ref({}) const sites = ref([]), rulesMap = ref({})
const editType = ref(''), editorJson = ref('[]') const editType = ref(''), editorJson = ref('[]')
const showPresets = ref(false)
const selectedPresets = ref([])
const dragIdx = ref(null) const dragIdx = ref(null)
const fmt = (t) => t ? (t.substring(0,19)||'').replace('T',' ') : '-' const fmt = (t) => t ? (t.substring(0,19)||'').replace('T',' ') : '-'
@@ -487,25 +438,6 @@ const addPreset = (p) => {
parsed.value = [...parsed.value, r] parsed.value = [...parsed.value, r]
} }
const importPresets = () => {
const items = presets.filter(p => selectedPresets.value.includes(p.name)).map(p => {
const r = { ...p, _fold: false }
ensureTaskReqs(r)
return r
})
const dupes = items.filter(r => existsRule(r))
if (dupes.length) {
ElMessage.warning(`跳过 ${dupes.length} 条重复规则`)
}
const newItems = items.filter(r => !existsRule(r))
if (newItems.length) {
parsed.value = [...parsed.value, ...newItems]
ElMessage.success(`已导入 ${newItems.length} 条规则`)
}
selectedPresets.value = []
showPresets.value = false
}
// 拖拽排序 // 拖拽排序
const onDragStart = (e, idx) => { dragIdx.value = idx; e.dataTransfer.effectAllowed = 'move' } const onDragStart = (e, idx) => { dragIdx.value = idx; e.dataTransfer.effectAllowed = 'move' }
const onDragOver = (e, idx) => { const onDragOver = (e, idx) => {