From bbce26af754b1ea22e0fdf720295670a130a8d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=89=E7=A7=8B?= <497055328@qq.com> Date: Tue, 7 Jul 2026 14:34:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=88=87=E6=8D=A2=E5=B8=83=E5=B1=80=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- suixinkan/UI/Home/HomeCollectionModels.swift | 4 +-- suixinkan/UI/Home/HomeViewController.swift | 32 +++++++++++++++---- suixinkan/UI/Profile/ProfileInfoRowView.swift | 3 ++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/suixinkan/UI/Home/HomeCollectionModels.swift b/suixinkan/UI/Home/HomeCollectionModels.swift index a4ca1a1..1ce18d6 100644 --- a/suixinkan/UI/Home/HomeCollectionModels.swift +++ b/suixinkan/UI/Home/HomeCollectionModels.swift @@ -35,8 +35,8 @@ enum HomeCollectionLayoutBuilder { /// 构建 Compositional Layout,按当前分区类型返回 section 布局。 static func makeLayout(sections: [HomeCollectionSection]) -> UICollectionViewCompositionalLayout { UICollectionViewCompositionalLayout { sectionIndex, environment in - guard sectionIndex < sections.count else { return nil } - switch sections[sectionIndex] { + let section = sectionIndex < sections.count ? sections[sectionIndex] : .commonApps + switch section { case .workStatus: return fullWidthSection(height: AppSpacing.formRowHeight) case .locationReport: diff --git a/suixinkan/UI/Home/HomeViewController.swift b/suixinkan/UI/Home/HomeViewController.swift index 4c597ff..f57f944 100644 --- a/suixinkan/UI/Home/HomeViewController.swift +++ b/suixinkan/UI/Home/HomeViewController.swift @@ -9,6 +9,8 @@ import UIKit /// 首页 Tab 根页面,按身份与权限展示信息与入口。 final class HomeViewController: BaseViewController { + private static let fallbackCellReuseIdentifier = "HomeFallbackCell" + private let viewModel = HomeViewModel() private let homeAPI = NetworkServices.shared.homeAPI @@ -117,6 +119,10 @@ final class HomeViewController: BaseViewController { private func registerCollectionCells() { collectionView.register(HomeWorkStatusCell.self, forCellWithReuseIdentifier: HomeWorkStatusCell.reuseIdentifier) + collectionView.register( + UICollectionViewCell.self, + forCellWithReuseIdentifier: Self.fallbackCellReuseIdentifier + ) collectionView.register( HomeLocationReportCell.self, forCellWithReuseIdentifier: HomeLocationReportCell.reuseIdentifier @@ -138,7 +144,18 @@ final class HomeViewController: BaseViewController { let dataSource = UICollectionViewDiffableDataSource( collectionView: collectionView ) { [weak self] collectionView, indexPath, item in - guard let self else { return UICollectionViewCell() } + guard let self else { + return collectionView.dequeueReusableCell( + withReuseIdentifier: Self.fallbackCellReuseIdentifier, + for: indexPath + ) + } + guard indexPath.section < self.currentSections.count else { + return collectionView.dequeueReusableCell( + withReuseIdentifier: Self.fallbackCellReuseIdentifier, + for: indexPath + ) + } let section = self.currentSections[indexPath.section] switch (section, item) { case (.workStatus, .workStatus): @@ -217,14 +234,15 @@ final class HomeViewController: BaseViewController { return cell default: - return UICollectionViewCell() + return collectionView.dequeueReusableCell( + withReuseIdentifier: Self.fallbackCellReuseIdentifier, + for: indexPath + ) } } dataSource.supplementaryViewProvider = { collectionView, kind, indexPath in - guard kind == UICollectionView.elementKindSectionHeader, - indexPath.section < self.currentSections.count, - self.currentSections[indexPath.section] == .commonApps else { + guard kind == UICollectionView.elementKindSectionHeader else { return nil } let header = collectionView.dequeueReusableSupplementaryView( @@ -232,7 +250,9 @@ final class HomeViewController: BaseViewController { withReuseIdentifier: HomeSectionHeaderView.reuseIdentifier, for: indexPath ) as! HomeSectionHeaderView - header.apply(title: "常用应用") + let title = indexPath.section < self.currentSections.count + && self.currentSections[indexPath.section] == .commonApps ? "常用应用" : "" + header.apply(title: title) return header } diff --git a/suixinkan/UI/Profile/ProfileInfoRowView.swift b/suixinkan/UI/Profile/ProfileInfoRowView.swift index a21cf3d..b99756e 100644 --- a/suixinkan/UI/Profile/ProfileInfoRowView.swift +++ b/suixinkan/UI/Profile/ProfileInfoRowView.swift @@ -194,11 +194,14 @@ final class ProfileInfoRowView: UIControl { rightStack.axis = .vertical rightStack.alignment = .trailing rightStack.spacing = 4 + rightStack.isUserInteractionEnabled = false rightStack.addArrangedSubview(stackNameLabel) rightStack.addArrangedSubview(stackTypeTag) rightStack.isHidden = true + badgeContainer.isUserInteractionEnabled = false divider.backgroundColor = UIColor(hex: 0xE5E7EB) + divider.isUserInteractionEnabled = false addSubview(titleLabel) addSubview(valueLabel)