Browse Source

Fix: webapp color theme (#6908)

tags/0.6.16
KVOJJJin 1 year ago
parent
commit
62cc4077bb
No account linked to committer's email address

+ 2
- 0
web/app/components/base/chat/chat-with-history/chat-wrapper.tsx View File

handleFeedback, handleFeedback,
currentChatInstanceRef, currentChatInstanceRef,
appData, appData,
themeBuilder,
} = useChatWithHistoryContext() } = useChatWithHistoryContext()
const appConfig = useMemo(() => { const appConfig = useMemo(() => {
const config = appParams || {} const config = appParams || {}
onFeedback={handleFeedback} onFeedback={handleFeedback}
suggestedQuestions={suggestedQuestions} suggestedQuestions={suggestedQuestions}
hideProcessDetail hideProcessDetail
themeBuilder={themeBuilder}
/> />
) )
} }

+ 2
- 0
web/app/components/base/chat/chat-with-history/context.tsx View File

ChatItem, ChatItem,
Feedback, Feedback,
} from '../types' } from '../types'
import type { ThemeBuilder } from '../embedded-chatbot/theme/theme-context'
import type { import type {
AppConversationData, AppConversationData,
AppData, AppData,
appId?: string appId?: string
handleFeedback: (messageId: string, feedback: Feedback) => void handleFeedback: (messageId: string, feedback: Feedback) => void
currentChatInstanceRef: RefObject<{ handleStop: () => void }> currentChatInstanceRef: RefObject<{ handleStop: () => void }>
themeBuilder?: ThemeBuilder
} }


export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>({ export const ChatWithHistoryContext = createContext<ChatWithHistoryContextValue>({

+ 6
- 1
web/app/components/base/chat/chat-with-history/index.tsx View File

useState, useState,
} from 'react' } from 'react'
import { useAsyncEffect } from 'ahooks' import { useAsyncEffect } from 'ahooks'
import { useThemeContext } from '../embedded-chatbot/theme/theme-context'
import { import {
ChatWithHistoryContext, ChatWithHistoryContext,
useChatWithHistoryContext, useChatWithHistoryContext,
appChatListDataLoading, appChatListDataLoading,
chatShouldReloadKey, chatShouldReloadKey,
isMobile, isMobile,
themeBuilder,
} = useChatWithHistoryContext() } = useChatWithHistoryContext()


const chatReady = (!showConfigPanelBeforeChat || !!appPrevChatList.length) const chatReady = (!showConfigPanelBeforeChat || !!appPrevChatList.length)
const site = appData?.site const site = appData?.site


useEffect(() => { useEffect(() => {
themeBuilder?.buildTheme(site?.chat_color_theme, site?.chat_color_theme_inverted)
if (site) { if (site) {
if (customConfig) if (customConfig)
document.title = `${site.title}` document.title = `${site.title}`
else else
document.title = `${site.title} - Powered by Dify` document.title = `${site.title} - Powered by Dify`
} }
}, [site, customConfig])
}, [site, customConfig, themeBuilder])


if (appInfoLoading) { if (appInfoLoading) {
return ( return (
}) => { }) => {
const media = useBreakpoints() const media = useBreakpoints()
const isMobile = media === MediaType.mobile const isMobile = media === MediaType.mobile
const themeBuilder = useThemeContext()


const { const {
appInfoError, appInfoError,
appId, appId,
handleFeedback, handleFeedback,
currentChatInstanceRef, currentChatInstanceRef,
themeBuilder,
}}> }}>
<ChatWithHistory className={className} /> <ChatWithHistory className={className} />
</ChatWithHistoryContext.Provider> </ChatWithHistoryContext.Provider>

+ 1
- 1
web/app/components/base/chat/embedded-chatbot/index.tsx View File

else else
document.title = `${site.title} - Powered by Dify` document.title = `${site.title} - Powered by Dify`
} }
}, [site, customConfig])
}, [site, customConfig, themeBuilder])


if (appInfoLoading) { if (appInfoLoading) {
return ( return (

Loading…
Cancel
Save