mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 17:45:54 +08:00
Fix: webapp color theme (#6908)
This commit is contained in:
parent
e683461416
commit
62cc4077bb
@ -30,6 +30,7 @@ const ChatWrapper = () => {
|
|||||||
handleFeedback,
|
handleFeedback,
|
||||||
currentChatInstanceRef,
|
currentChatInstanceRef,
|
||||||
appData,
|
appData,
|
||||||
|
themeBuilder,
|
||||||
} = useChatWithHistoryContext()
|
} = useChatWithHistoryContext()
|
||||||
const appConfig = useMemo(() => {
|
const appConfig = useMemo(() => {
|
||||||
const config = appParams || {}
|
const config = appParams || {}
|
||||||
@ -143,6 +144,7 @@ const ChatWrapper = () => {
|
|||||||
onFeedback={handleFeedback}
|
onFeedback={handleFeedback}
|
||||||
suggestedQuestions={suggestedQuestions}
|
suggestedQuestions={suggestedQuestions}
|
||||||
hideProcessDetail
|
hideProcessDetail
|
||||||
|
themeBuilder={themeBuilder}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import type {
|
|||||||
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,
|
||||||
@ -46,6 +47,7 @@ export type ChatWithHistoryContextValue = {
|
|||||||
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>({
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
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,
|
||||||
@ -34,6 +35,7 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({
|
|||||||
appChatListDataLoading,
|
appChatListDataLoading,
|
||||||
chatShouldReloadKey,
|
chatShouldReloadKey,
|
||||||
isMobile,
|
isMobile,
|
||||||
|
themeBuilder,
|
||||||
} = useChatWithHistoryContext()
|
} = useChatWithHistoryContext()
|
||||||
|
|
||||||
const chatReady = (!showConfigPanelBeforeChat || !!appPrevChatList.length)
|
const chatReady = (!showConfigPanelBeforeChat || !!appPrevChatList.length)
|
||||||
@ -41,13 +43,14 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({
|
|||||||
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 (
|
||||||
@ -106,6 +109,7 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const media = useBreakpoints()
|
const media = useBreakpoints()
|
||||||
const isMobile = media === MediaType.mobile
|
const isMobile = media === MediaType.mobile
|
||||||
|
const themeBuilder = useThemeContext()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
appInfoError,
|
appInfoError,
|
||||||
@ -171,6 +175,7 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
|
|||||||
appId,
|
appId,
|
||||||
handleFeedback,
|
handleFeedback,
|
||||||
currentChatInstanceRef,
|
currentChatInstanceRef,
|
||||||
|
themeBuilder,
|
||||||
}}>
|
}}>
|
||||||
<ChatWithHistory className={className} />
|
<ChatWithHistory className={className} />
|
||||||
</ChatWithHistoryContext.Provider>
|
</ChatWithHistoryContext.Provider>
|
||||||
|
@ -51,7 +51,7 @@ const Chatbot = () => {
|
|||||||
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…
x
Reference in New Issue
Block a user