为资产模块新增相册管理与片花上传
为 album_list 与 album_trailer 接入首页路由,在 Profile 中新增 DEBUG 首页菜单预览,并扩展 Assets 测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -17,6 +17,8 @@ Profile 模块负责“我的/个人信息”页面及其二级页面,包括
|
||||
|
||||
登录态清理和缓存清理由 App 模块的 `AuthSessionCoordinator` 统一处理。
|
||||
|
||||
DEBUG 构建下,“我的”列表会额外展示“首页调试”入口,进入 `DebugHomeMenuPreviewView` 后可查看并跳转所有已知首页菜单,不读取角色权限。该入口只用于迁移预览和调试,不进入 Release 包。
|
||||
|
||||
## 核心对象
|
||||
|
||||
- `ProfileView`:个人信息页 UI,负责展示资料、编辑入口、密码弹窗和退出确认。
|
||||
@ -25,6 +27,7 @@ Profile 模块负责“我的/个人信息”页面及其二级页面,包括
|
||||
- `AccountSwitchView` / `AccountSwitchViewModel`:账号切换页面和状态逻辑。
|
||||
- `RealNameAuthView` / `RealNameAuthViewModel`:实名认证页面和表单逻辑。
|
||||
- `SettingsCenterView` / `AgreementView`:设置中心和协议 H5 页面。
|
||||
- `DebugHomeMenuPreviewView`:DEBUG 专用首页菜单预览页,不参与正式业务流程。
|
||||
- `ProfileAPI`:封装用户资料、实名认证和资料更新接口。
|
||||
- `OSSUploadService`:上传头像和实名认证证件图片,返回可提交给业务接口的 OSS URL。
|
||||
- `UserInfoResponse`:用户基础资料。
|
||||
|
||||
@ -13,6 +13,9 @@ enum ProfileRoute: Hashable {
|
||||
case realNameAuth
|
||||
case settings
|
||||
case agreement(AgreementPage)
|
||||
#if DEBUG
|
||||
case debugHomeMenus
|
||||
#endif
|
||||
|
||||
/// 构建个人中心路由对应的 SwiftUI 目标页面。
|
||||
@ViewBuilder
|
||||
@ -26,6 +29,10 @@ enum ProfileRoute: Hashable {
|
||||
SettingsCenterView()
|
||||
case .agreement(let page):
|
||||
AgreementView(page: page)
|
||||
#if DEBUG
|
||||
case .debugHomeMenus:
|
||||
DebugHomeMenuPreviewView()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
148
suixinkan/Features/Profile/Views/DebugHomeMenuPreviewView.swift
Normal file
148
suixinkan/Features/Profile/Views/DebugHomeMenuPreviewView.swift
Normal file
@ -0,0 +1,148 @@
|
||||
//
|
||||
// DebugHomeMenuPreviewView.swift
|
||||
// suixinkan
|
||||
//
|
||||
// Created by Codex on 2026/6/24.
|
||||
//
|
||||
|
||||
#if DEBUG
|
||||
import SwiftUI
|
||||
|
||||
/// 首页菜单调试预览页,展示所有已知菜单入口并跳过权限过滤。
|
||||
struct DebugHomeMenuPreviewView: View {
|
||||
@Environment(AppRouter.self) private var appRouter
|
||||
@Environment(RouterPath.self) private var router
|
||||
@Environment(ToastCenter.self) private var toastCenter
|
||||
|
||||
private let items = HomeMenuRouter.debugAllMenuItems()
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section {
|
||||
ForEach(items) { item in
|
||||
Button {
|
||||
open(item)
|
||||
} label: {
|
||||
DebugHomeMenuRow(item: item, route: HomeMenuRouter.resolve(uri: item.uri, title: item.title))
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
} header: {
|
||||
Text("全部首页菜单")
|
||||
} footer: {
|
||||
Text("DEBUG 调试入口不读取角色权限,仅用于预览页面迁移状态。")
|
||||
}
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.navigationTitle("首页菜单调试")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
/// 打开指定调试菜单。
|
||||
private func open(_ item: HomeMenuItem) {
|
||||
let route = HomeMenuRouter.resolve(uri: item.uri, title: item.title)
|
||||
switch route {
|
||||
case .tab(let tab):
|
||||
appRouter.select(tab)
|
||||
case .orders(let entry):
|
||||
appRouter.selectOrders(entry: entry)
|
||||
case .destination(let homeRoute):
|
||||
router.navigate(to: .home(homeRoute))
|
||||
case .unsupported(_, let title, let reason):
|
||||
toastCenter.show(reason)
|
||||
router.navigate(to: .home(.modulePlaceholder(uri: item.uri, title: title)))
|
||||
case .placeholder(let uri, let title):
|
||||
HomeRouteDiagnostics.recordUnknown(uri: uri, title: title)
|
||||
router.navigate(to: .home(.modulePlaceholder(uri: uri, title: title)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 首页菜单调试行,展示菜单标题、URI 和解析状态。
|
||||
private struct DebugHomeMenuRow: View {
|
||||
let item: HomeMenuItem
|
||||
let route: HomeMenuResolvedRoute
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: AppMetrics.Spacing.small) {
|
||||
Image(systemName: iconName)
|
||||
.font(.system(size: 18, weight: .semibold))
|
||||
.foregroundStyle(iconColor)
|
||||
.frame(width: 30, height: 30)
|
||||
.background(iconColor.opacity(0.12), in: Circle())
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(item.title)
|
||||
.font(.system(size: AppMetrics.FontSize.body, weight: .semibold))
|
||||
.foregroundStyle(AppDesign.textPrimary)
|
||||
Text(item.uri)
|
||||
.font(.system(size: AppMetrics.FontSize.caption))
|
||||
.foregroundStyle(AppDesign.textSecondary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(routeLabel)
|
||||
.font(.system(size: AppMetrics.FontSize.caption, weight: .semibold))
|
||||
.foregroundStyle(iconColor)
|
||||
|
||||
Image(systemName: "chevron.right")
|
||||
.font(.system(size: AppMetrics.FontSize.caption, weight: .semibold))
|
||||
.foregroundStyle(AppDesign.placeholder)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.padding(.vertical, AppMetrics.Spacing.xSmall)
|
||||
}
|
||||
|
||||
/// 返回当前路由类型展示文案。
|
||||
private var routeLabel: String {
|
||||
switch route {
|
||||
case .tab:
|
||||
return "Tab"
|
||||
case .orders:
|
||||
return "订单"
|
||||
case .destination(let homeRoute):
|
||||
if case .modulePlaceholder = homeRoute {
|
||||
return "占位"
|
||||
}
|
||||
return "页面"
|
||||
case .unsupported:
|
||||
return "不支持"
|
||||
case .placeholder:
|
||||
return "未知"
|
||||
}
|
||||
}
|
||||
|
||||
/// 返回当前路由类型图标。
|
||||
private var iconName: String {
|
||||
switch route {
|
||||
case .tab:
|
||||
return "rectangle.grid.1x2"
|
||||
case .orders:
|
||||
return "doc.text"
|
||||
case .destination(let homeRoute):
|
||||
if case .modulePlaceholder = homeRoute {
|
||||
return "square.dashed"
|
||||
}
|
||||
return "arrowshape.turn.up.right"
|
||||
case .unsupported:
|
||||
return "nosign"
|
||||
case .placeholder:
|
||||
return "questionmark.circle"
|
||||
}
|
||||
}
|
||||
|
||||
/// 返回当前路由类型颜色。
|
||||
private var iconColor: Color {
|
||||
switch route {
|
||||
case .tab, .orders, .destination:
|
||||
AppDesign.primary
|
||||
case .unsupported:
|
||||
.red
|
||||
case .placeholder:
|
||||
AppDesign.warning
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -322,6 +322,20 @@ struct ProfileView: View {
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
#if DEBUG
|
||||
divider
|
||||
|
||||
Button {
|
||||
router.navigate(to: .profile(.debugHomeMenus))
|
||||
} label: {
|
||||
infoRow(title: "首页调试") {
|
||||
statusBadge(text: "DEBUG", icon: "hammer.fill", foreground: AppDesign.primary, background: AppDesign.primarySoft)
|
||||
rowChevron
|
||||
}
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
#endif
|
||||
}
|
||||
.padding(.horizontal, 24)
|
||||
.padding(.vertical, 4)
|
||||
|
||||
Reference in New Issue
Block a user