fix: 修复代码审查全部18项问题,重构导出与匹配引擎
A级(严重): - ExportResults 支持 CSV 格式导出和 IncludeHeader 配置,使用实际表头名 - RunMatchWithAI 消除重复文件读取,提取 runMatchOnData() 内部函数 - AI 缓存文件权限收紧至 0600 B级(中等): - 移除废弃代码约400行 (MonthlyReport/DailyReport/StartMatching/DeepseekEnhanceMatching) - 替换自定义 parseCSVLine 为标准 encoding/csv - GetAICacheInfo 返回命名结构体 AICacheInfo - 时间差排序改为数值比较 - App.vue 提取 buildMatchConfig() 工厂函数消除配置重复 - AllMatches=false 时命中 1.0 相似度可提前结束 B 表循环 C级(轻微): - 魔法数字提取为命名常量 - main.go 替换 println 为 log.Fatalf - 清理未使用变量 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -126,7 +126,16 @@ async function startMatching() {
|
||||
progress.value = { current: 0, total: 100, message: '准备中...', phase: 'reading' }
|
||||
|
||||
try {
|
||||
const config = {
|
||||
const data = await RunMatch(buildMatchConfig())
|
||||
results.value = data; stats.value.matched = data.length
|
||||
} catch (err) { errorMsg.value = typeof err === 'string' ? err : (err.message || '匹配失败')
|
||||
hideProgressNow()
|
||||
} finally { loading.value = false; if (!errorMsg.value) scheduleProgressDone() }
|
||||
}
|
||||
|
||||
// buildMatchConfig 从响应式状态构建 MatchConfig 对象(消除重复)
|
||||
function buildMatchConfig() {
|
||||
return {
|
||||
fileAPath: fileAPath.value, fileBPath: fileBPath.value,
|
||||
colAMatchIndex: colAMatchIdx.value, colATimeIndex: colATimeIdx.value,
|
||||
colBMatchIndex: colBMatchIdx.value, colBTimeIndex: colBTimeIdx.value,
|
||||
@@ -141,11 +150,6 @@ async function startMatching() {
|
||||
exportFormat: matchConfig.value.exportFormat || 'xlsx',
|
||||
includeHeader: matchConfig.value.includeHeader !== false
|
||||
}
|
||||
const data = await RunMatch(config)
|
||||
results.value = data; stats.value.matched = data.length
|
||||
} catch (err) { errorMsg.value = typeof err === 'string' ? err : (err.message || '匹配失败')
|
||||
hideProgressNow()
|
||||
} finally { loading.value = false; if (!errorMsg.value) scheduleProgressDone() }
|
||||
}
|
||||
|
||||
// ----------- Deepseek AI 增强匹配 -----------
|
||||
@@ -179,22 +183,7 @@ async function startAIEnhance() {
|
||||
progress.value = { current: 0, total: 100, message: '正在启动 AI 增强匹配...', phase: 'reading' }
|
||||
|
||||
try {
|
||||
const config = {
|
||||
fileAPath: fileAPath.value, fileBPath: fileBPath.value,
|
||||
colAMatchIndex: colAMatchIdx.value, colATimeIndex: colATimeIdx.value,
|
||||
colBMatchIndex: colBMatchIdx.value, colBTimeIndex: colBTimeIdx.value,
|
||||
colBExtractIndex: colBExtractIdx.value,
|
||||
regexPattern: matchConfig.value.regexPattern || '',
|
||||
timeWindow: Number(matchConfig.value.timeWindow) || 12,
|
||||
threshold: Number(matchConfig.value.threshold) || 0.65,
|
||||
allMatches: matchConfig.value.allMatches || false,
|
||||
caseSensitive: matchConfig.value.caseSensitive || false,
|
||||
sortBy: matchConfig.value.sortBy || '',
|
||||
maxPreview: Number(matchConfig.value.maxPreview) || 0,
|
||||
exportFormat: matchConfig.value.exportFormat || 'xlsx',
|
||||
includeHeader: matchConfig.value.includeHeader !== false
|
||||
}
|
||||
const data = await RunMatchWithAI(config)
|
||||
const data = await RunMatchWithAI(buildMatchConfig())
|
||||
results.value = data
|
||||
stats.value.matched = data.length
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user