Files
websopy-taro/.workbuddy/memory/2026-08-11.md
T
gxwebsoft db1bc728f6 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
2026-08-11 11:12:23 +08:00

35 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-08-11 工作日志
## CMS 模块接口迁移到 cms-api
- **问题**CMS 接口(/cms/cms-article, /cms/cms-ad 等)走 `shop-api.websoft.top/api/cms/...` 返回 404
- **方案**CMS 模块全部改用独立 baseURL `https://cms-api.websoft.top/api`
- **改动清单**
1. `config/env.js` — 三环境(dev/test/prod)新增 `CMS_API_BASE_URL: 'https://cms-api.websoft.top/api'`
2. `config/app.ts` — 新增导出 `CmsBaseUrl = CMS_API_BASE_URL`
3. 新建 `src/utils/cmsRequest.ts` — 基于 request 封装,默认 baseUrl 为 CmsBaseUrlAPI 完全一致
4. `src/api/cms/` 下全部 34 个 index.ts — `import request``import cmsRequest``request.get/post/put/del``cmsRequest.get/post/put/del`(共 261 处调用)
5. `src/api/cms/cmsDomain/index.ts` — 特殊处理:原用 `SERVER_API_URL + '/cms/...'` 拼全 URL,改为相对路径走 cmsRequest
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,属长尾待办。