fix: 代码格式优化和临时文件清理

- 优化多个模板文件的代码格式

- 清理 tmp 目录中的临时备份文件

- 统一代码风格,符合项目规范
This commit is contained in:
User
2026-03-13 18:53:06 +08:00
parent 6ba6397ead
commit 7dbf574338
10 changed files with 715 additions and 37 deletions

View File

@@ -2534,6 +2534,99 @@ function themeoptions_page(){
</td>
</tr>
<tr>
<th><label><?php _e('提示词遗传算法 (PGA)', 'argon');?></label></th>
<td>
<?php $argon_ai_audit_genetic_prompt_enable = get_option('argon_ai_audit_genetic_prompt_enable', 'false'); ?>
<label>
<input type="checkbox" name="argon_ai_audit_genetic_prompt_enable" value="true" <?php if ($argon_ai_audit_genetic_prompt_enable=='true'){echo 'checked';}?>/>
<?php _e('启用 AI 审核提示词遗传算法', 'argon');?>
</label>
<p class="description">
<?php _e('开启后,系统会维护一个 Prompt 基因池。根据管理员的审核反馈(对/错),自动优胜劣汰,动态调整 Prompt 以达到最佳审核效果。', 'argon');?>
</p>
<?php if ($argon_ai_audit_genetic_prompt_enable == 'true'): ?>
<div class="argon-genetic-pool-status" style="margin-top: 10px; padding: 10px; background: #f8f9fe; border: 1px solid #e9ecef; border-radius: 4px;">
<strong><?php _e('当前基因池状态', 'argon'); ?>:</strong>
<ul style="margin: 5px 0 0 15px; font-size: 12px; color: #666;">
<?php
$pool = get_option('argon_ai_audit_prompt_pool', []);
if (!empty($pool)):
foreach ($pool as $mode => $data):
$count = count($data['population']);
$best = $data['population'][$data['current_best_index']];
?>
<li>
<code><?php echo esc_html($mode); ?></code>:
<?php printf(__('共 %d 个变体,当前最佳版本 v%d (适应度: %d)', 'argon'), $count, $best['version'], $best['fitness']); ?>
</li>
<?php
endforeach;
else:
?>
<li><?php _e('暂未积累基因数据', 'argon'); ?></li>
<?php endif; ?>
</ul>
<button type="button" class="button button-small" id="argon-reset-prompt-pool" style="margin-top: 10px;">
<?php _e('重置基因池', 'argon'); ?>
</button>
</div>
<?php endif; ?>
</td>
</tr>
<tr>
<th><label><?php _e('关键词遗传修正 (KGC)', 'argon');?></label></th>
<td>
<?php $argon_ai_audit_genetic_keyword_correction_enable = get_option('argon_ai_audit_genetic_keyword_correction_enable', 'false'); ?>
<label>
<input type="checkbox" name="argon_ai_audit_genetic_keyword_correction_enable" value="true" <?php if ($argon_ai_audit_genetic_keyword_correction_enable=='true'){echo 'checked';}?>/>
<?php _e('启用关键词缓存遗传修正', 'argon');?>
</label>
<p class="description">
<?php _e('开启后,系统会定期对学习到的关键词进行“进化”处理:自动衰减过期特征、淘汰低效词汇、修正误伤特征,使本地垃圾词库保持精简高效。', 'argon');?>
</p>
</td>
</tr>
<tr>
<th><label><?php _e('遗传变异率', 'argon');?></label></th>
<td>
<input type="number" name="argon_ai_audit_genetic_keyword_mutation_rate" min="1" max="50" value="<?php echo get_option('argon_ai_audit_genetic_keyword_mutation_rate', '5'); ?>" style="width: 80px;"/> %
<p class="description">
<?php _e('新 Prompt 变异产生的概率和关键词修正的幅度。建议维持在 5% 左右。', 'argon');?>
</p>
</td>
</tr>
<tr>
<th><label><?php _e('关键词缓存状态', 'argon');?></label></th>
<td>
<?php
$learned_keywords = get_option('argon_comment_spam_learned_keywords', []);
$high_confidence_count = 0;
if (!empty($learned_keywords)) {
foreach ($learned_keywords as $k => $v) {
if (isset($v['confidence']) && $v['confidence'] > 0.9 && isset($v['spam_count']) && $v['spam_count'] >= 3) {
$high_confidence_count++;
}
}
}
?>
<div class="argon-keyword-cache-status" style="padding: 10px; background: #f8f9fe; border: 1px solid #e9ecef; border-radius: 4px;">
<p style="margin: 0; font-size: 13px;">
<?php printf(__('当前本地特征库包含 %d 个关键词,其中 %d 个已进入高置信度快速路径(可直接拦截以节省 AI 费用)。', 'argon'), count($learned_keywords), $high_confidence_count); ?>
</p>
<button type="button" class="button button-small" id="argon-clear-learned-keywords" style="margin-top: 10px;">
<?php _e('清空学习缓存', 'argon'); ?>
</button>
</div>
<p class="description">
<?php _e('系统会自动从 AI 审计结果中提取共性特征并进行交叉训练和遗传修正。命中高置信度特征的评论将不再调用 AI直接本地返回。', 'argon');?>
</p>
</td>
</tr>
<tr>
<th><label><?php _e('全站扫描', 'argon');?></label></th>
<td>
@@ -3035,6 +3128,48 @@ function themeoptions_page(){
$('#argon-spam-scan-pending').on('click', function() {
startSpamScan('pending');
});
// 重置基因池
$(document).on('click', '#argon-reset-prompt-pool', function() {
if (!confirm('<?php _e('确定要重置所有 Prompt 基因池吗?这将删除所有已学习的变体。', 'argon'); ?>')) {
return;
}
let $btn = $(this);
$btn.prop('disabled', true).text('<?php _e('正在重置...', 'argon'); ?>');
$.post(ajaxurl, {
action: 'argon_reset_prompt_pool',
nonce: '<?php echo wp_create_nonce('argon_manage_unified_apis'); ?>'
}, function(response) {
if (response.success) {
alert(response.data.message);
location.reload();
} else {
alert(response.data);
$btn.prop('disabled', false).text('<?php _e('重置基因池', 'argon'); ?>');
}
});
});
// 清空学习缓存
$(document).on('click', '#argon-clear-learned-keywords', function() {
if (!confirm('<?php _e('确定要清空所有已学习的关键词缓存吗?这将导致系统需要重新通过 AI 学习特征。', 'argon'); ?>')) {
return;
}
let $btn = $(this);
$btn.prop('disabled', true).text('<?php _e('正在清空...', 'argon'); ?>');
$.post(ajaxurl, {
action: 'argon_clear_learned_keywords',
nonce: '<?php echo wp_create_nonce('argon_manage_unified_apis'); ?>'
}, function(response) {
if (response.success) {
alert(response.data.message);
location.reload();
} else {
alert(response.data);
$btn.prop('disabled', false).text('<?php _e('清空学习缓存', 'argon'); ?>');
}
});
});
});
</script>