Commit f7d2b090 by 杨明

参数设置

1 parent b0411a55
'use client' /*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
* @LastEditTime: 2025-04-24 09:45:21
* @FilePath: \glsk-ai-assistant\app\components\base\answer-icon\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
"use client";
import type { FC } from 'react' import type { FC } from "react";
import { init } from 'emoji-mart' import { init } from "emoji-mart";
import data from '@emoji-mart/data' import data from "@emoji-mart/data";
import classNames from '@/utils/classnames' import classNames from "@/utils/classnames";
import type { AppIconType } from '@/types/app' import type { AppIconType } from "@/types/app";
init({ data }) init({ data });
export type AnswerIconProps = { export type AnswerIconProps = {
iconType?: AppIconType | null iconType?: AppIconType | null;
icon?: string | null icon?: string | null;
background?: string | null background?: string | null;
imageUrl?: string | null imageUrl: string;
} };
const AnswerIcon: FC<AnswerIconProps> = ({ const AnswerIcon: FC<AnswerIconProps> = ({
iconType, iconType,
icon,
background, background,
imageUrl, imageUrl,
}) => { }) => {
const wrapperClassName = classNames( const wrapperClassName = classNames(
'flex', "flex",
'items-center', "items-center",
'justify-center', "justify-center",
'w-full', "w-full",
'h-full', "h-full",
'rounded-full', "rounded-full",
'border-[0.5px]', "border-[0.5px]",
'border-black/5', "border-black/5",
'text-xl', "text-xl"
) );
const isValidImageIcon = iconType === 'image' && imageUrl return (
return <div <div
className={wrapperClassName} className={wrapperClassName}
style={{ background: background || '#D5F5F6' }} style={{ background: background || "#D5F5F6" }}
> >
{isValidImageIcon <img
? <img src={imageUrl} className="h-full w-full rounded-full" alt="answer icon" /> src={imageUrl}
: (icon && icon !== '') ? <em-emoji id={icon} /> : <em-emoji id='🤖' /> className="h-full w-full rounded-full"
} alt="answer icon"
/>
</div> </div>
} );
};
export default AnswerIcon export default AnswerIcon;
import { useCallback, useState } from 'react' /*
import { * @Author: yangming@didihu.com.cn yangming@didihu.com.cn
RiEditBoxLine, * @Date: 2025-04-22 09:29:17
RiLayoutRight2Line, * @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn
RiResetLeftLine, * @LastEditTime: 2025-04-22 19:06:23
} from '@remixicon/react' * @FilePath: \glsk-ai-assistant\app\components\base\chat\chat-with-history\header\index.tsx
import { useTranslation } from 'react-i18next' * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
import { */
useChatWithHistoryContext, import { AVATAR_AI_URL } from "@/app/components/base/chat/constants";
} from '../context' type Props = {
import Operation from './operation' avatar: string;
import ActionButton, { ActionButtonState } from '@/app/components/base/action-button' title: string;
import AppIcon from '@/app/components/base/app-icon' };
import Tooltip from '@/app/components/base/tooltip' const Header = ({ avatar, title }: Props) => {
import ViewFormDropdown from '@/app/components/base/chat/chat-with-history/inputs-form/view-form-dropdown'
import Confirm from '@/app/components/base/confirm'
import RenameModal from '@/app/components/base/chat/chat-with-history/sidebar/rename-modal'
import type { ConversationItem } from '@/models/share'
import cn from '@/utils/classnames'
const Header = () => {
const {
appData,
currentConversationId,
currentConversationItem,
inputsForms,
pinnedConversationList,
handlePinConversation,
handleUnpinConversation,
conversationRenaming,
handleRenameConversation,
handleDeleteConversation,
handleNewConversation,
sidebarCollapseState,
handleSidebarCollapse,
isResponding,
} = useChatWithHistoryContext()
const { t } = useTranslation()
const isSidebarCollapsed = sidebarCollapseState
const isPin = pinnedConversationList.some(item => item.id === currentConversationId)
const [showConfirm, setShowConfirm] = useState<ConversationItem | null>(null)
const [showRename, setShowRename] = useState<ConversationItem | null>(null)
const handleOperate = useCallback((type: string) => {
if (type === 'pin')
handlePinConversation(currentConversationId)
if (type === 'unpin')
handleUnpinConversation(currentConversationId)
if (type === 'delete')
setShowConfirm(currentConversationItem as any)
if (type === 'rename')
setShowRename(currentConversationItem as any)
}, [currentConversationId, currentConversationItem, handlePinConversation, handleUnpinConversation])
const handleCancelConfirm = useCallback(() => {
setShowConfirm(null)
}, [])
const handleDelete = useCallback(() => {
if (showConfirm)
handleDeleteConversation(showConfirm.id, { onSuccess: handleCancelConfirm })
}, [showConfirm, handleDeleteConversation, handleCancelConfirm])
const handleCancelRename = useCallback(() => {
setShowRename(null)
}, [])
const handleRename = useCallback((newName: string) => {
if (showRename)
handleRenameConversation(showRename.id, newName, { onSuccess: handleCancelRename })
}, [showRename, handleRenameConversation, handleCancelRename])
return ( return (
<> <div className="flex items-center justify-between h-12 px-8">
<div className='flex h-14 shrink-0 items-center justify-between p-3'> <div className=" flex items-center">
<div className={cn('flex items-center gap-1 transition-all duration-200 ease-in-out', !isSidebarCollapsed && 'user-select-none opacity-0')}> <img
<ActionButton className={cn(!isSidebarCollapsed && 'cursor-default')} size='l' onClick={() => handleSidebarCollapse(false)}> src={AVATAR_AI_URL}
<RiLayoutRight2Line className='h-[18px] w-[18px]' /> className="rounded-full size-8"
</ActionButton> alt="answer icon"
<div className='mr-1 shrink-0'>
<AppIcon
size='large'
iconType={appData?.site.icon_type}
icon={appData?.site.icon}
background={appData?.site.icon_background}
imageUrl={appData?.site.icon_url}
/> />
<span className="ml-2 font-bold">{title}</span>
</div> </div>
{!currentConversationId && ( <img src={avatar} className="rounded-full size-8" alt="answer icon" />
<div className={cn('system-md-semibold grow truncate text-text-secondary')}>{appData?.site.title}</div>
)}
{currentConversationId && currentConversationItem && isSidebarCollapsed && (
<>
<div className='p-1 text-divider-deep'>/</div>
<Operation
title={currentConversationItem?.name || ''}
isPinned={!!isPin}
togglePin={() => handleOperate(isPin ? 'unpin' : 'pin')}
isShowDelete
isShowRenameConversation
onRenameConversation={() => handleOperate('rename')}
onDelete={() => handleOperate('delete')}
/>
</>
)}
<div className='flex items-center px-1'>
<div className='h-[14px] w-px bg-divider-regular'></div>
</div>
{isSidebarCollapsed && (
<Tooltip
disabled={!!currentConversationId}
popupContent={t('share.chat.newChatTip')}
>
<div>
<ActionButton
size='l'
state={(!currentConversationId || isResponding) ? ActionButtonState.Disabled : ActionButtonState.Default}
disabled={!currentConversationId || isResponding}
onClick={handleNewConversation}
>
<RiEditBoxLine className='h-[18px] w-[18px]' />
</ActionButton>
</div>
</Tooltip>
)}
</div>
<div className='flex items-center gap-1'>
{currentConversationId && (
<Tooltip
popupContent={t('share.chat.resetChat')}
>
<ActionButton size='l' onClick={handleNewConversation}>
<RiResetLeftLine className='h-[18px] w-[18px]' />
</ActionButton>
</Tooltip>
)}
{currentConversationId && inputsForms.length > 0 && (
<ViewFormDropdown />
)}
</div> </div>
</div> );
{!!showConfirm && ( };
<Confirm
title={t('share.chat.deleteConversation.title')}
content={t('share.chat.deleteConversation.content') || ''}
isShow
onCancel={handleCancelConfirm}
onConfirm={handleDelete}
/>
)}
{showRename && (
<RenameModal
isShow
onClose={handleCancelRename}
saveLoading={conversationRenaming}
name={showRename?.name || ''}
onSave={handleRename}
/>
)}
</>
)
}
export default Header export default Header;
import type { FC } from 'react' import type { FC } from "react";
import { useEffect, useState } from "react";
import { useAsyncEffect } from "ahooks";
import { useThemeContext } from "../embedded-chatbot/theme/theme-context";
import { ChatWithHistoryContext, useChatWithHistoryContext } from "./context";
import { useChatWithHistory } from "./hooks";
import Header from "./header";
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";
import { import {
useEffect, AVATAR_USER_URL,
useState, AVATAR_AI_URL,
} from 'react' MAIN_TITLE,
import { useAsyncEffect } from 'ahooks' } from "@/app/components/base/chat/constants";
import { useThemeContext } from '../embedded-chatbot/theme/theme-context'
import {
ChatWithHistoryContext,
useChatWithHistoryContext,
} from './context'
import { useChatWithHistory } from './hooks'
import Sidebar from './sidebar'
import Header from './header'
import HeaderInMobile from './header-in-mobile'
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 = { type ChatWithHistoryProps = {
className?: string className?: string;
} };
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ type urlProps = {
className, avatar?: string; // 头像
}) => { business_type?: string; // 业务类型
brand?: string; // 品牌
one_id?: string; // 唯一标识
queryType?: string; //问题类型
position?: string; // 岗位
platformType?: string; // 平台类型
};
// 获取地址栏参数
const getQueryParams = function (): urlProps {
const urlParams = new URLSearchParams(globalThis.location?.search);
const avatar = urlParams.get("avatar") ?? AVATAR_USER_URL;
const paramsObject = Object.fromEntries(urlParams.entries());
return {
...paramsObject,
avatar,
};
};
const newInputs = getQueryParams();
newInputs.queryType = '0'
const avatar: string = newInputs.avatar!;
console.log(newInputs, 22);
delete newInputs.avatar;
const ChatWithHistory: FC<ChatWithHistoryProps> = ({ className }) => {
const { const {
appInfoError, appInfoError,
appData, appData,
...@@ -35,91 +55,69 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({ ...@@ -35,91 +55,69 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = ({
chatShouldReloadKey, chatShouldReloadKey,
isMobile, isMobile,
themeBuilder, themeBuilder,
sidebarCollapseState, } = useChatWithHistoryContext();
} = useChatWithHistoryContext() const customConfig = appData?.custom_config;
const isSidebarCollapsed = sidebarCollapseState const site = appData?.site; // 替换 'paramName' 为实际的参数名
const customConfig = appData?.custom_config
const site = appData?.site
const [showSidePanel, setShowSidePanel] = useState(false)
useEffect(() => { useEffect(() => {
themeBuilder?.buildTheme(site?.chat_color_theme, site?.chat_color_theme_inverted) 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 document.title = `${site.title} - Powered by Dify`;
else
document.title = `${site.title} - Powered by Dify`
} }
}, [site, customConfig, themeBuilder]) }, [site, customConfig, themeBuilder]);
if (appInfoLoading) { if (appInfoLoading) {
return ( return <Loading type="app" />;
<Loading type='app' />
)
} }
if (appInfoError) { if (appInfoError) {
return ( return <AppUnavailable />;
<AppUnavailable />
)
} }
return ( 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',
)}>
<Sidebar />
</div>
)}
{isMobile && (
<HeaderInMobile />
)}
<div className={cn('relative grow p-2', isMobile && 'h-[calc(100%_-_56px)] p-0')}>
{isSidebarCollapsed && (
<div <div
className={cn( className={cn(
'absolute top-0 z-20 flex h-full w-[256px] flex-col p-2 transition-all duration-500 ease-in-out', "flex h-full bg-background-default-burn",
showSidePanel ? 'left-0' : 'left-[-248px]', isMobile && "flex-col",
className
)} )}
onMouseEnter={() => setShowSidePanel(true)}
onMouseLeave={() => setShowSidePanel(false)}
> >
<Sidebar isPanel /> <div
</div> className={cn("relative grow", isMobile && "h-[calc(100%_-_56px)] p-0")}
)} >
<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')}> <div
{!isMobile && <Header />} className={cn(
{appChatListDataLoading && ( "flex h-full flex-col overflow-hidden border-components-panel-border-subtle chat-panel-bg"
<Loading type='app' />
)} )}
>
<Header avatar={avatar} title={MAIN_TITLE} />
{!appChatListDataLoading && ( {!appChatListDataLoading && (
<ChatWrapper key={chatShouldReloadKey} /> <ChatWrapper
key={chatShouldReloadKey}
avatar={avatar}
aiAvatar={AVATAR_AI_URL}
/>
)} )}
</div> </div>
</div> </div>
</div> </div>
) );
} };
export type ChatWithHistoryWrapProps = { export type ChatWithHistoryWrapProps = {
installedAppInfo?: InstalledApp installedAppInfo?: InstalledApp;
className?: string className?: string;
} };
const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
installedAppInfo, installedAppInfo,
className, className,
}) => { }) => {
const media = useBreakpoints() const media = useBreakpoints();
const isMobile = media === MediaType.mobile const isMobile = media === MediaType.mobile;
const themeBuilder = useThemeContext() const themeBuilder = useThemeContext();
const { const {
appInfoError, appInfoError,
...@@ -159,10 +157,18 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({ ...@@ -159,10 +157,18 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
setIsResponding, setIsResponding,
currentConversationInputs, currentConversationInputs,
setCurrentConversationInputs, setCurrentConversationInputs,
} = useChatWithHistory(installedAppInfo) } = useChatWithHistory(installedAppInfo);
useEffect(() => {
//新建对话
handleNewConversation();
setTimeout(() => {
console.log(newInputs,88);
handleNewConversationInputsChange(newInputs);
}, 1000);
}, []);
return ( return (
<ChatWithHistoryContext.Provider value={{ <ChatWithHistoryContext.Provider
value={{
appInfoError, appInfoError,
appInfoLoading, appInfoLoading,
appData, appData,
...@@ -202,52 +208,50 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({ ...@@ -202,52 +208,50 @@ const ChatWithHistoryWrap: FC<ChatWithHistoryWrapProps> = ({
setIsResponding, setIsResponding,
currentConversationInputs, currentConversationInputs,
setCurrentConversationInputs, setCurrentConversationInputs,
}}> }}
>
<ChatWithHistory className={className} /> <ChatWithHistory className={className} />
</ChatWithHistoryContext.Provider> </ChatWithHistoryContext.Provider>
) );
} };
const ChatWithHistoryWrapWithCheckToken: FC<ChatWithHistoryWrapProps> = ({ const ChatWithHistoryWrapWithCheckToken: FC<ChatWithHistoryWrapProps> = ({
installedAppInfo, installedAppInfo,
className, className,
}) => { }) => {
const [initialized, setInitialized] = useState(false) const [initialized, setInitialized] = useState(false);
const [appUnavailable, setAppUnavailable] = useState<boolean>(false) const [appUnavailable, setAppUnavailable] = useState<boolean>(false);
const [isUnknownReason, setIsUnknownReason] = useState<boolean>(false) const [isUnknownReason, setIsUnknownReason] = useState<boolean>(false);
useAsyncEffect(async () => { useAsyncEffect(async () => {
if (!initialized) { if (!initialized) {
if (!installedAppInfo) { if (!installedAppInfo) {
try { try {
await checkOrSetAccessToken() await checkOrSetAccessToken();
} } catch (e: any) {
catch (e: any) {
if (e.status === 404) { if (e.status === 404) {
setAppUnavailable(true) setAppUnavailable(true);
} } else {
else { setIsUnknownReason(true);
setIsUnknownReason(true) setAppUnavailable(true);
setAppUnavailable(true)
} }
} }
} }
setInitialized(true) setInitialized(true);
} }
}, []) }, []);
if (!initialized) if (!initialized) return null;
return null
if (appUnavailable) if (appUnavailable)
return <AppUnavailable isUnknownReason={isUnknownReason} /> return <AppUnavailable isUnknownReason={isUnknownReason} />;
return ( return (
<ChatWithHistoryWrap <ChatWithHistoryWrap
installedAppInfo={installedAppInfo} installedAppInfo={installedAppInfo}
className={className} className={className}
/> />
) );
} };
export default ChatWithHistoryWrapWithCheckToken export default ChatWithHistoryWrapWithCheckToken;
...@@ -4,7 +4,7 @@ import type { ChatItem } from '../../types' ...@@ -4,7 +4,7 @@ import type { ChatItem } from '../../types'
import { useChatContext } from '../context' import { useChatContext } from '../context'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
import {AUTO_INPUT} from "@/app/components/base/chat/constants";
type SuggestedQuestionsProps = { type SuggestedQuestionsProps = {
item: ChatItem item: ChatItem
} }
...@@ -17,11 +17,9 @@ const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({ ...@@ -17,11 +17,9 @@ const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({
const klassName = `mr-1 mt-1 ${isMobile ? 'block overflow-hidden text-ellipsis' : ''} max-w-full shrink-0 last:mr-0` const klassName = `mr-1 mt-1 ${isMobile ? 'block overflow-hidden text-ellipsis' : ''} max-w-full shrink-0 last:mr-0`
const { const {
isOpeningStatement,
suggestedQuestions, suggestedQuestions,
} = item } = item
if (!suggestedQuestions?.length)
if (!isOpeningStatement || !suggestedQuestions?.length)
return null return null
return ( return (
...@@ -31,7 +29,7 @@ const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({ ...@@ -31,7 +29,7 @@ const SuggestedQuestions: FC<SuggestedQuestionsProps> = ({
key={index} key={index}
variant='secondary-accent' variant='secondary-accent'
className={klassName} className={klassName}
onClick={() => onSend?.(question)} onClick={() => onSend?.({message:question,type:AUTO_INPUT})}
> >
{question} {question}
</Button>), </Button>),
......
import { memo } from 'react' import { memo } from "react";
import { import { RiMicLine, RiSendPlane2Fill } from "@remixicon/react";
RiMicLine, import type { EnableType } from "../../types";
RiSendPlane2Fill, import type { Theme } from "../../embedded-chatbot/theme/theme-context";
} from '@remixicon/react' import Button from "@/app/components/base/button";
import type { import ActionButton from "@/app/components/base/action-button";
EnableType, import { FileUploaderInChatInput } from "@/app/components/base/file-uploader";
} from '../../types' import type { FileUpload } from "@/app/components/base/features/types";
import type { Theme } from '../../embedded-chatbot/theme/theme-context' import cn from "@/utils/classnames";
import Button from '@/app/components/base/button'
import ActionButton from '@/app/components/base/action-button'
import { FileUploaderInChatInput } from '@/app/components/base/file-uploader'
import type { FileUpload } from '@/app/components/base/features/types'
import cn from '@/utils/classnames'
type OperationProps = { type OperationProps = {
fileConfig?: FileUpload fileConfig?: FileUpload;
speechToTextConfig?: EnableType speechToTextConfig?: EnableType;
onShowVoiceInput?: () => void onShowVoiceInput?: () => void;
onSend: () => void onSend: () => void;
theme?: Theme | null theme?: Theme | null;
} };
const Operation = ( const Operation = ({
{
ref, ref,
fileConfig, fileConfig,
speechToTextConfig, speechToTextConfig,
onShowVoiceInput, onShowVoiceInput,
onSend, onSend,
theme, theme,
}: OperationProps & { }: OperationProps & {
ref: React.RefObject<HTMLDivElement>; ref: React.RefObject<HTMLDivElement>;
}, }) => {
) => {
return ( return (
<div <div className={cn("flex shrink-0 items-center justify-end")}>
className={cn( <div className="flex items-center pl-1" ref={ref}>
'flex shrink-0 items-center justify-end', {/* <div className='flex items-center space-x-1'>
)}
>
<div
className='flex items-center pl-1'
ref={ref}
>
<div className='flex items-center space-x-1'>
{fileConfig?.enabled && <FileUploaderInChatInput fileConfig={fileConfig} />} {fileConfig?.enabled && <FileUploaderInChatInput fileConfig={fileConfig} />}
{ {
speechToTextConfig?.enabled && ( speechToTextConfig?.enabled && (
...@@ -54,10 +40,10 @@ const Operation = ( ...@@ -54,10 +40,10 @@ const Operation = (
</ActionButton> </ActionButton>
) )
} }
</div> </div> */}
<Button <Button
className='ml-3 w-8 px-0' className="ml-3 w-8 px-0"
variant='primary' variant="primary"
onClick={onSend} onClick={onSend}
style={ style={
theme theme
...@@ -67,12 +53,12 @@ const Operation = ( ...@@ -67,12 +53,12 @@ const Operation = (
: {} : {}
} }
> >
<RiSendPlane2Fill className='h-4 w-4' /> <RiSendPlane2Fill className="h-4 w-4" />
</Button> </Button>
</div> </div>
</div> </div>
) );
} };
Operation.displayName = 'Operation' Operation.displayName = "Operation";
export default memo(Operation) export default memo(Operation);
import type { import type { FC, ReactNode } from "react";
FC, import { memo } from "react";
ReactNode, import type { ChatItem } from "../types";
} from 'react' import type { Theme } from "../embedded-chatbot/theme/theme-context";
import { import { CssTransform } from "../embedded-chatbot/theme/utils";
memo, import { User } from "@/app/components/base/icons/src/public/avatar";
} from 'react' import { Markdown } from "@/app/components/base/markdown";
import type { ChatItem } from '../types' import { FileList } from "@/app/components/base/file-uploader";
import type { Theme } from '../embedded-chatbot/theme/theme-context'
import { CssTransform } from '../embedded-chatbot/theme/utils'
import { User } from '@/app/components/base/icons/src/public/avatar'
import { Markdown } from '@/app/components/base/markdown'
import { FileList } from '@/app/components/base/file-uploader'
type QuestionProps = { type QuestionProps = {
item: ChatItem item: ChatItem;
questionIcon?: ReactNode questionIcon?: ReactNode;
theme: Theme | null | undefined theme: Theme | null | undefined;
} };
const Question: FC<QuestionProps> = ({ const Question: FC<QuestionProps> = ({ item, questionIcon, theme }) => {
item, const { content, message_files } = item;
questionIcon,
theme,
}) => {
const {
content,
message_files,
} = item
return ( return (
<div className='mb-2 flex justify-end pl-14 last:mb-0'> <div className="mb-2 flex justify-end pl-14 last:mb-0">
<div className='group relative mr-4 max-w-full'> <div className="group relative mr-4 max-w-full">
<div <div
className='rounded-2xl bg-[#D1E9FF]/50 px-4 py-3 text-sm text-gray-900' className="rounded-2xl bg-[#D1E9FF]/50 px-4 py-3 text-sm text-gray-900"
style={theme?.chatBubbleColorStyle ? CssTransform(theme.chatBubbleColorStyle) : {}} style={
theme?.chatBubbleColorStyle
? CssTransform(theme.chatBubbleColorStyle)
: {}
}
> >
{ {!!message_files?.length && (
!!message_files?.length && (
<FileList <FileList
files={message_files} files={message_files}
showDeleteAction={false} showDeleteAction={false}
showDownloadAction={true} showDownloadAction={true}
/> />
) )}
}
<Markdown content={content} /> <Markdown content={content} />
</div> </div>
<div className='mt-1 h-[18px]' /> <div className="mt-1 h-[18px]" />
</div>
<div className='h-10 w-10 shrink-0'>
{
questionIcon || (
<div className='h-full w-full rounded-full border-[0.5px] border-black/5'>
<User className='h-full w-full' />
</div>
)
}
</div> </div>
<div className="h-10 w-10 shrink-0">{questionIcon}</div>
</div> </div>
) );
} };
export default memo(Question) export default memo(Question);
export const CONVERSATION_ID_INFO = 'conversationIdInfo' export const CONVERSATION_ID_INFO = "conversationIdInfo";
export const UUID_NIL = '00000000-0000-0000-0000-000000000000' export const UUID_NIL = "00000000-0000-0000-0000-000000000000";
export const AVATAR_AI_URL =
"https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-avatar.png";
export const AVATAR_USER_URL =
"https://img02.glsx.com.cn/weapp/resource/saas/ai/user-avatar.png";
export const MAIN_TITLE = "广联AI集市";
export const SELF_INPUT = "0";
export const AUTO_INPUT = "1";
...@@ -68,10 +68,13 @@ export type ChatItem = IChatItem & { ...@@ -68,10 +68,13 @@ export type ChatItem = IChatItem & {
export type ChatItemInTree = { export type ChatItemInTree = {
children?: ChatItemInTree[] children?: ChatItemInTree[]
} & ChatItem } & ChatItem
export type messageProp = {
message:string
type:string
}
export type OnSend = { export type OnSend = {
(message: string, files?: FileEntity[]): void (message: messageProp, files?: FileEntity[]): void
(message: string, files: FileEntity[] | undefined, isRegenerate: boolean, lastAnswer?: ChatItem | null): void (message: messageProp, files: FileEntity[] | undefined, isRegenerate: boolean, lastAnswer?: ChatItem | null): void
} }
export type OnRegenerate = (chatItem: ChatItem) => void export type OnRegenerate = (chatItem: ChatItem) => void
......
...@@ -735,5 +735,9 @@ html[data-theme="dark"] { ...@@ -735,5 +735,9 @@ html[data-theme="dark"] {
--color-saas-background: #0b0b0e; --color-saas-background: #0b0b0e;
--color-saas-pricing-grid-bg: #c8ceda33; --color-saas-pricing-grid-bg: #c8ceda33;
.chat-panel-bg {
background:
url("https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-bg.png") top / 100% 240px no-repeat,
#f5f9ff 0 240px / 100% calc(100% - 240px) no-repeat;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -735,5 +735,9 @@ html[data-theme="light"] { ...@@ -735,5 +735,9 @@ html[data-theme="light"] {
--color-saas-background: #fcfcfd; --color-saas-background: #fcfcfd;
--color-saas-pricing-grid-bg: #c8ceda80; --color-saas-pricing-grid-bg: #c8ceda80;
.chat-panel-bg {
background:
url("https://img02.glsx.com.cn/weapp/resource/saas/ai/ai-bg.png") top / 100% 240px no-repeat,
#f5f9ff 0 240px / 100% calc(100% - 240px) no-repeat;
}
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!