diff --git a/.cursor/rules/Api-Module-Split.mdc b/.cursor/rules/Api-Module-Split.mdc new file mode 100644 index 0000000..745248d --- /dev/null +++ b/.cursor/rules/Api-Module-Split.mdc @@ -0,0 +1,37 @@ +--- +description: 接口迁移到 xk-api 后必须拆出独立模块文件,禁止再往 api.js 大文件里塞 +alwaysApply: true +--- + +# API 模块拆分规则(xk-api 迁移必读) + +`request/api/api.js`(约 600+ 行大杂烩)是历史遗留的 Yii 接口聚合文件。 +**任何迁移到 xk-api 的接口、以及所有新增的 xk-api 接口,一律不得写进 `api.js`**,必须提取/新建到 `request/api/` 下的独立业务模块文件。 + +## 必须做 + +1. **按业务域建独立文件**:`request/api/.js`,小驼峰命名(已有先例:`patient.js`、`order.js`、`register.js`、`product.js`、`medicalRecord.js`、`specialPrescription.js`) +2. **统一走 http 封装**:`import { post, get } from './http'`,第三参传 `3`(`HttpUrlMap[3] = '/xkApi'`),不要手拼 `/xkApi` 字符串到 `http()` 老封装上 +3. **文件头注释标明后端与取值方式**,每个函数注释标 HTTP 方法与路径,例如: + +```js +import { post, get } from './http' + +/** + * 就诊人相关接口统一走 xk-api(type=3) + * 取值:unwrapXkApi → code / result / message + */ +/** 就诊人列表 xk-api POST /patient/list */ +export async function getPatientListApi(params = {}) { + return await post('/patient/list', params, 3) +} +``` + +4. **迁移某接口时**(Yii → xk-api):把它从 `api.js` 挪到对应模块文件,`api.js` 里原函数直接删除(调用方改 import),确实来不及改完所有调用方时才允许在 `api.js` 保留一行 re-export 并标 `@deprecated` +5. 页面取值统一 `unwrapXkApi`(见 Api-Response.mdc) + +## 禁止做 + +- 禁止在 `api.js` 中新增任何函数(包括 Yii 接口——新 Yii 接口也应放模块文件) +- 禁止新代码再用 `normalizeXkApiResponse` 这类「把 xk-api 响应抹成 errcode/data」的兼容层;那是存量代码的过渡产物 +- 禁止一个模块文件里混装两个后端的接口而不加注释区分;同一文件确需并存时,每个函数注释必须标明 `// xk-api` 或 `// Yii` diff --git a/.cursor/rules/Code-Standards.mdc b/.cursor/rules/Code-Standards.mdc index 600712f..da73f8f 100644 --- a/.cursor/rules/Code-Standards.mdc +++ b/.cursor/rules/Code-Standards.mdc @@ -11,3 +11,5 @@ alwaysApply: true 6. 微信小程序 `.vue` 模板(会编译成 WXML)禁止使用 `??`、`?.` 等现代运算符,否则会报 `unexpected token '?'`;模板里用 `||` / 显式判断,脚本里可用 `??`/`?.` 7. 微信小程序模板里 `:class` / `:style` 禁止写 `fn(arg)` 方法调用(如 `:class="sexClass(p)"` 会编译失败);用对象/数组字面量(如 `:class="{ male: p.sex == 1 }"`),或把结果先算进 data/computed 再绑定 8. 接口取值:写代码时先确认接口是 xk-api 还是 Yii,再固定用 `code/result/message` 或 `errcode/data/msg`(可用 `unwrapXkApi` / `unwrapYiiApi`);禁止运行时猜测、禁止 `result || data`(详见 Api-Response.mdc) +9. 卡片强调样式:禁止用左侧竖色条(`border-left` 色条/左侧色块)做卡片强调或分类标识,统一用「1px 同色系边框 + 同色低透明度外发光(box-shadow 微光)」;历史页面暂不强制回改,新增/改动的卡片必须遵守 +10. API 模块拆分:迁移到 xk-api 的接口和所有新增接口必须放 `request/api/.js` 独立模块文件,禁止再往 `request/api/api.js` 大文件里新增(详见 Api-Module-Split.mdc) diff --git a/components/claim-patient-modal/claim-patient-modal.vue b/components/claim-patient-modal/claim-patient-modal.vue index 467aa83..077e97f 100644 --- a/components/claim-patient-modal/claim-patient-modal.vue +++ b/components/claim-patient-modal/claim-patient-modal.vue @@ -17,7 +17,7 @@