From a47fc5a76bb594b9a3429b9dc3938226dd7dc7d8 Mon Sep 17 00:00:00 2001 From: CaIon Date: Sat, 9 Aug 2025 20:58:28 +0800 Subject: [PATCH] feat: enhance JSON marshaling for Message and skip Fluent Read links in chat items --- dto/openai_request.go | 8 ++++++++ web/src/components/layout/SiderBar.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/dto/openai_request.go b/dto/openai_request.go index f33b2c1e..127c5c94 100644 --- a/dto/openai_request.go +++ b/dto/openai_request.go @@ -140,6 +140,14 @@ type Message struct { //parsedStringContent *string } +func (m *Message) MarshalJSON() ([]byte, error) { + if m.Content == nil { + m.Content = "" + } + type Alias Message + return json.Marshal((*Alias)(m)) +} + type MediaContent struct { Type string `json:"type"` Text string `json:"text,omitempty"` diff --git a/web/src/components/layout/SiderBar.js b/web/src/components/layout/SiderBar.js index bac677e8..66ae6350 100644 --- a/web/src/components/layout/SiderBar.js +++ b/web/src/components/layout/SiderBar.js @@ -201,12 +201,20 @@ const SiderBar = ({ onNavigate = () => { } }) => { if (Array.isArray(chats)) { let chatItems = []; for (let i = 0; i < chats.length; i++) { + let shouldSkip = false; let chat = {}; for (let key in chats[i]) { + let link = chats[i][key]; + if (typeof link !== 'string') continue; // 确保链接是字符串 + if (link.startsWith('fluent')) { + shouldSkip = true; + continue; // 跳过 Fluent Read + } chat.text = key; chat.itemKey = 'chat' + i; chat.to = '/console/chat/' + i; } + if (shouldSkip) continue; chatItems.push(chat); } setChatItems(chatItems);