Add backend theme selection based on URL parameter for embedded chat
This commit is contained in:
parent
96905a8933
commit
0b27022931
4 changed files with 23 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ export const useGetSharedChatSearchParams = () => {
|
|||
from: searchParams.get('from') as SharedFrom,
|
||||
sharedId: searchParams.get('shared_id'),
|
||||
locale: searchParams.get('locale'),
|
||||
theme: searchParams.get('theme'),
|
||||
data: data,
|
||||
visibleAvatar: searchParams.get('visible_avatar')
|
||||
? searchParams.get('visible_avatar') !== '1'
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import { NextMessageInput } from '@/components/message-input/next';
|
|||
import MessageItem from '@/components/next-message-item';
|
||||
import PdfDrawer from '@/components/pdf-drawer';
|
||||
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
||||
import { useTheme } from '@/components/theme-provider';
|
||||
import { MessageType } from '@/constants/chat';
|
||||
import { ThemeEnum } from '@/constants/common';
|
||||
import { useUploadCanvasFileWithProgress } from '@/hooks/use-agent-request';
|
||||
import { cn } from '@/lib/utils';
|
||||
import i18n from '@/locales/config';
|
||||
|
|
@ -25,8 +27,10 @@ const ChatContainer = () => {
|
|||
const {
|
||||
sharedId: conversationId,
|
||||
locale,
|
||||
theme,
|
||||
visibleAvatar,
|
||||
} = useGetSharedChatSearchParams();
|
||||
const { setTheme } = useTheme();
|
||||
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
||||
useClickDrawer();
|
||||
|
||||
|
|
@ -89,6 +93,12 @@ const ChatContainer = () => {
|
|||
}
|
||||
}, [locale, visibleAvatar]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (theme && (theme === ThemeEnum.Light || theme === ThemeEnum.Dark)) {
|
||||
setTheme(theme as ThemeEnum);
|
||||
}
|
||||
}, [theme, setTheme]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isTaskMode && inputsData.prologue) {
|
||||
addNewestOneAnswer({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export const useGetSharedChatSearchParams = () => {
|
|||
from: searchParams.get('from') as SharedFrom,
|
||||
sharedId: searchParams.get('shared_id'),
|
||||
locale: searchParams.get('locale'),
|
||||
theme: searchParams.get('theme'),
|
||||
data: data,
|
||||
visibleAvatar: searchParams.get('visible_avatar')
|
||||
? searchParams.get('visible_avatar') !== '1'
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import { NextMessageInput } from '@/components/message-input/next';
|
|||
import MessageItem from '@/components/message-item';
|
||||
import PdfDrawer from '@/components/pdf-drawer';
|
||||
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
||||
import { useTheme } from '@/components/theme-provider';
|
||||
import { MessageType, SharedFrom } from '@/constants/chat';
|
||||
import { ThemeEnum } from '@/constants/common';
|
||||
import { useFetchNextConversationSSE } from '@/hooks/chat-hooks';
|
||||
import { useFetchFlowSSE } from '@/hooks/flow-hooks';
|
||||
import { useFetchExternalChatInfo } from '@/hooks/use-chat-request';
|
||||
|
|
@ -22,8 +24,10 @@ const ChatContainer = () => {
|
|||
sharedId: conversationId,
|
||||
from,
|
||||
locale,
|
||||
theme,
|
||||
visibleAvatar,
|
||||
} = useGetSharedChatSearchParams();
|
||||
const { setTheme } = useTheme();
|
||||
const { visible, hideModal, documentId, selectedChunk, clickDocumentButton } =
|
||||
useClickDrawer();
|
||||
|
||||
|
|
@ -52,6 +56,13 @@ const ChatContainer = () => {
|
|||
i18n.changeLanguage(locale);
|
||||
}
|
||||
}, [locale, visibleAvatar]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (theme && (theme === ThemeEnum.Light || theme === ThemeEnum.Dark)) {
|
||||
setTheme(theme as ThemeEnum);
|
||||
}
|
||||
}, [theme, setTheme]);
|
||||
|
||||
const { data: avatarData } = useFetchAvatar();
|
||||
|
||||
if (!conversationId) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue