Skip to content

运行约定(默认遵循):

  • 前端预览固定端口 5173:yarn run dev -- --port 5173 --strictPort --host
  • curl 快速返回状态(不读体):curl -sS -o /dev/null -w '%{http_code}\n' --max-time 6 --connect-timeout 3 <URL>

说明:除非你在当次对话中另有指示,我将复用已运行的前端服务(如 http://localhost:5173/),并在接口探测时使用上述 curl 模板避免请求挂起。

API 约定:

  • API 固定端口 8000:默认在本地使用 http://localhost:8000/ 提供接口服务。
  • 运行检测策略:若检测到 8000 端口正在被占用,则视为 API 已成功运行(无需重复启动)。
  • 探测示例:curl -sS -o /dev/null -w '%{http_code}\n' --max-time 6 --connect-timeout 3 http://localhost:8000/health || echo 'unreachable'
  • 执行curl探测是加入-sS -o /dev/null -w '%{http_code}\n' --max-time 6 --connect-timeout 3等参数防止因为curl没有返回状态导致的挂起

使用说明:

  • 在此工作区默认加载本文件约定:后续操作中我将优先遵循上述端口与探测策略,前端复用 5173、API 复用 8000;若你另有指示,则以你的指示为准。

包管理约定(使用 Yarn 替代 NPM):

  • 默认使用 yarn 执行依赖安装与脚本运行,避免混用 npm
  • 安装依赖:yarn install(优先读取并遵循 yarn.lock)。
  • 运行脚本:yarn run <script> 或直接 yarn <script>,例如:yarn devyarn buildyarn preview
  • 添加依赖:yarn add <pkg>;开发依赖:yarn add -D <pkg>;移除依赖:yarn remove <pkg>
  • 若同时存在 package-lock.jsonyarn.lock,默认以 yarn.lock 为准并避免同时修改两者。
  • 如你在当次对话中明确要求使用 npm,则以你的指示为准(临时覆盖本约定)。