refactor(common): 移除公共组件中的 NutUI Button,改用 Taro 原生 Button

- `EmptyState` 和 `FixedButton` 两个组件全部替换 NutUI Button 为 Taro 原生 Button
- 解决空状态按钮在微信小程序端不可见的问题,确保按钮正常显示
- `FixedButton` 组件虽然未被调用,仍保留但调整实现,icon 由 prop 改为 children 渲染
- 统一主色使用 tailwind 的 `bg-red-500`,弃用原 NutUI primary 颜色
- 全局修复微信小程序原生 button 的 `::after` 灰色描边问题,在全局样式中设置 `button::after { border: none; }`
- NutUI Button 的引用文件数由 27 减至 25,`src/components/common/` 完全无 NutUI 依赖
- CMS 请求链路调整,所有 CMS 接口改用独立 `cmsRequest` 实现,确保请求正确
- 修正 `src/api/official` 的数据层,取消错误的 shop
This commit is contained in:
2026-08-11 11:12:23 +08:00
parent 6dd4ca9785
commit db1bc728f6
2 changed files with 27 additions and 1 deletions
+20
View File
@@ -12,3 +12,23 @@
6. `src/api/layout/index.ts``getServerTime()``getNext7day()` 两个 CMS 接口改用 cmsRequest
7. `src/api/official/index.ts` — 更新注释说明
- **注意**macOS sed 对 `request\.(get|post)\(` 模式替换无效(原因不明),最终用 `perl -pi -e 's/request\.get/cmsRequest.get/g'` 成功批量替换
## 公共组件去 NutUI 空壳化(高杠杆修复)
**背景**:排查 NutUI 空壳化残留时发现 `src/components/common/` 下两个公共组件内部引用 NutUI `Button`,属于最高杠杆修复点。
- **`EmptyState/index.tsx`**:被 53 个文件 import,其中 **3 个页面 4 处真正传了 `actionText`** —— 这些空状态按钮在 weapp 里此前完全不可见:
- `pages/shop/cart.tsx`:「去逛逛」「去登录后查看购物车」(空购物车唯一出口,之前是死路)
- `pages/user/address-list.tsx`:「添加地址」
- `pages/user/coupon-list.tsx`:动态 action
- 改法:`@nutui` Button → `@tarojs/components` Button`size='mini'` + `bg-red-500 text-white rounded-full border-0`,用 style 强制 padding/lineHeight。
- **`FixedButton/index.tsx`**:同样改为 Taro 原生 Button`icon` prop 由原生不支持改为渲染成 children。**注意:该组件全项目 0 处调用,是死代码**,保留但可考虑清理。
- **主色选择**NutUI 默认 primary 是红色系(`--nutui-brand-*`),项目 `bg-red-500` 用了 32 次是事实主色,故统一用 red-500,不用 tailwind 里那套没人用的 `primary``bg-primary-*` 全项目 0 引用)。
### 附带修复:小程序 button::after 描边
- 发现项目从未处理微信原生 `button` 自带的 `::after` 灰色描边伪元素,**tailwind `border-0` 覆盖不到伪元素**,导致所有 Taro 原生 Button 多一圈边框(包括 7-23 修的 `passport/pay`)。
-`src/app.scss` 加全局 `button::after { border: none; }`,已验证打进 `app-origin.wxss`。NutUI Button 编译产物不是 button 标签,不受影响。
### 状态
- 构建通过:`✔ Compiled successfully in 21.13s`
- NutUI 引用文件 27 → **25**`src/components/common/` 已完全无 NutUI。
- 剩余 25 个页面级散引用(Button 19 / Card 2 / Cell 1 / Divider 1),集中在 order、passport、booking,属长尾待办。