From db1bc728f65e3ef4c66b2e7fdab818cb5116c48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 11 Aug 2026 11:12:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(common):=20=E7=A7=BB=E9=99=A4=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E7=BB=84=E4=BB=B6=E4=B8=AD=E7=9A=84=20NutUI=20Button?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E7=94=A8=20Taro=20=E5=8E=9F=E7=94=9F=20Butto?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `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 --- .workbuddy/memory/2026-08-11.md | 20 ++++++++++++++++++++ .workbuddy/memory/MEMORY.md | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.workbuddy/memory/2026-08-11.md b/.workbuddy/memory/2026-08-11.md index 0395cce..15f192b 100644 --- a/.workbuddy/memory/2026-08-11.md +++ b/.workbuddy/memory/2026-08-11.md @@ -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,属长尾待办。 diff --git a/.workbuddy/memory/MEMORY.md b/.workbuddy/memory/MEMORY.md index a4f660e..fbbfd82 100644 --- a/.workbuddy/memory/MEMORY.md +++ b/.workbuddy/memory/MEMORY.md @@ -24,7 +24,13 @@ ## 官网分包 official(2026-08-11 落地) - 位置 `src/official/`(6 页:index/article/article-detail/about/message/mine)+ `src/official/components/`(OfficialTabBar/ArticleCard/SectionTitle),在 `src/app.config.ts` 的 `subpackages` 中 root=`official`。入口在 `src/pages/index/index.tsx` 搜索栏下的「企业官网」卡片。 -- 数据层统一从 `@/api/official` 引入(re-export `src/api/cms/*`)。**内容请求走默认 shop-api(`https://shop-api.websoft.top/api`),shop-api 已代理 `/cms` 前缀,不要另配 cms-api 域名**(避免小程序合法域名白名单成本)。租户靠 `TenantId` 请求头。 +- 数据层统一从 `@/api/official` 引入(re-export `src/api/cms/*`)。租户靠 `TenantId` 请求头。 +- **⚠️ CMS 请求链路(2026-08-11 修正,勿回退)**:CMS 接口**不能**走 shop-api——`shop-api.websoft.top/api/cms/...` 返回 **404**,shop-api 并未代理 `/cms`(早前"已代理"的判断是错的)。现全部走独立 `https://cms-api.websoft.top/api`: + - `config/env.js` 三环境均有 `CMS_API_BASE_URL`,`config/app.ts` 导出 `CmsBaseUrl`。 + - `src/utils/cmsRequest.ts` 基于 request 封装、默认 baseUrl=CmsBaseUrl,API 与 request 一致。 + - `src/api/cms/` 下 34 个 `index.ts` 一律 `import cmsRequest`;**新增 CMS 接口必须用 cmsRequest,不要用 request**。 + - 需在小程序后台把 `cms-api.websoft.top` 加入 request 合法域名白名单。 + - 批量替换技巧:macOS `sed` 对 `request\.(get|post)\(` 替换无效,改用 `perl -pi -e 's/request\.get/cmsRequest.get/g'`。 - CMS 字段陷阱:文章封面 `image`(非 cover)、摘要 `overview`(非 summary)、`ARTICLE_STATUS.PUBLISHED = 0`(0 才是已发布);留言内容字段是 `need`(非 content),小程序提交带 `source:'miniapp'`。 - 微信原生 tabBar **不支持分包页面**,官网底部导航是自实现的 `OfficialTabBar`(用 `redirectTo`)。 - 品牌色统一 token:tailwind `brand` 色阶(600=`#185FA5`)+ `app.scss` 的 `--brand-color/--brand-light`。富文本用 `.official-rich`(定义在 `app.scss`,px 自动转 rpx)。