From a430284aa21e3ae1f0d5654e55b2ad2852519cc2 Mon Sep 17 00:00:00 2001
From: wwf <yearningwang@iqtogether.com>
Date: 星期三, 04 六月 2025 15:17:49 +0800
Subject: [PATCH] 初始化

---
 app/components/base/chat/chat-with-history/index.tsx |   90 ++++++++++++++++----------------------------
 1 files changed, 33 insertions(+), 57 deletions(-)

diff --git a/app/components/base/chat/chat-with-history/index.tsx b/app/components/base/chat/chat-with-history/index.tsx
index dfd7bd2..7282dd4 100644
--- a/app/components/base/chat/chat-with-history/index.tsx
+++ b/app/components/base/chat/chat-with-history/index.tsx
@@ -11,15 +11,14 @@
 } from './context'
 import { useChatWithHistory } from './hooks'
 import Sidebar from './sidebar'
-import Header from './header'
 import HeaderInMobile from './header-in-mobile'
+import ConfigPanel from './config-panel'
 import ChatWrapper from './chat-wrapper'
 import type { InstalledApp } from '@/models/explore'
 import Loading from '@/app/components/base/loading'
 import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
 import { checkOrSetAccessToken } from '@/app/components/share/utils'
 import AppUnavailable from '@/app/components/base/app-unavailable'
-import cn from '@/utils/classnames'
 
 type ChatWithHistoryProps = {
   className?: string
@@ -31,17 +30,17 @@
     appInfoError,
     appData,
     appInfoLoading,
+    appPrevChatTree,
+    showConfigPanelBeforeChat,
     appChatListDataLoading,
     chatShouldReloadKey,
     isMobile,
     themeBuilder,
-    sidebarCollapseState,
   } = useChatWithHistoryContext()
-  const isSidebarCollapsed = sidebarCollapseState
+
+  const chatReady = (!showConfigPanelBeforeChat || !!appPrevChatTree.length)
   const customConfig = appData?.custom_config
   const site = appData?.site
-
-  const [showSidePanel, setShowSidePanel] = useState(false)
 
   useEffect(() => {
     themeBuilder?.buildTheme(site?.chat_color_theme, site?.chat_color_theme_inverted)
@@ -66,44 +65,35 @@
   }
 
   return (
-    <div className={cn(
-      'flex h-full bg-background-default-burn',
-      isMobile && 'flex-col',
-      className,
-    )}>
-      {!isMobile && (
-        <div className={cn(
-          'flex w-[236px] flex-col p-1 pr-0 transition-all duration-200 ease-in-out',
-          isSidebarCollapsed && 'w-0 overflow-hidden !p-0',
-        )}>
+    <div className={`h-full flex bg-white ${className} ${isMobile && 'flex-col'}`}>
+      {
+        !isMobile && (
           <Sidebar />
-        </div>
-      )}
-      {isMobile && (
-        <HeaderInMobile />
-      )}
-      <div className={cn('relative grow p-2', isMobile && 'h-[calc(100%_-_56px)] p-0')}>
-        {isSidebarCollapsed && (
-          <div
-            className={cn(
-              'absolute top-0 z-20 flex h-full w-[256px] flex-col p-2 transition-all duration-500 ease-in-out',
-              showSidePanel ? 'left-0' : 'left-[-248px]',
-            )}
-            onMouseEnter={() => setShowSidePanel(true)}
-            onMouseLeave={() => setShowSidePanel(false)}
-          >
-            <Sidebar isPanel />
-          </div>
-        )}
-        <div className={cn('flex h-full flex-col overflow-hidden border-[0,5px] border-components-panel-border-subtle bg-chatbot-bg', isMobile ? 'rounded-t-2xl' : 'rounded-2xl')}>
-          {!isMobile && <Header />}
-          {appChatListDataLoading && (
+        )
+      }
+      {
+        isMobile && (
+          <HeaderInMobile />
+        )
+      }
+      <div className={`grow overflow-hidden ${showConfigPanelBeforeChat && !appPrevChatTree.length && 'flex items-center justify-center'}`}>
+        {
+          showConfigPanelBeforeChat && !appChatListDataLoading && !appPrevChatTree.length && (
+            <div className={`flex w-full items-center justify-center h-full ${isMobile && 'px-4'}`}>
+              <ConfigPanel />
+            </div>
+          )
+        }
+        {
+          appChatListDataLoading && chatReady && (
             <Loading type='app' />
-          )}
-          {!appChatListDataLoading && (
+          )
+        }
+        {
+          chatReady && !appChatListDataLoading && (
             <ChatWrapper key={chatShouldReloadKey} />
-          )}
-        </div>
+          )
+        }
       </div>
     </div>
   )
@@ -133,6 +123,7 @@
     appPrevChatTree,
     pinnedConversationList,
     conversationList,
+    showConfigPanelBeforeChat,
     newConversationInputs,
     newConversationInputsRef,
     handleNewConversationInputsChange,
@@ -151,14 +142,6 @@
     appId,
     handleFeedback,
     currentChatInstanceRef,
-    sidebarCollapseState,
-    handleSidebarCollapse,
-    clearChatList,
-    setClearChatList,
-    isResponding,
-    setIsResponding,
-    currentConversationInputs,
-    setCurrentConversationInputs,
   } = useChatWithHistory(installedAppInfo)
 
   return (
@@ -174,6 +157,7 @@
       appPrevChatTree,
       pinnedConversationList,
       conversationList,
+      showConfigPanelBeforeChat,
       newConversationInputs,
       newConversationInputsRef,
       handleNewConversationInputsChange,
@@ -194,14 +178,6 @@
       handleFeedback,
       currentChatInstanceRef,
       themeBuilder,
-      sidebarCollapseState,
-      handleSidebarCollapse,
-      clearChatList,
-      setClearChatList,
-      isResponding,
-      setIsResponding,
-      currentConversationInputs,
-      setCurrentConversationInputs,
     }}>
       <ChatWithHistory className={className} />
     </ChatWithHistoryContext.Provider>

--
Gitblit v1.8.0