{ "patterns": { "pat-001": { "name": "Vite Dev Server与ClashX代理冲突", "source": "user_feedback", "confidence": 0.95, "applications": 5, "created": "2026-03-21", "category": "environment", "pattern": "Vite dev server在ClashX开启时挂起不响应", "problem": "Node.js HTTP服务器监听成功但curl请求挂起", "solution": "使用原生Node.js HTTP服务器dev-server.mjs替代Vite dev server;或关闭ClashX的增强模式", "quality_rules": [ "使用npm run dev:simple启动开发服务器", "代码修改后需npm run build重新构建", "dev-server.mjs会自动添加CORS头" ] }, "pat-002": { "name": "Axios响应数据嵌套结构", "source": "implementation_review", "confidence": 0.95, "applications": 1, "created": "2026-03-22", "category": "frontend", "pattern": "API响应是{code, message, data{...}}嵌套结构,直接访问res.data.token是undefined", "problem": "登录成功后token存储为undefined,导致isLoggedIn返回false", "solution": "使用res.data.data获取实际的登录数据", "quality_rules": [ "登录数据在res.data.data中,不是在res.data中", "访问嵌套数据前先console.log打印确认结构" ] }, "pat-003": { "name": "CORS配置端口限制", "source": "implementation_review", "confidence": 0.85, "applications": 2, "created": "2026-03-22", "category": "backend", "pattern": "后端CORS只允许特定端口导致跨域失败", "problem": "前端使用不同端口时API请求被CORS阻止", "solution": "CORS配置中添加所有可能的前端开发端口(5173-5180)", "quality_rules": [ "后端CorsConfiguration设置allowedOrigins包含所有开发端口", "前端request.ts的baseURL使用绝对路径http://localhost:8080/api" ] }, "pat-004": { "name": "Git提交纪律", "source": "user_feedback", "confidence": 0.95, "applications": 3, "created": "2026-03-22", "category": "workflow", "pattern": "代码修改后未提交到Git,npm install或操作导致工作目录恢复到旧状态", "problem": "昨天修复的问题今天又发生,因为修改从未commit", "solution": "每次修复完成后立即commit;建立开发流程规范", "quality_rules": [ "完成功能或修复后立即git commit", "git commit message要清晰描述修改内容", "在git commit之前不要进行npm install等可能重置环境的操作" ] }, "pat-005": { "name": "登录跳转使用window.location.href", "source": "implementation_review", "confidence": 0.90, "applications": 2, "created": "2026-03-22", "category": "frontend", "pattern": "SPA登录成功后router.push('/')不工作", "problem": "Pinia store更新和Vue Router跳转时序问题", "solution": "使用window.location.href = '/'强制页面重新加载", "quality_rules": [ "登录回调中使用window.location.href进行跳转", "登出时也使用window.location.href = '/login'" ] }, "pat-006": { "name": "dist构建产物未及时更新", "source": "user_feedback", "confidence": 0.80, "applications": 3, "created": "2026-03-22", "category": "workflow", "pattern": "修改代码后构建产物没有更新", "problem": "前端修改后没有重新npm run build", "solution": "建立标准流程:修改代码 → npm run build → 重启dev-server", "quality_rules": [ "每次测试前确认dist是最新的", "使用dev-server.mjs时每次修改都需要重新构建" ] } } }