Approved
作为 mini小程序开发者, 我希望 将yongren模块的页面拆分为独立的UI包, 以便 提高代码的模块化程度,便于独立测试和部署,提升项目的可维护性。
mini-ui-packages/yongren-dashboard-ui:仪表板页面包mini-ui-packages/yongren-order-management-ui:订单管理相关页面包mini-ui-packages/yongren-talent-management-ui:人才管理相关页面包mini-ui-packages/yongren-settings-ui:设置页面包mini-ui-packages/yongren-statistics-ui:统计页面包mini-ui-packages/mini-enterprise-auth-ui:企业认证UI包(将包含企业登录页和profile页面)mini-ui-packages/yongren-shared-ui:用人模块共享UI组件包mini-shared-ui-components包,为Taro组件提供了共享UI组件包 [来源:docs/stories/014.001.mini-shared-ui-components.md]mini-shared-ui-components/testing导出中 [来源:docs/stories/014.001.mini-shared-ui-components.md#任务3]在迁移yongren模块页面时,发现所有页面都依赖相同的认证hooks(useAuth和useRequireAuth)。为保持代码复用性和一致性,需要创建专门的mini-enterprise-auth-ui包来提供这些共享的认证功能:
@d8d/mini-enterprise-auth-uiuseAuth(): 提供当前用户信息、登录、登出、注册功能useRequireAuth(): 路由保护hook,未登录用户重定向到登录页@d8d/mini-shared-ui-components的RPC客户端工具和@d8d/server的路由类型UI页面包不需要特定的数据模型。[来源:docs/architecture/data-model-schema-changes.md#现有数据模型状态]
UI页面包需要包含API客户端,用于RPC类型推断,遵循与后台管理UI包相同的模式:
packages/advertisement-management-ui/src/api/advertisementClient.ts的模式@d8d/mini-shared-ui-components导入createRpcClient工具@d8d/allin-company-module导入companyEnterpriseRoutes,从@d8d/allin-disability-module导入personExtensionRoutes,从@d8d/core-module/auth-module导入enterpriseAuthRoutes),使用typeof获取类型。注意:与之前从@d8d/server统一导入路由类型不同,现在改为从各自的后端模块包中导入对应的路由对象,这样更加清晰和便于维护。mini/src/pages/yongren/ 目录下 [来源:docs/architecture/source-tree.md#实际项目结构]标准目录结构:
mini-ui-packages/<package-name>/
├── package.json # 包配置
├── tsconfig.json # TypeScript配置
├── src/
│ ├── index.ts # 主入口文件
│ ├── components/ # React组件
│ │ ├── <ComponentName>.tsx # 组件实现
│ │ ├── <ComponentName>.test.tsx # 组件测试
│ │ └── index.ts # 组件导出
│ ├── api/ # API客户端(必需)
│ │ ├── <module>Client.ts # RPC客户端管理器
│ │ └── index.ts # API导出
│ ├── types/ # TypeScript类型定义
│ │ ├── index.ts # 类型导出
│ │ └── <type>.ts # 具体类型定义
│ └── utils/ # 工具函数
│ └── index.ts # 工具导出
├── tests/ # 测试文件
│ └── integration/ # 集成测试
└── README.md # 包文档
注意:页面包通常不需要自定义hooks目录,因为现有的页面组件直接在组件内部使用React Query,没有抽取到独立的hooks中。
API客户端实现要求:
packages/advertisement-management-ui/src/api/advertisementClient.ts)@d8d/mini-shared-ui-components导入RPC客户端工具(createRpcClient)@d8d/allin-company-module导入companyEnterpriseRoutes,从@d8d/allin-disability-module导入personExtensionRoutes,从@d8d/core-module/auth-module导入enterpriseAuthRoutes),使用typeof获取类型。注意:与之前从@d8d/server统一导入路由类型不同,现在改为从各自的后端模块包中导入对应的路由对象,这样更加清晰和便于维护。package.json配置参考:
mini-ui-packages/mini-shared-ui-components/package.json 的Taro兼容配置@d8d/mini-shared-ui-components 作为共享UI组件基础包导出规范(细粒度路径导出):
packages/shared-ui-components/package.json 的细粒度路径导出配置exports字段中为每个UI组件提供独立的导出路径示例配置:
"exports": {
".": {
"types": "./src/index.ts",
"import": "./src/index.ts",
"require": "./src/index.ts"
},
"./components/button": {
"types": "./src/components/button.tsx",
"import": "./src/components/button.tsx",
"require": "./src/components/button.tsx"
},
"./components/card": {
"types": "./src/components/card.tsx",
"import": "./src/components/card.tsx",
"require": "./src/components/card.tsx"
},
"./components/dialog": {
"types": "./src/components/dialog.tsx",
"import": "./src/components/dialog.tsx",
"require": "./src/components/dialog.tsx"
},
"./components/form": {
"types": "./src/components/form.tsx",
"import": "./src/components/form.tsx",
"require": "./src/components/form.tsx"
},
"./components/tab-bar": {
"types": "./src/components/tab-bar.tsx",
"import": "./src/components/tab-bar.tsx",
"require": "./src/components/tab-bar.tsx"
},
"./testing": {
"types": "./src/testing/index.ts",
"import": "./src/testing/index.ts",
"require": "./src/testing/index.ts"
}
}
使用方式:消费者可以通过 import { Button } from '@d8d/mini-shared-ui-components/components/button' 精确导入特定组件
优势:
关键差异:
companyEnterpriseRoutes、personExtensionRoutes、enterpriseAuthRoutes),使用typeof获取类型进行类型推断。注意:与之前从@d8d/server统一导入路由类型不同,现在改为从各自的后端模块包中导入对应的路由对象,这样更加清晰和便于维护。mini/src/pages/yongren/ [来源:docs/architecture/source-tree.md#实际项目结构]mini-ui-packages/ 目录下创建各个页面包mini/src/pages/yongren/dashboard/index.tsx 和 index.cssmini/src/pages/yongren/order/list/index.tsx 和相关文件mini/src/pages/yongren/order/detail/index.tsx 和相关文件mini/src/pages/yongren/talent/list/index.tsx 和相关文件mini/src/pages/yongren/talent/detail/index.tsx 和相关文件mini/src/pages/yongren/statistics/index.tsx 和相关文件mini/src/pages/yongren/settings/index.tsx 和相关文件页面包结构示例(yongren-dashboard-ui):
mini-ui-packages/yongren-dashboard-ui/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts # 导出Dashboard页面组件
│ ├── Dashboard.tsx # 仪表板页面组件
│ ├── Dashboard.config.ts # 页面配置
│ ├── Dashboard.css # 页面样式
│ └── utils/ # 页面工具函数
└── tests/
└── Dashboard.test.tsx # 页面测试
路由配置更新:
mini/src/app.config.ts 的 pages 数组中pages/yongren/dashboard/index 更新为从包中导入的路径tests/文件夹与源码并行 [来源:docs/architecture/coding-standards.md#增强特定标准]@d8d/mini-shared-ui-components/testing 导出的测试工具 [来源:docs/stories/014.001.mini-shared-ui-components.md#任务3]data-testid属性 [来源:docs/architecture/ui-package-standards.md#测试选择器优化规范]packages/目录用于共享包 [来源:docs/architecture/source-tree.md#实际项目结构]mini-ui-packages/目录来组织所有mini相关的UI包tests/文件夹与源码并行 [来源:docs/architecture/coding-standards.md#增强特定标准]mini-shared-ui-components/testing)| Date | Version | Description | Author |
|---|---|---|---|
| 2025-12-19 | 1.0 | Initial story creation | Scrum Master Bob |
This section is populated by the development agent during implementation
claude-sonnet
Reference any debug logs or traces generated during development
新建文件:
修改文件:
Results from QA Agent QA review of the completed story implementation