diff --git a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx index 9dcd4cc7ab..8eda66c52a 100644 --- a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx +++ b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx @@ -30,6 +30,7 @@ const ChatWrapper = () => { handleFeedback, currentChatInstanceRef, appData, + themeBuilder, } = useChatWithHistoryContext() const appConfig = useMemo(() => { const config = appParams || {} @@ -143,6 +144,7 @@ const ChatWrapper = () => { onFeedback={handleFeedback} suggestedQuestions={suggestedQuestions} hideProcessDetail + themeBuilder={themeBuilder} /> ) } diff --git a/web/app/components/base/chat/chat-with-history/context.tsx b/web/app/components/base/chat/chat-with-history/context.tsx index 7808b73b12..e3c144bcd2 100644 --- a/web/app/components/base/chat/chat-with-history/context.tsx +++ b/web/app/components/base/chat/chat-with-history/context.tsx @@ -8,6 +8,7 @@ import type { ChatItem, Feedback, } from '../types' +import type { ThemeBuilder } from '../embedded-chatbot/theme/theme-context' import type { AppConversationData, AppData, @@ -46,6 +47,7 @@ export type ChatWithHistoryContextValue = { appId?: string handleFeedback: (messageId: string, feedback: Feedback) => void currentChatInstanceRef: RefObject<{ handleStop: () => void }> + themeBuilder?: ThemeBuilder } export const ChatWithHistoryContext = createContext({ diff --git a/web/app/components/base/chat/chat-with-history/index.tsx b/web/app/components/base/chat/chat-with-history/index.tsx index b02091231d..5910a7f949 100644 --- a/web/app/components/base/chat/chat-with-history/index.tsx +++ b/web/app/components/base/chat/chat-with-history/index.tsx @@ -4,6 +4,7 @@ import { useState, } from 'react' import { useAsyncEffect } from 'ahooks' +import { useThemeContext } from '../embedded-chatbot/theme/theme-context' import { ChatWithHistoryContext, useChatWithHistoryContext, @@ -34,6 +35,7 @@ const ChatWithHistory: FC = ({ appChatListDataLoading, chatShouldReloadKey, isMobile, + themeBuilder, } = useChatWithHistoryContext() const chatReady = (!showConfigPanelBeforeChat || !!appPrevChatList.length) @@ -41,13 +43,14 @@ const ChatWithHistory: FC = ({ const site = appData?.site useEffect(() => { + themeBuilder?.buildTheme(site?.chat_color_theme, site?.chat_color_theme_inverted) if (site) { if (customConfig) document.title = `${site.title}` else document.title = `${site.title} - Powered by Dify` } - }, [site, customConfig]) + }, [site, customConfig, themeBuilder]) if (appInfoLoading) { return ( @@ -106,6 +109,7 @@ const ChatWithHistoryWrap: FC = ({ }) => { const media = useBreakpoints() const isMobile = media === MediaType.mobile + const themeBuilder = useThemeContext() const { appInfoError, @@ -171,6 +175,7 @@ const ChatWithHistoryWrap: FC = ({ appId, handleFeedback, currentChatInstanceRef, + themeBuilder, }}> diff --git a/web/app/components/base/chat/embedded-chatbot/index.tsx b/web/app/components/base/chat/embedded-chatbot/index.tsx index 6d144f3f3b..d34fe164d1 100644 --- a/web/app/components/base/chat/embedded-chatbot/index.tsx +++ b/web/app/components/base/chat/embedded-chatbot/index.tsx @@ -51,7 +51,7 @@ const Chatbot = () => { else document.title = `${site.title} - Powered by Dify` } - }, [site, customConfig]) + }, [site, customConfig, themeBuilder]) if (appInfoLoading) { return (