From 2bbbdea70797da03ae1a82550bdec2d0b5c42a01 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Mon, 4 Aug 2025 13:56:59 +0800 Subject: [PATCH] =?utf8?q?AI=E5=A4=A7=E6=A8=A1=E5=9E=8B=E5=A2=9E=E5=8A=A0?= =?utf8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/AivoiceChatContentListItemView.h | 1 + .../nativeui/aivoice/src/AiVoicePresenter.cpp | 2 +- .../src/AivoiceChatContentListItemView.cpp | 29 +++++++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h index 0897ec9b0..bde48ec66 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceChatContentListItemView.h @@ -29,6 +29,7 @@ namespace OHOS private: UILabel chatContentLabel; + UILabel mindLabel; UIImageView chatContentImage; UIScrollView chatContentScrollView; int m_viewHeight; diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 3a3449afd..96efd664f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -302,7 +302,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeViewOperator"); // 加锁,作用域结束时自动释放锁 - std::lock_guard lock(m_mutex); + // std::lock_guard lock(m_mutex); bool isSameView = (hideView == showView); if (isSameView) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp index a5b9590c7..0ec9239dc 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceChatContentListItemView.cpp @@ -23,6 +23,11 @@ namespace OHOS static constexpr const int16_t CHATCONTENTLABEL_TEXT_FONT = 26; static constexpr const int16_t CHATCONTENTLABEL_LINE_HEIGHT = 30; + static constexpr const int16_t MINDLABEL_X = 40; + static constexpr const int16_t MINDLABEL_Y = 25; + static constexpr const int16_t MINDLABEL_TEXT_FONT = 20; + static constexpr const int16_t MINDLABEL_LINE_HEIGHT = 26; + static constexpr const int64_t RADIUS = 20; static constexpr const int16_t QUESTION_CHATCONTENTIMAGE_X = 0; @@ -54,6 +59,7 @@ namespace OHOS SetUpChild(); Add(&chatContentImage); chatContentScrollView.Add(&chatContentLabel); + chatContentScrollView.Add(&mindLabel); Add(&chatContentScrollView); } @@ -61,6 +67,7 @@ namespace OHOS { Remove(&chatContentImage); chatContentScrollView.Remove(&chatContentLabel); + chatContentScrollView.Remove(&mindLabel); Remove(&chatContentScrollView); } @@ -88,12 +95,19 @@ namespace OHOS } else { - if(!AiVoiceModel::GetInstance().GetIsLimitDisplayed()) + if (!AiVoiceModel::GetInstance().GetIsLimitDisplayed()) { AiVoiceModel::GetInstance().SetIsLimitDisplayed(true); - chatContentLabel.SetLineBreakMode(isAiAnswerFlag ? UILabel::LINE_BREAK_ELLIPSIS : UILabel::LINE_BREAK_WRAP);//超过高度在末尾用省略号替换 + chatContentLabel.SetLineBreakMode(isAiAnswerFlag ? UILabel::LINE_BREAK_ELLIPSIS : UILabel::LINE_BREAK_WRAP); // 超过高度在末尾用省略号替换 } } + + if(isAiAnswerFlag) + { + chatContentScrollView.Resize(isAiAnswerFlag ? QUESTION_CHATCONTENTSCROLLVIEW_W : ANSWER_CHATCONTENTSCROLLVIEW_W, GetHeight()); + mindLabel.SetY(chatContentScrollView.GetY() + chatContentScrollView.GetHeight()- 40); + mindLabel.SetVisible(true); + } } void AivoiceChatContentListItemView::SetUpChild() @@ -115,6 +129,17 @@ namespace OHOS chatContentLabel.SetLineBreakMode(UILabel::LINE_BREAK_WRAP); chatContentLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); chatContentLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, CHATCONTENTLABEL_TEXT_FONT); + + mindLabel.SetPosition(MINDLABEL_X, MINDLABEL_Y); + mindLabel.Resize(0, 26); + mindLabel.SetVisible(false); + mindLabel.SetText("内容由AI生成,仅供参考"); + mindLabel.SetStyle(STYLE_TEXT_FONT, MINDLABEL_TEXT_FONT); + mindLabel.SetStyle(STYLE_LINE_HEIGHT, MINDLABEL_LINE_HEIGHT); + mindLabel.SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + mindLabel.SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); + mindLabel.SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, MINDLABEL_TEXT_FONT); + mindLabel.SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff)); } } \ No newline at end of file -- 2.17.1