Commit 3e47fdd2 by 李伟康

style(chat): 统一聊天界面底部间距样式

- 将多个组件中的 mb-2 和 mb-4 替换为统一的 MB-12 样式类
- 在全局样式中添加 MB-12 类定义,设置底部间距为 12px
- 更新 Answer、Question 和 InitQuestions 组件的间距类名
- 修复 Report 组件中 iframe 消息通信的 ID 匹配逻辑
- 添加 UUID 用于区分不同 Report 组件实例的消息
- 调整 Think 组件内容区域顶部内边距
- 优化 Footer 组件使用模块化样式类
- 重命名 Confirm 组件内容容器类名以避免冲突
1 parent 4b6960fc
...@@ -45,8 +45,8 @@ const Answer: FC<AnswerProps> = ({ chatAnswerContainerInner }) => { ...@@ -45,8 +45,8 @@ const Answer: FC<AnswerProps> = ({ chatAnswerContainerInner }) => {
return ( return (
<> <>
<div className="mb-2 flex last:mb-0"> <div className="MB-12 flex last:mb-0">
<div className="chat-answer-container group w-0 grow pb-2" ref={containerRef}> <div className="chat-answer-container group w-0 grow" ref={containerRef}>
{/* <LoadingAvatar /> */} {/* <LoadingAvatar /> */}
<div className={cn('group relative', chatAnswerContainerInner)}> <div className={cn('group relative', chatAnswerContainerInner)}>
<div <div
......
.footer-mask{ .footer-mask{
padding-top: 8px; padding-top: 8px;
background: linear-gradient(180deg, rgba(237, 240, 255, 0.00) 0%, #E9F2FE 10.11%, #E8F2FE 100%); background: linear-gradient(180deg, rgba(237, 240, 255, 0.00) 0%, #E9F2FE 10.11%, #E8F2FE 100%);
}
.footer-box{
gap: 12px;
} }
\ No newline at end of file \ No newline at end of file
import React, { FC, memo, useMemo } from 'react' import React, { FC, memo, useMemo } from 'react'
import TryToAsk from './components/try-to-ask'
import ChatInput from './components/input' import ChatInput from './components/input'
import StopResponding from './components/stopResponding'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import ReStart from './components/operation/restart' import ReStart from './components/operation/restart'
import Setting from './components/operation/setting' import Setting from './components/operation/setting'
...@@ -22,7 +20,7 @@ const Footer: FC<FooterProps> = ({ isMobile, chatFooterRef, chatFooterInnerRef } ...@@ -22,7 +20,7 @@ const Footer: FC<FooterProps> = ({ isMobile, chatFooterRef, chatFooterInnerRef }
<div <div
ref={chatFooterInnerRef} ref={chatFooterInnerRef}
className={cn('relative', `mx-auto w-full max-w-[800px] ${isMobile ? 'px-2' : 'px-4'}`)}> className={cn('relative', `mx-auto w-full max-w-[800px] ${isMobile ? 'px-2' : 'px-4'}`)}>
<div className="mb-2 flex items-center relative h-8 gap-4"> <div className={cn('mb-2 flex items-center relative h-8', s['footer-box'])}>
<ReStart /> <ReStart />
<Setting /> <Setting />
{/* {isShowPracticeButton && <Practice />} */} {/* {isShowPracticeButton && <Practice />} */}
......
...@@ -53,7 +53,7 @@ const InitQuestions: FC = () => { ...@@ -53,7 +53,7 @@ const InitQuestions: FC = () => {
return useMemo(() => { return useMemo(() => {
return ( return (
<div className={cn('mb-4 flex last:mb-0', s['suggested-questions-box'])}> <div className={cn('MB-12 flex last:mb-0', s['suggested-questions-box'])}>
{/* <div className="relative h-10 w-10 shrink-0">{<AnswerIcon />}</div> */} {/* <div className="relative h-10 w-10 shrink-0">{<AnswerIcon />}</div> */}
<img src={AI_TIPS} alt="AI Tips" className={cn(s['suggested-questions-title'])} /> <img src={AI_TIPS} alt="AI Tips" className={cn(s['suggested-questions-title'])} />
<div className={cn(s['suggested-questions-list'], 'group w-0 grow')}> <div className={cn(s['suggested-questions-list'], 'group w-0 grow')}>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
border-radius: 16px; border-radius: 16px;
overflow: hidden; overflow: hidden;
flex-direction: column; flex-direction: column;
margin-bottom: 12px;
} }
.suggested-questions-title { .suggested-questions-title {
......
...@@ -17,7 +17,7 @@ import cn from '@/utils/classnames' ...@@ -17,7 +17,7 @@ import cn from '@/utils/classnames'
const Question: FC = () => { const Question: FC = () => {
const { content, theme } = useChatBodyContext() const { content, theme } = useChatBodyContext()
return ( return (
<div className="mb-4 flex justify-end pl-14 last:mb-0"> <div className="MB-12 flex justify-end pl-14 last:mb-0">
<div className={cn('group', 'relative', 'max-w-full')}> <div className={cn('group', 'relative', 'max-w-full')}>
<div <div
className={cn('rounded-br-none bg-[#3773F8] px-3 py-2 text-sm text-gray-900', s['question-boder'])} className={cn('rounded-br-none bg-[#3773F8] px-3 py-2 text-sm text-gray-900', s['question-boder'])}
......
.confirm-content{ .confirm-content-box{
background: linear-gradient(180deg, #EDF5FF 0%, #FFFFFF 100%); background: linear-gradient(180deg, #EDF5FF 0%, #FFFFFF 100%);
border-radius: 18px; border-radius: 18px;
color: #133368; color: #133368;
......
...@@ -91,7 +91,7 @@ function Confirm({ ...@@ -91,7 +91,7 @@ function Confirm({
e.stopPropagation() e.stopPropagation()
}}> }}>
<div ref={dialogRef} className={'relative w-[80%] max-w-[480px] overflow-hidden'}> <div ref={dialogRef} className={'relative w-[80%] max-w-[480px] overflow-hidden'}>
<div className={cn('shadows-shadow-lg flex max-w-full flex-col items-start rounded-2xl border-[0.5px] border-solid border-components-panel-border bg-components-panel-bg', s['confirm-content'])}> <div className={cn('shadows-shadow-lg flex max-w-full flex-col items-start rounded-2xl border-[0.5px] border-solid border-components-panel-border bg-components-panel-bg', s['confirm-content-box'])}>
<div className='flex flex-col items-start gap-2 self-stretch'> <div className='flex flex-col items-start gap-2 self-stretch'>
<div className={cn('title-2xl-semi-bold text-text-primary', s['confirm-title'])}>{title}</div> <div className={cn('title-2xl-semi-bold text-text-primary', s['confirm-title'])}>{title}</div>
<div className={cn('system-md-regular w-full text-text-tertiary', s['confirm-content'])}>{content}</div> <div className={cn('system-md-regular w-full text-text-tertiary', s['confirm-content'])}>{content}</div>
......
...@@ -5,6 +5,7 @@ import cn from '@/utils/classnames' ...@@ -5,6 +5,7 @@ import cn from '@/utils/classnames'
import s from './index.module.scss' import s from './index.module.scss'
import Toast from '@/app/components/base/toast' import Toast from '@/app/components/base/toast'
import { GET_PARAMS } from '@/app/components/base/chat/constants' import { GET_PARAMS } from '@/app/components/base/chat/constants'
import { v4 as uuidv4 } from 'uuid'
type ReportProps = { type ReportProps = {
content: any | null content: any | null
...@@ -18,6 +19,7 @@ const Report: FC<ReportProps> = ({ content }) => { ...@@ -18,6 +19,7 @@ const Report: FC<ReportProps> = ({ content }) => {
const iframeRef = useRef<HTMLIFrameElement>(null) const iframeRef = useRef<HTMLIFrameElement>(null)
const containerRef = useRef<HTMLDivElement>(null) const containerRef = useRef<HTMLDivElement>(null)
const [containerHeight, setContainerHeight] = useState(150) const [containerHeight, setContainerHeight] = useState(150)
const reportId = useRef<string>(uuidv4())
const handleToggleExpand = () => { const handleToggleExpand = () => {
setIsExpanded(!isExpanded) setIsExpanded(!isExpanded)
...@@ -26,16 +28,16 @@ const Report: FC<ReportProps> = ({ content }) => { ...@@ -26,16 +28,16 @@ const Report: FC<ReportProps> = ({ content }) => {
// 监听来自 iframe 的消息 // 监听来自 iframe 的消息
useEffect(() => { useEffect(() => {
const handleMessage = (event: MessageEvent) => { const handleMessage = (event: MessageEvent) => {
if (event.data && event.data.type === 'RESIZE_IFRAME') { if (event.data && event.data.type === 'RESIZE_IFRAME' && event.data.reportId === reportId.current) {
const height = event.data.height const height = event.data.height
if (height && height > 0) { if (height && height > 0) {
setContainerHeight(height) setContainerHeight(height)
console.log('收到 iframe 高度:', height) console.log('收到 iframe 高度:', height, 'reportId:', reportId.current)
} }
} }
if (event.data && event.data.type === 'COPY_SUCCESS') { if (event.data && event.data.type === 'COPY_SUCCESS') {
Toast.notify({ Toast.notify({
message: '链接复制成功,快去粘贴吧~', message: '链接复制成功,快去粘贴吧~',
type: 'success', type: 'success',
}) })
} }
...@@ -51,14 +53,17 @@ const Report: FC<ReportProps> = ({ content }) => { ...@@ -51,14 +53,17 @@ const Report: FC<ReportProps> = ({ content }) => {
// 向 iframe 发送获取高度的消息 // 向 iframe 发送获取高度的消息
const requestIframeHeight = () => { const requestIframeHeight = () => {
if (iframeRef.current && iframeRef.current.contentWindow) { if (iframeRef.current && iframeRef.current.contentWindow) {
iframeRef.current.contentWindow.postMessage({ type: 'GET_IFRAME_HEIGHT' }, '*') iframeRef.current.contentWindow.postMessage({
type: 'GET_IFRAME_HEIGHT',
reportId: reportId.current
}, '*')
} }
} }
// iframe 加载完成后请求高度 // iframe 加载完成后请求高度
const handleIframeLoad = () => { const handleIframeLoad = () => {
console.log('iframe 加载完成,请求高度') console.log('iframe 加载完成,请求高度, reportId:', reportId.current)
// 延迟发送,确保 iframe 内部内容已渲染 // 延迟发送,确保 iframe 内部内容已渲染
setTimeout(() => { setTimeout(() => {
requestIframeHeight() requestIframeHeight()
}, 300) }, 300)
...@@ -77,10 +82,10 @@ const Report: FC<ReportProps> = ({ content }) => { ...@@ -77,10 +82,10 @@ const Report: FC<ReportProps> = ({ content }) => {
if (!report_start_date) return '' if (!report_start_date) return ''
if (reportType === 2) { if (reportType === 2) {
// 月报:2026-01-10 转成 2026 年 1 月 // 月报:2026-01-10 转成 2026 年 1 月
return dayjs(report_start_date).format('YYYY年M月') return dayjs(report_start_date).format('YYYY年M月')
} else if (reportType === 1) { } else if (reportType === 1) {
// 周报:2026-01-10 转成 2026 年第 2 周 // 周报:2026-01-10 转成 2026 年第 2 周
const date = dayjs(report_start_date) const date = dayjs(report_start_date)
const year = date.year() const year = date.year()
// 计算是该年的第几周 // 计算是该年的第几周
...@@ -143,4 +148,4 @@ const Report: FC<ReportProps> = ({ content }) => { ...@@ -143,4 +148,4 @@ const Report: FC<ReportProps> = ({ content }) => {
) )
} }
export default Report export default Report
\ No newline at end of file \ No newline at end of file
...@@ -105,7 +105,7 @@ export const Think = ({ children, ...props }: any) => { ...@@ -105,7 +105,7 @@ export const Think = ({ children, ...props }: any) => {
</div> </div>
</summary> </summary>
{displayContent ? ( {displayContent ? (
<div className=" border-l border-components-panel-border pl-2 text-text-secondary think-class"> <div className="pt-2 border-l border-components-panel-border pl-2 text-text-secondary think-class">
{displayContent} {displayContent}
</div> </div>
) : ( ) : (
......
...@@ -780,4 +780,8 @@ button:focus-within { ...@@ -780,4 +780,8 @@ button:focus-within {
.footer-icon { .footer-icon {
width: 18px; width: 18px;
height: 18px; height: 18px;
}
.MB-12{
margin-bottom: 12px;
} }
\ 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!