From 2be3f84196c2f1c3d1007dc82732f8c6fab22f3b Mon Sep 17 00:00:00 2001 From: Lakr <25259084+Lakr233@users.noreply.github.com> Date: Tue, 1 Jul 2025 14:06:06 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=9A=91=20compiler=20issue=20on=20n?= =?UTF-8?q?ewer=20syntax=20(#12974)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary by CodeRabbit * **Refactor** * Updated method and function signatures to accept any type conforming to the chat cell view model protocol, improving flexibility and extensibility of chat cell configuration and height estimation. * Simplified internal logic for determining text color in chat cells. --- .../Sources/Intelligents/ChatManager/ChatManager+Stream.swift | 2 +- .../Interface/View/ChatCell/AssistantMessageCell.swift | 2 +- .../Intelligents/Interface/View/ChatCell/ChatBaseCell.swift | 4 +--- .../Interface/View/ChatCell/ChatCellFactory.swift | 2 +- .../Intelligents/Interface/View/ChatCell/LoadingCell.swift | 2 +- .../Interface/View/ChatCell/SystemMessageCell.swift | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/ChatManager/ChatManager+Stream.swift b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/ChatManager/ChatManager+Stream.swift index 7ce6e89c09..a970fb6cbd 100644 --- a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/ChatManager/ChatManager+Stream.swift +++ b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/ChatManager/ChatManager+Stream.swift @@ -21,7 +21,7 @@ extension ChatManager { id: .init(), content: inputBoxData.text, timestamp: .init(), - attachments: [], + attachments: [] )) let messageParameters: [String: AnyHashable] = [ diff --git a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/AssistantMessageCell.swift b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/AssistantMessageCell.swift index 3431731c66..eb4b49ca6a 100644 --- a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/AssistantMessageCell.swift +++ b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/AssistantMessageCell.swift @@ -84,7 +84,7 @@ class AssistantMessageCell: ChatBaseCell { // MARK: - Configuration - override func configure(with viewModel: ChatCellViewModel) { + override func configure(with viewModel: any ChatCellViewModel) { guard let assistantViewModel = viewModel as? AssistantMessageCellViewModel else { return } self.viewModel = assistantViewModel diff --git a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatBaseCell.swift b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatBaseCell.swift index 6847807511..5681e37abb 100644 --- a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatBaseCell.swift +++ b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatBaseCell.swift @@ -76,7 +76,7 @@ class ChatBaseCell: UITableViewCell { } /// 配置 ViewModel,子类需要重写 - func configure(with _: ChatCellViewModel) { + func configure(with _: any ChatCellViewModel) { // 子类实现 } @@ -91,8 +91,6 @@ class ChatBaseCell: UITableViewCell { .systemRed case .loading: .secondaryLabel - default: - .label } } diff --git a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatCellFactory.swift b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatCellFactory.swift index c1abc556f7..11bd7bd2b7 100644 --- a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatCellFactory.swift +++ b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/ChatCellFactory.swift @@ -53,7 +53,7 @@ class ChatCellFactory { // MARK: - Height Estimation - static func estimatedHeight(for viewModel: ChatCellViewModel) -> CGFloat { + static func estimatedHeight(for viewModel: any ChatCellViewModel) -> CGFloat { switch viewModel.cellType { case .userMessage, .assistantMessage: diff --git a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/LoadingCell.swift b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/LoadingCell.swift index 1e2d92b29c..e6256fe801 100644 --- a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/LoadingCell.swift +++ b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/LoadingCell.swift @@ -63,7 +63,7 @@ class LoadingCell: ChatBaseCell { // MARK: - Configuration - override func configure(with viewModel: ChatCellViewModel) { + override func configure(with viewModel: any ChatCellViewModel) { guard let loadingViewModel = viewModel as? LoadingCellViewModel else { return } self.viewModel = loadingViewModel diff --git a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/SystemMessageCell.swift b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/SystemMessageCell.swift index 97efc69596..fe928c19bd 100644 --- a/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/SystemMessageCell.swift +++ b/packages/frontend/apps/ios/App/Packages/Intelligents/Sources/Intelligents/Interface/View/ChatCell/SystemMessageCell.swift @@ -68,7 +68,7 @@ class SystemMessageCell: ChatBaseCell { // MARK: - Configuration - override func configure(with viewModel: ChatCellViewModel) { + override func configure(with viewModel: any ChatCellViewModel) { guard let systemViewModel = viewModel as? SystemMessageCellViewModel else { return } self.viewModel = systemViewModel