Commit d6af94d7 by liimin

refactor(base): 优化聊天组件样式和布局

- 移除 ChatWithHistory 组件的重复样式
- 注释掉 Answer 组件中的部分代码
- 调整 Footer 组件的导入结构
- 优化 FileList 组件的 props 传递
- 简化 Operation 组件的代码
- 调整 Question 组件的样式
- 更新 layout.tsx 中的 theme-color 和 body 类名
- 添加 chat-panel-bg 类样式
- 更新 dark 和 light 主题中的 chat-panel-bg 样式
1 parent 2d6441dd
...@@ -17,9 +17,9 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = React.memo(() => { ...@@ -17,9 +17,9 @@ const ChatWithHistory: FC<ChatWithHistoryProps> = React.memo(() => {
const isMobile = useBreakpoints() === MediaType.mobile const isMobile = useBreakpoints() === MediaType.mobile
const { presuppositionProblem, isShowPracticeButton, inputs } = useUrlParams() const { presuppositionProblem, isShowPracticeButton, inputs } = useUrlParams()
return ( return (
<div className={cn('flex h-full bg-background-default-burn', isMobile && 'flex-col')}> <div className={cn('flex h-full', isMobile && 'flex-col')}>
<div className={cn('relative grow', isMobile && 'h-[calc(100%_-_56px)] p-0')}> <div className={cn('relative grow', isMobile && 'h-[calc(100%_-_56px)] p-0')}>
<div className={cn('flex h-full flex-col overflow-hidden border-components-panel-border-subtle chat-panel-bg')}> <div className={cn('flex h-full flex-col overflow-hidden border-components-panel-border-subtle ')}>
<ChatWrapper <ChatWrapper
presuppositionQuestion={presuppositionProblem} presuppositionQuestion={presuppositionProblem}
isShowPracticeButton={isShowPracticeButton} isShowPracticeButton={isShowPracticeButton}
......
...@@ -131,13 +131,13 @@ const Answer: FC<AnswerProps> = ({ ...@@ -131,13 +131,13 @@ const Answer: FC<AnswerProps> = ({
</div> </div>
)} )}
{content && !hasAgentThoughts && <BasicContent item={item}/>} {content && !hasAgentThoughts && <BasicContent item={item}/>}
{hasAgentThoughts && <AgentContent item={item} responding={responding} content={content} />} {/* {hasAgentThoughts && <AgentContent item={item} responding={responding} content={content} />} */}
{!!allFiles?.length && ( {/* {!!allFiles?.length && (
<FileList className="my-1" files={allFiles} showDeleteAction={false} showDownloadAction canPreview /> <FileList className="my-1" files={allFiles} showDeleteAction={false} showDownloadAction canPreview />
)} )}
{!!message_files?.length && ( {!!message_files?.length && (
<FileList className="my-1" files={message_files} showDeleteAction={false} showDownloadAction canPreview /> <FileList className="my-1" files={message_files} showDeleteAction={false} showDownloadAction canPreview />
)} )} */}
{/* {annotation?.id && annotation.authorName && ( {/* {annotation?.id && annotation.authorName && (
<EditTitle <EditTitle
className="mt-1" className="mt-1"
...@@ -147,9 +147,9 @@ const Answer: FC<AnswerProps> = ({ ...@@ -147,9 +147,9 @@ const Answer: FC<AnswerProps> = ({
/> />
)} */} )} */}
{/* <SuggestedQuestions item={item} /> */} {/* <SuggestedQuestions item={item} /> */}
{!!citation?.length && !responding && ( {/* {!!citation?.length && !responding && (
<Citation data={citation} showHitInfo={config?.supportCitationHitInfo} /> <Citation data={citation} showHitInfo={config?.supportCitationHitInfo} />
)} )} */}
{/* {item.siblingCount && item.siblingCount > 1 && item.siblingIndex !== undefined && ( {/* {item.siblingCount && item.siblingCount > 1 && item.siblingIndex !== undefined && (
<div className="flex items-center justify-center pt-3.5 text-sm"> <div className="flex items-center justify-center pt-3.5 text-sm">
<button className={`${item.prevSibling ? 'opacity-100' : 'opacity-30'}`} disabled={!item.prevSibling} onClick={() => item.prevSibling && switchSibling?.(item.prevSibling)}> <button className={`${item.prevSibling ? 'opacity-100' : 'opacity-30'}`} disabled={!item.prevSibling} onClick={() => item.prevSibling && switchSibling?.(item.prevSibling)}>
......
...@@ -26,7 +26,7 @@ type OperationProps = { ...@@ -26,7 +26,7 @@ type OperationProps = {
const Operation: FC<OperationProps> = ({ item, isLast, question, index, showPromptLog, maxSize, contentWidth, hasWorkflowProcess, noChatInput }) => { const Operation: FC<OperationProps> = ({ item, isLast, question, index, showPromptLog, maxSize, contentWidth, hasWorkflowProcess, noChatInput }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { config, onFeedback, onSend:sendMessage,onRegenerate } = useChatContext() const { config, onFeedback,onRegenerate } = useChatContext()
// const [config,onFeedback,sendMessage,onRegenerate] = useChatStore(state => [state.config,state.handleFeedback,state.sendMessage,state.doRegenerate]) // const [config,onFeedback,sendMessage,onRegenerate] = useChatStore(state => [state.config,state.handleFeedback,state.sendMessage,state.doRegenerate])
const [isShowReplyModal, setIsShowReplyModal] = useState(false) const [isShowReplyModal, setIsShowReplyModal] = useState(false)
const [showLike, setShowLike] = useState(false) const [showLike, setShowLike] = useState(false)
...@@ -45,7 +45,6 @@ const Operation: FC<OperationProps> = ({ item, isLast, question, index, showProm ...@@ -45,7 +45,6 @@ const Operation: FC<OperationProps> = ({ item, isLast, question, index, showProm
// 判断是否已点赞 // 判断是否已点赞
const feedbackActive = useMemo(() => config?.supportFeedback && localFeedback?.rating && !isOpeningStatement, [config?.supportFeedback, localFeedback?.rating, onFeedback, isOpeningStatement]) const feedbackActive = useMemo(() => config?.supportFeedback && localFeedback?.rating && !isOpeningStatement, [config?.supportFeedback, localFeedback?.rating, onFeedback, isOpeningStatement])
// 处理反馈 // 处理反馈
const handleFeedback = async (rating: 'like' | 'dislike' | null) => { const handleFeedback = async (rating: 'like' | 'dislike' | null) => {
if (!config?.supportFeedback || !onFeedback || showLike) return if (!config?.supportFeedback || !onFeedback || showLike) return
......
import React, { FC, memo, useMemo} from 'react' import React, { FC, memo, useMemo} from 'react'
import { useTranslation } from 'react-i18next'
import type { ChatConfig, OnSend } from '@/app/components/base/chat/types'
import type { ThemeBuilder } from '@/app/components/base/chat/embedded-chatbot/theme/theme-context'
import type { InputForm } from '@/app/components/base/chat/chat/type'
import TryToAsk from './try-to-ask' import TryToAsk from './try-to-ask'
import Practice from './practice'
// import ChatInputArea from '../chat-input-area'
import ChatInput from './input' import ChatInput from './input'
import StopResponding from './stopResponding' import StopResponding from './stopResponding'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useChatContext } from '../context'
import { useChatStore } from '@/app/components/base/chat/chat-with-history/store'
import { state } from 'mermaid/dist/rendering-util/rendering-elements/shapes/state'
type FooterProps = { type FooterProps = {
chatFooterClassName?: string chatFooterClassName?: string
chatFooterInnerClassName?: string chatFooterInnerClassName?: string
......
...@@ -3,7 +3,6 @@ import { FileListInChatInput } from '@/app/components/base/file-uploader' ...@@ -3,7 +3,6 @@ import { FileListInChatInput } from '@/app/components/base/file-uploader'
import { useChatContext } from '@/app/components/base/chat/chat/context' import { useChatContext } from '@/app/components/base/chat/chat/context'
const FileList: FC = () => { const FileList: FC = () => {
const { config } = useChatContext() const { config } = useChatContext()
const visionConfig = config.file_upload return <FileListInChatInput fileConfig={config.file_upload} />
return <FileListInChatInput fileConfig={visionConfig!} />
} }
export default memo(FileList) export default memo(FileList)
...@@ -7,7 +7,6 @@ import Send from './send' ...@@ -7,7 +7,6 @@ import Send from './send'
import { useTextAreaHeightContext } from '../input/context' import { useTextAreaHeightContext } from '../input/context'
const Operation: FC = () => { const Operation: FC = () => {
const { holdSpaceRef } = useTextAreaHeightContext() const { holdSpaceRef } = useTextAreaHeightContext()
return ( return (
<div className={cn('flex shrink-0 items-center justify-end')}> <div className={cn('flex shrink-0 items-center justify-end')}>
<ReStart /> <ReStart />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn * @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:17 * @Date: 2025-04-22 09:29:17
* @LastEditors: limin * @LastEditors: limin
* @LastEditTime: 2025-06-26 10:20:23 * @LastEditTime: 2025-07-11 20:31:55
* @FilePath: \ai-assistant\app\components\base\chat\chat\question.tsx * @FilePath: \ai-assistant\app\components\base\chat\chat\question.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -26,7 +26,7 @@ const Question: FC<QuestionProps> = ({ item, questionIcon, theme }) => { ...@@ -26,7 +26,7 @@ const Question: FC<QuestionProps> = ({ item, questionIcon, theme }) => {
<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 className="rounded-2xl bg-[#D1E9FF]/50 px-4 py-3 text-sm text-gray-900" style={theme?.chatBubbleColorStyle ? CssTransform(theme?.chatBubbleColorStyle) : {}}> <div className="rounded-2xl bg-[#D1E9FF]/50 px-4 py-3 text-sm text-gray-900" style={theme?.chatBubbleColorStyle ? CssTransform(theme?.chatBubbleColorStyle) : {}}>
{!!message_files?.length && <FileList files={message_files} showDeleteAction={false} showDownloadAction={true} />} {/* {!!message_files?.length && <FileList files={message_files} showDeleteAction={false} showDownloadAction={true} />} */}
<Markdown content={content} /> <Markdown content={content} />
</div> </div>
<div className="mt-1 h-[8px]" /> <div className="mt-1 h-[8px]" />
......
/* /*
* @Author: yangming@didihu.com.cn yangming@didihu.com.cn * @Author: yangming@didihu.com.cn yangming@didihu.com.cn
* @Date: 2025-04-22 09:29:21 * @Date: 2025-04-22 09:29:21
* @LastEditors: yangming@didihu.com.cn yangming@didihu.com.cn * @LastEditors: limin
* @LastEditTime: 2025-04-27 10:09:19 * @LastEditTime: 2025-07-11 19:40:08
* @FilePath: \glsk-ai-assistant\app\layout.tsx * @FilePath: \ai-assistant\app\layout.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
import type { Viewport } from "next"; import type { Viewport } from "next";
...@@ -34,13 +34,13 @@ const LocaleLayout = async ({ children }: { children: React.ReactNode }) => { ...@@ -34,13 +34,13 @@ const LocaleLayout = async ({ children }: { children: React.ReactNode }) => {
return ( return (
<html lang={locale ?? "en"} className="h-full" suppressHydrationWarning> <html lang={locale ?? "en"} className="h-full" suppressHydrationWarning>
<head> <head>
<meta name="theme-color" content="#FFFFFF" /> <meta name="theme-color" content="#ffffff" />
<meta name="mobile-web-app-capable" content="yes" /> <meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" /> <meta name="apple-mobile-web-app-status-bar-style" content="default" />
</head> </head>
<body <body
className="color-scheme h-full select-auto" className="color-scheme h-full select-auto chat-panel-bg"
data-api-prefix={process.env.NEXT_PUBLIC_API_PREFIX} data-api-prefix={process.env.NEXT_PUBLIC_API_PREFIX}
data-pubic-api-prefix={process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX} data-pubic-api-prefix={process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX}
data-marketplace-api-prefix={ data-marketplace-api-prefix={
......
...@@ -18,7 +18,6 @@ html[data-theme='dark'] { ...@@ -18,7 +18,6 @@ html[data-theme='dark'] {
html[data-changing-theme] * { html[data-changing-theme] * {
transition: none !important; transition: none !important;
} }
:root { :root {
--max-width: 1100px; --max-width: 1100px;
--border-radius: 12px; --border-radius: 12px;
...@@ -647,6 +646,7 @@ button:focus-within { ...@@ -647,6 +646,7 @@ button:focus-within {
border-radius: 64px; border-radius: 64px;
} }
/* border radius end */ /* border radius end */
.link { .link {
...@@ -661,6 +661,7 @@ button:focus-within { ...@@ -661,6 +661,7 @@ button:focus-within {
text-fill-color: transparent; text-fill-color: transparent;
} }
/* overwrite paging active dark model style */ /* overwrite paging active dark model style */
[class*="style_paginatio"] li .text-primary-600 { [class*="style_paginatio"] li .text-primary-600 {
color: rgb(28 100 242); color: rgb(28 100 242);
...@@ -698,3 +699,6 @@ button:focus-within { ...@@ -698,3 +699,6 @@ button:focus-within {
scrollbar-width: none; scrollbar-width: none;
} }
} }
.chat-panel-bg {
background-color: #f5f9ff;
}
\ No newline at end of file \ No newline at end of file
...@@ -735,7 +735,4 @@ html[data-theme="dark"] { ...@@ -735,7 +735,4 @@ 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-color: #f5f9ff;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -735,7 +735,4 @@ html[data-theme="light"] { ...@@ -735,7 +735,4 @@ 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-color: #f5f9ff;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!