This commit is contained in:
2025-09-15 21:17:57 +08:00
parent 524da0830a
commit 413ac308ac
9 changed files with 394 additions and 26 deletions
+102 -7
View File
@@ -1,13 +1,47 @@
<template>
<div class="settings-page">
<el-card class="box-card">
<div slot="header" class="card-header">
<span>系统信息</span>
</div>
<el-row :gutter="20" class="system-info">
<el-col :span="8">
<div class="info-item">
<div class="info-label">CPU 核心数</div>
<div class="info-value">{{ systemInfo.cpuCores }}</div>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<div class="info-label">内存大小</div>
<div class="info-value">{{ systemInfo.memoryGB.toFixed(1) }} GB</div>
</div>
</el-col>
<el-col :span="8">
<div class="info-item">
<div class="info-label">推荐 Worker</div>
<div class="info-value">
Go {{ systemInfo.recommendedGo }} / 人类 {{ systemInfo.recommendedNsfw }} / 二次元 {{ systemInfo.recommendedAnime }}
<el-button type="text" size="mini" @click="applyRecommended">一键应用</el-button>
</div>
</div>
</el-col>
</el-row>
</el-card>
<el-card class="box-card" style="margin-top: 20px">
<div slot="header" class="card-header">
<span>色情检测配置</span>
</div>
<el-form :model="form" label-width="120px" class="settings-form">
<el-form :model="form" label-width="140px" class="settings-form">
<el-form-item label="Go 端 Worker 数">
<el-input-number v-model="form.goWorkers" :min="0" :max="64"></el-input-number>
<div class="form-tip">探测/MIME/移动的并发数,0 表示使用文件配置(当前推荐 {{ systemInfo.recommendedGo }})</div>
</el-form-item>
<el-form-item label="检测类型">
<el-radio-group v-model="form.type" @change="handleTypeChange">
<el-radio-group v-model="form.type">
<el-radio label="">关闭</el-radio>
<el-radio label="human">人类 (NudeNet)</el-radio>
<el-radio label="anime">二次元 (WD Tagger)</el-radio>
@@ -24,11 +58,21 @@
<div class="form-tip">分数高于此值判定为色情(推荐 0.2-0.4)</div>
</el-form-item>
<el-form-item v-if="form.type === 'human'" label="推理 Worker 数">
<el-input-number v-model="form.humanWorkers" :min="1" :max="32"></el-input-number>
<div class="form-tip">并行推理的 worker 数量,越大越快但占用更多内存(每个 worker 约 300MB)</div>
</el-form-item>
<el-form-item v-if="form.type === 'anime'" label="检测阈值">
<el-slider v-model="form.animeThreshold" :min="0.1" :max="0.9" :step="0.05" show-input></el-slider>
<div class="form-tip">explicit/questionable 分数高于此值判定为色情(推荐 0.5-0.7)</div>
</el-form-item>
<el-form-item v-if="form.type === 'anime'" label="推理 Worker 数">
<el-input-number v-model="form.animeWorkers" :min="1" :max="32"></el-input-number>
<div class="form-tip">并行推理的 worker 数量,越大越快但占用更多内存(每个 worker 约 1.5GB)</div>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveConfig" :loading="saving">保存配置</el-button>
</el-form-item>
@@ -47,13 +91,24 @@ export default {
form: {
type: '',
humanThreshold: 0.5,
animeThreshold: 0.5
animeThreshold: 0.5,
humanWorkers: 4,
animeWorkers: 2,
goWorkers: 0
},
systemInfo: {
cpuCores: 0,
memoryGB: 0,
recommendedGo: 0,
recommendedNsfw: 4,
recommendedAnime: 2
},
saving: false
}
},
created() {
this.loadConfig()
this.loadSystemInfo()
},
methods: {
async loadConfig() {
@@ -63,13 +118,29 @@ export default {
this.form.type = res.data.type || ''
this.form.humanThreshold = res.data.humanThreshold || 0.5
this.form.animeThreshold = res.data.animeThreshold || 0.5
this.form.humanWorkers = res.data.humanWorkers || 4
this.form.animeWorkers = res.data.animeWorkers || 2
this.form.goWorkers = res.data.goWorkers || 0
}
} catch (error) {
this.$message.error('加载配置失败')
}
},
handleTypeChange() {
// 切换类型时不需要特殊处理
async loadSystemInfo() {
try {
const res = await request.get('/api/config/system')
if (res.data) {
this.systemInfo = res.data
}
} catch (error) {
// 忽略
}
},
applyRecommended() {
this.form.goWorkers = this.systemInfo.recommendedGo
this.form.humanWorkers = this.systemInfo.recommendedNsfw
this.form.animeWorkers = this.systemInfo.recommendedAnime
this.$message.success('已应用推荐值,请点击保存配置')
},
async saveConfig() {
this.saving = true
@@ -77,7 +148,10 @@ export default {
await request.put('/api/config/nsfw', {
type: this.form.type,
humanThreshold: this.form.humanThreshold,
animeThreshold: this.form.animeThreshold
animeThreshold: this.form.animeThreshold,
humanWorkers: this.form.humanWorkers,
animeWorkers: this.form.animeWorkers,
goWorkers: this.form.goWorkers
})
this.$message.success('配置已保存,下次扫描生效')
} catch (error) {
@@ -100,6 +174,27 @@ export default {
font-weight: 600;
}
.system-info {
margin-top: 10px;
}
.info-item {
text-align: center;
padding: 10px 0;
}
.info-label {
font-size: 13px;
color: #909399;
margin-bottom: 8px;
}
.info-value {
font-size: 20px;
font-weight: 600;
color: #1f3a6b;
}
.settings-form {
margin-top: 20px;
}