From 55dbdba6361112067a2827484a1c5245906745a2 Mon Sep 17 00:00:00 2001 From: CaIon Date: Sat, 9 Aug 2025 18:26:45 +0800 Subject: [PATCH 1/5] feat: add FluentRead support in chat configuration --- setting/chat.go | 3 +++ web/src/components/table/tokens/index.jsx | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/setting/chat.go b/setting/chat.go index 53cb655a..b97d65ce 100644 --- a/setting/chat.go +++ b/setting/chat.go @@ -12,6 +12,9 @@ var Chats = []map[string]string{ { "Cherry Studio": "cherrystudio://providers/api-keys?v=1&data={cherryConfig}", }, + { + "流畅阅读": "fluentread", + }, { "Lobe Chat 官方示例": "https://chat-preview.lobehub.com/?settings={\"keyVaults\":{\"openai\":{\"apiKey\":\"{key}\",\"baseURL\":\"{address}/v1\"}}}", }, diff --git a/web/src/components/table/tokens/index.jsx b/web/src/components/table/tokens/index.jsx index ee1ff75d..e0c3d93b 100644 --- a/web/src/components/table/tokens/index.jsx +++ b/web/src/components/table/tokens/index.jsx @@ -91,7 +91,7 @@ function TokensPage() { if (localStorage.getItem(SUPPRESS_KEY) === '1') return; const container = document.getElementById('fluent-new-api-container'); if (!container) { - Toast.warning(t('未检测到 Fluent 容器,请确认扩展已启用')); + Toast.warning(t('未检测到 FluentRead(流畅阅读),请确认扩展已启用')); return; } setPrefillKey(key || ''); @@ -102,13 +102,13 @@ function TokensPage() { } Notification.info({ id: 'fluent-detected', - title: t('检测到 Fluent(流畅阅读)'), + title: t('检测到 FluentRead(流畅阅读)'), content: (
{prefillKey - ? t('已检测到 Fluent 扩展,已从操作中指定密钥,将使用该密钥进行填充。请选择模型后继续。') - : t('已检测到 Fluent 扩展,请选择模型后可一键填充当前选中令牌(或本页第一个令牌)。')} + ? t('已检测到 FluentRead 扩展,已从操作中指定密钥,将使用该密钥进行填充。请选择模型后继续。') + : t('已检测到 FluentRead 扩展,请选择模型后可一键填充当前选中令牌(或本页第一个令牌)。')}
{t('一键填充到 FluentRead')} - + {!key && ( + + )} From a47fc5a76bb594b9a3429b9dc3938226dd7dc7d8 Mon Sep 17 00:00:00 2001 From: CaIon Date: Sat, 9 Aug 2025 20:58:28 +0800 Subject: [PATCH 3/5] 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); From 50f9195f2d26882292c18a168a63e046cc5fda10 Mon Sep 17 00:00:00 2001 From: CaIon Date: Sat, 9 Aug 2025 21:04:49 +0800 Subject: [PATCH 4/5] feat: remove custom JSON marshaling for Message struct --- dto/openai_request.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dto/openai_request.go b/dto/openai_request.go index 127c5c94..f33b2c1e 100644 --- a/dto/openai_request.go +++ b/dto/openai_request.go @@ -140,14 +140,6 @@ 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"` From fd2ff2a973f8964fac3a818f127d8b03225a8bbe Mon Sep 17 00:00:00 2001 From: CaIon Date: Sat, 9 Aug 2025 21:06:25 +0800 Subject: [PATCH 5/5] feat: update Fluent Read link handling in sidebar to improve chat item filtering --- web/src/components/layout/SiderBar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/components/layout/SiderBar.js b/web/src/components/layout/SiderBar.js index 66ae6350..985042ee 100644 --- a/web/src/components/layout/SiderBar.js +++ b/web/src/components/layout/SiderBar.js @@ -208,13 +208,13 @@ const SiderBar = ({ onNavigate = () => { } }) => { if (typeof link !== 'string') continue; // 确保链接是字符串 if (link.startsWith('fluent')) { shouldSkip = true; - continue; // 跳过 Fluent Read + break; // 跳过 Fluent Read } chat.text = key; chat.itemKey = 'chat' + i; chat.to = '/console/chat/' + i; } - if (shouldSkip) continue; + if (shouldSkip || !chat.text) continue; // 避免推入空项 chatItems.push(chat); } setChatItems(chatItems);