{
  "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": "user_feedback",
      "confidence": 0.95,
      "applications": 5,
      "created": "2026-03-22",
      "category": "frontend",
      "pattern": "后端API响应统一格式为{code,message,data{}}，前端直接访问res.data导致数据为undefined",
      "problem": "登录、用户、角色、权限等页面fetch数据时，res.data是ApiResponse而非实际数据",
      "solution": "使用res.data.data获取实际的列表/用户数据",
      "quality_rules": [
        "所有API调用后赋值给ref时使用 res.data.data",
        "示例: users.value = res.data.data || []",
        "不仅是登录API，所有列表查询API都有相同的嵌套结构"
      ]
    },
    "pat-003": {
      "name": "API路径双重/api前缀问题",
      "source": "implementation_review",
      "confidence": 0.95,
      "applications": 2,
      "created": "2026-03-22",
      "category": "frontend",
      "pattern": "baseURL和API路径都包含/api，导致请求变成/api/api/xxx",
      "problem": "后端收到/api/api/permissions请求，返回NoResourceFoundException",
      "solution": "baseURL设置为http://localhost:8080（不含/api），API路径使用/api/permissions",
      "quality_rules": [
        "baseURL: http://localhost:8080",
        "API路径: /api/permissions, /api/users 等",
        "不要在baseURL和API路径中同时包含/api"
      ]
    },
    "pat-003-A": {
      "name": "修改baseURL后API路径未同步更新",
      "source": "implementation_review",
      "confidence": 1.0,
      "applications": 1,
      "created": "2026-03-23",
      "category": "frontend",
      "pattern": "修改baseURL后，所有API文件的路径未同步更新，导致路径不一致",
      "problem": "fa344f9c修改baseURL从http://localhost:8080/api到http://localhost:8080，但auth.ts等文件的/api/auth/login未改为/auth/login，或反之",
      "root_cause": "修改baseURL时没有同步检查和更新所有API文件的路径",
      "solution": "修改baseURL后必须同步更新所有API文件的路径，保持一致性",
      "quality_rules": [
        "baseURL和API路径必须配套：baseURL=http://localhost:8080时，API路径=/api/xxx",
        "修改baseURL时用 grep -r '/api/' src/api/ 检查所有文件",
        "建议在ESLint或构建脚本中增加路径一致性检查"
      ]
    },
    "pat-004": {
      "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包含所有开发端口"
      ]
    },
    "pat-005": {
      "name": "Git提交纪律",
      "source": "user_feedback",
      "confidence": 0.95,
      "applications": 5,
      "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-006": {
      "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-007": {
      "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时每次修改都需要重新构建"
      ]
    }
  }
}
