Align iOS home common apps and all-functions page with Android.

Add unified HomeCommonMenu/HomeAllFunctions diagnostics, rebuild all-functions from top-level menuList permissions, and document Home and AllFunctions module logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-30 09:40:02 +08:00
parent 63fb0462d6
commit 5692134efc
11 changed files with 693 additions and 138 deletions

View File

@ -1,5 +1,7 @@
# Home 模块业务逻辑
Android 工程对应文档:[`zhiflyfollow/docs/home/Home.md`](../../../zhiflyfollow/docs/home/Home.md)
## 模块职责
Home 模块负责登录后的首页工作台,包括当前景区展示、工作状态、位置上报入口、快捷操作、常用应用和全部功能入口。
@ -18,14 +20,15 @@ Home 模块负责登录后的首页工作台,包括当前景区展示、工作
## 常用应用
`HomeCommonMenuStore` 使用 UserDefaults 按账号和角色保存常用应用 URI
`HomeCommonMenuStore` 使用 UserDefaults 按账号和角色保存常用应用 URI,算法与 Android `AllFunctionsViewModel` 对齐
- 当前版本使用账号 + 角色作用域保存常用应用 URI避免不同业务账号的同一角色互相覆盖旧版角色 key 会在首次读取时迁移。
- 首次无配置时,按 Android 规则从当前角色顶层权限 URI 生成默认值:权限多于 4 个取前 4 个,否则全部使用
-页常用应用按 Android `Constants.menuList` 白名单过滤iOS 已接入但 Android 首页未登记的 URI 不进入首页常用应用
- 读取时按当前角色权限过滤不可用 URI
- 添加移除时按同义 URI 去重
- 可用菜单范围:仅**顶层权限** ∩ Android `Constants.menuList` 白名单(`androidHomeMenuURIs`),不使用扁平化子权限
-次无配置时:先取顶层权限前 4 个 URI原始 API 顺序),再与 menuList 白名单求交后落库
- 已有 saved 配置时:精确 URI 匹配过滤;全部失效时返回空,**不回退**默认生成
- 添加/移除常用应用使用精确 URI 匹配(与 Android 一致)
- 不同角色的常用应用互不影响。
- 升级时会从旧版 `role.{roleId}` key 一次性迁移到 `role.{roleCode}`
- Debug 构建下可通过 `HomeCommonMenu` 日志 tag 与 Android 端逐步对比(`context` / `rawTopLevel` / `availableFunctions` / `savedCommon` / `defaultCommon` / `finalCommon` / `displayItems`)。
## 路由规则
@ -39,6 +42,10 @@ Home 模块负责登录后的首页工作台,包括当前景区展示、工作
`HomeMoreFunctionsView` 使用系统导航栏展示标题和返回,以支持左边缘滑动返回。
## 全部功能
「全部功能」页的数据、筛选、展示逻辑见独立文档 [`AllFunctions.md`](AllFunctions.md)。
## 位置上报
首页工作状态区域由 `HomeLocationViewModel` 驱动,与 `LocationReport` 详情页共享同一实例(在 `RootView` 注入)。