完善账号切换展示、首页菜单图标与有线传输设置 chip。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-15 14:59:31 +08:00
parent 5eef31b8da
commit ce6de76055
18 changed files with 321 additions and 130 deletions

View File

@ -118,6 +118,7 @@ struct AccountSwitchAccount: Identifiable, Hashable {
let title: String
let subtitle: String
let phone: String
let realName: String
let avatar: String
let scenicName: String
let storeId: Int?
@ -201,6 +202,7 @@ struct V9ScenicUser: Decodable, Equatable {
let phone: String
let scenicId: Int
let scenicName: String
let roleName: String
let appRoleCode: String
let appRoleName: String
let isCurrent: Bool
@ -218,8 +220,9 @@ struct V9ScenicUser: Decodable, Equatable {
accountType: accountType.nonEmpty ?? Self.accountTypeValue,
businessUserId: businessUserId,
title: scenicName.nonEmpty ?? nickname.nonEmpty ?? realName.nonEmpty ?? "景区账号",
subtitle: username,
subtitle: joinAccountSubtitle(scenicName, roleName),
phone: phone,
realName: realName,
avatar: "",
scenicName: scenicName,
storeId: nil,
@ -242,6 +245,7 @@ struct V9ScenicUser: Decodable, Equatable {
case phone
case scenicId = "scenic_id"
case scenicName = "scenic_name"
case roleName = "role_name"
case appRoleCode = "app_role_code"
case appRoleName = "app_role_name"
case isCurrent = "is_current"
@ -262,6 +266,7 @@ struct V9ScenicUser: Decodable, Equatable {
phone = try container.decodeLossyString(forKey: .phone)
scenicId = try container.decodeLossyInt(forKey: .scenicId) ?? 0
scenicName = try container.decodeLossyString(forKey: .scenicName)
roleName = try container.decodeLossyString(forKey: .roleName)
appRoleCode = try container.decodeLossyString(forKey: .appRoleCode)
appRoleName = try container.decodeLossyString(forKey: .appRoleName)
isCurrent = try container.decodeLossyBool(forKey: .isCurrent) ?? false
@ -285,6 +290,7 @@ struct V9StoreUser: Decodable, Equatable {
let scenicName: String
let storeId: Int
let storeName: String
let roleName: String
let appRoleCode: String
let appRoleName: String
let isCurrent: Bool
@ -302,8 +308,9 @@ struct V9StoreUser: Decodable, Equatable {
accountType: accountType.nonEmpty ?? Self.accountTypeValue,
businessUserId: businessUserId,
title: storeName.nonEmpty ?? scenicName.nonEmpty ?? realName.nonEmpty ?? userName.nonEmpty ?? "门店账号",
subtitle: userName.nonEmpty ?? username,
subtitle: joinAccountSubtitle(scenicName, roleName),
phone: phone,
realName: realName,
avatar: avatar,
scenicName: scenicName,
storeId: storeId > 0 ? storeId : nil,
@ -327,6 +334,7 @@ struct V9StoreUser: Decodable, Equatable {
case scenicName = "scenic_name"
case storeId = "store_id"
case storeName = "store_name"
case roleName = "role_name"
case appRoleCode = "app_role_code"
case appRoleName = "app_role_name"
case isCurrent = "is_current"
@ -347,6 +355,7 @@ struct V9StoreUser: Decodable, Equatable {
scenicName = try container.decodeLossyString(forKey: .scenicName)
storeId = try container.decodeLossyInt(forKey: .storeId) ?? 0
storeName = try container.decodeLossyString(forKey: .storeName)
roleName = try container.decodeLossyString(forKey: .roleName)
appRoleCode = try container.decodeLossyString(forKey: .appRoleCode)
appRoleName = try container.decodeLossyString(forKey: .appRoleName)
isCurrent = try container.decodeLossyBool(forKey: .isCurrent) ?? false
@ -405,6 +414,14 @@ private extension KeyedDecodingContainer {
}
}
///
private func joinAccountSubtitle(_ values: String...) -> String {
values
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
.filter { !$0.isEmpty }
.joined(separator: " · ")
}
private extension String {
var nonEmpty: String? {
let text = trimmingCharacters(in: .whitespacesAndNewlines)

View File

@ -0,0 +1,21 @@
//
// HomeMenuIconFactory.swift
// suixinkan
//
import UIKit
/// / SF Symbol
enum HomeMenuIconFactory {
/// 2426pt
static let symbolConfiguration = UIImage.SymbolConfiguration(pointSize: 18, weight: .medium)
/// Assets SF Symbol
static func image(named iconName: String) -> UIImage? {
if let asset = UIImage(named: iconName) {
return asset
}
return UIImage(systemName: iconName, withConfiguration: symbolConfiguration)
}
}