Procházet zdrojové kódy

Merge remote-tracking branch 'guoruqiang/main' into pr482-merge

# Conflicts:
#	README.md
#	web/src/components/HeaderBar.js
#	web/src/components/SiderBar.js
CalciumIon před 1 rokem
rodič
revize
c8f437c13a
3 změnil soubory, kde provedl 28 přidání a 5 odebrání
  1. 1 0
      README.md
  2. 14 5
      web/src/components/HeaderBar.js
  3. 13 0
      web/src/pages/Home/index.js

+ 1 - 0
README.md

@@ -64,6 +64,7 @@
 13. 🎵 添加 [Suno API](https://github.com/Suno-API/Suno-API)接口支持,[对接文档](Suno.md)
 14. 🔄 支持Rerank模型,目前兼容Cohere和Jina,可接入Dify,[对接文档](Rerank.md)
 15. ⚡ **[OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime/integration)** - 支持OpenAI的Realtime API,支持Azure渠道
+16. 支持使用路由/chat2link 进入聊天界面
 
 ## 模型支持
 此版本额外支持以下模型:

+ 14 - 5
web/src/components/HeaderBar.js

@@ -14,6 +14,7 @@ import {
   IconHelpCircle,
   IconHome,
   IconHomeStroked, IconIndentLeft,
+  IconComment,
   IconKey, IconMenu,
   IconNoteMoneyStroked,
   IconPriceTag,
@@ -87,12 +88,19 @@ const HeaderBar = () => {
   useEffect(() => {
     if (theme === 'dark') {
       document.body.setAttribute('theme-mode', 'dark');
+    } else {
+      document.body.removeAttribute('theme-mode');
+    }
+    // 发送当前主题模式给子页面
+    const iframe = document.querySelector('iframe');
+    if (iframe) {
+      iframe.contentWindow.postMessage({ themeMode: theme }, '*');
     }
 
     if (isNewYear) {
       console.log('Happy New Year!');
     }
-  }, []);
+  }, [theme]);
 
   useEffect(() => {
     const handleLanguageChanged = (lng) => {
@@ -125,6 +133,7 @@ const HeaderBar = () => {
                 pricing: '/pricing',
                 detail: '/detail',
                 home: '/',
+                chat: '/chat',
               };
               return (
                 <div onClick={(e) => {
@@ -205,13 +214,13 @@ const HeaderBar = () => {
                   position='bottomRight'
                   render={
                     <Dropdown.Menu>
-                      <Dropdown.Item 
+                      <Dropdown.Item
                         onClick={() => handleLanguageChange('zh')}
                         type={currentLang === 'zh' ? 'primary' : 'tertiary'}
                       >
                         中文
                       </Dropdown.Item>
-                      <Dropdown.Item 
+                      <Dropdown.Item
                         onClick={() => handleLanguageChange('en')}
                         type={currentLang === 'en' ? 'primary' : 'tertiary'}
                       >
@@ -220,8 +229,8 @@ const HeaderBar = () => {
                     </Dropdown.Menu>
                   }
                 >
-                  <Nav.Item 
-                    itemKey={'language'} 
+                  <Nav.Item
+                    itemKey={'language'}
                     icon={<IconLanguage />}
                   />
                 </Dropdown>

+ 13 - 0
web/src/pages/Home/index.js

@@ -39,6 +39,19 @@ const Home = () => {
       }
       setHomePageContent(content);
       localStorage.setItem('home_page_content', content);
+
+        // 如果内容是 URL,则发送主题模式
+        if (data.startsWith('https://')) {
+            const iframe = document.querySelector('iframe');
+            if (iframe) {
+                const theme = localStorage.getItem('theme-mode') || 'light';
+                // 测试是否正确传递theme-mode给iframe
+                // console.log('Sending theme-mode to iframe:', theme); 
+                iframe.onload = () => {
+                    iframe.contentWindow.postMessage({ themeMode: theme }, '*');
+                };
+            }
+        }
     } else {
       showError(message);
       setHomePageContent('加载首页内容失败...');