优化: AI Chat全栈多批审查修复与架构清理(risk_level清理/路由解耦/工具渲染/测试补测/死代码)

This commit is contained in:
2026-06-18 22:57:19 +08:00
parent 0ca5d9805f
commit a2871a66e0
87 changed files with 5720 additions and 3012 deletions

View File

@@ -113,6 +113,7 @@ import { useProjectStore } from './stores/project'
import { useAppSettingsStore } from './stores/appSettings'
import i18n from './i18n'
import AiChat from './components/AiChat.vue'
import { aiApi } from '@/api'
const route = useRoute()
const isDetached = computed(() => route.path === '/ai-detached')
@@ -207,6 +208,20 @@ onMounted(async () => {
await migrateLegacyLocalStorage()
// 3. 缓存已就绪,初始化主题/locale
initTheme()
// F-260618-23: 根 onMounted 恢复 Agentic 轮次/重试到后端(AtomicUsize 纯内存,重启回默认)。
// GeneralPanel.vue onMounted 仅 Settings 页挂载,用户直接进 AI Chat 不同步 → 后端默认 10 与前端显示持久值不一致。
// clamp 与 GeneralPanel.syncAgentMaxIterations/syncAgentMaxRetries 逐字对齐(双保险,IPC 幂等值相同无害)
// 包 try/catch 防 IPC 失败 reject onMounted(对齐 dataChangedListener 模式)
try {
const iter = appSettings.get<number>('df-ai-agent-max-iterations', 10)
const iterClamped = Math.min(50, Math.max(1, iter || 10))
const retry = appSettings.get<number>('df-ai-agent-max-retries', 3)
const retryClamped = Math.min(10, Math.max(0, retry ?? 3))
await aiApi.setAgentMaxIterations(iterClamped)
await aiApi.setAgentMaxRetries(retryClamped)
} catch (e) {
console.error('恢复 Agentic 轮次/重试配置失败:', e)
}
const savedLang = appSettings.get<string | null>('df-language', null)
if (savedLang) {
i18n.global.locale.value = savedLang as 'zh-CN' | 'en'