11"use client"
22
3- import { Modal , message , Badge } from 'antd'
4- import { ExpandAltOutlined } from '@ant-design/icons'
3+ import { Modal , message , Badge , Button } from 'antd'
4+ import { ExpandAltOutlined , SaveOutlined , BugOutlined } from '@ant-design/icons'
55import { useState , useRef , useEffect , useCallback } from 'react'
66import AdditionalRequestInput from './AdditionalRequestInput'
77import { fineTunePrompt , savePrompt } from '@/services/promptService'
@@ -160,14 +160,14 @@ const PromptCard = ({ title, content, index, onChange, onExpand }: {
160160 return (
161161 < div className = "h-full flex flex-col rounded-lg border border-gray-200 bg-white shadow-sm hover:shadow-md transition-all duration-200" >
162162 { /* Card header */ }
163- < div className = "bg-gray-50 text-gray-700 px-4 py-3 rounded-t-lg border-b border-gray-200 flex-shrink-0" >
163+ < div className = "bg-gray-50 text-gray-700 px-4 py-2 rounded-t-lg border-b border-gray-200 flex-shrink-0" >
164164 < div className = "flex items-center justify-between" >
165165 < div className = "flex items-center" >
166166 < Badge
167167 { ...getBadgeProps ( index ) }
168168 className = "mr-3"
169169 />
170- < h3 className = "text-lg font-medium" > { title } </ h3 >
170+ < h3 className = "text-base font-medium" > { title } </ h3 >
171171 </ div >
172172 < button
173173 onClick = { ( ) => onExpand ?.( title , content , index ) }
@@ -240,6 +240,23 @@ export default function SystemPromptDisplay({
240240
241241 const { t } = useTranslation ( 'common' )
242242
243+ // Calculate dynamic modal height based on content
244+ const calculateModalHeight = ( content : string ) => {
245+ const lineCount = content . split ( '\n' ) . length ;
246+ const contentLength = content . length ;
247+
248+ // 基于行数和内容长度的高度计算,范围 25vh - 85vh
249+ const minHeight = 25 ;
250+ const maxHeight = 85 ;
251+
252+ // 结合行数和内容长度来计算高度
253+ const heightByLines = minHeight + Math . floor ( lineCount / 8 ) * 5 ;
254+ const heightByContent = minHeight + Math . floor ( contentLength / 200 ) * 3 ;
255+
256+ const calculatedHeight = Math . max ( heightByLines , heightByContent ) ;
257+ return Math . max ( minHeight , Math . min ( maxHeight , calculatedHeight ) ) ;
258+ } ;
259+
243260 // Handle expand card content
244261 const handleExpandCard = ( title : string , content : string , index : number ) => {
245262 setExpandTitle ( title )
@@ -439,28 +456,35 @@ export default function SystemPromptDisplay({
439456
440457 return (
441458 < div className = "flex flex-col h-full" >
442- < div className = "flex justify-between items-center mb-3 flex-shrink-0 px-2" >
443- < div className = "flex flex-col " >
444- < h2 className = "text-lg font-medium text-gray-700 mt-1.5 " > { t ( 'agent.title' ) } </ h2 >
459+ < div className = "flex justify-between items-center mb-2 flex-shrink-0 px-2" >
460+ < div className = "flex items-center " >
461+ < h2 className = "text-lg font-medium" > { t ( 'agent.title' ) } </ h2 >
445462 </ div >
446- < div className = "flex gap-2" >
447- < button
463+ < div className = "flex gap-1" >
464+ < Button
465+ type = "text"
466+ size = "small"
467+ icon = { < SaveOutlined /> }
448468 onClick = { handleSavePrompt }
449469 disabled = { ! agentId }
450- className = "px-4 py-1.5 rounded-md flex items-center text-sm bg- green-500 text-white hover:bg -green-600 disabled:opacity-50 disabled:cursor-not-allowed "
451- style = { { border : "none" } }
470+ className = "text-green-500 hover:text -green-600 hover:bg-green-50 "
471+ title = { t ( 'systemPrompt.button.save' ) }
452472 >
453473 { t ( 'systemPrompt.button.save' ) }
454- </ button >
455- < button
474+ </ Button >
475+ < Button
476+ type = "text"
477+ size = "small"
478+ icon = { < BugOutlined /> }
456479 onClick = { onDebug }
457- className = "px-4 py-1.5 rounded-md flex items-center text-sm bg-gray-100 text-gray-700 hover:bg-gray-200 "
458- style = { { border : "none" } }
480+ className = "text-blue-500 hover: text-blue-600 hover:bg-blue-50 "
481+ title = { t ( 'systemPrompt.button.debug' ) }
459482 >
460483 { t ( 'systemPrompt.button.debug' ) }
461- </ button >
484+ </ Button >
462485 </ div >
463486 </ div >
487+ < div className = "border-t border-gray-200 mx-2 mb-2" > </ div >
464488 < div
465489 className = "flex-1 overflow-y-auto px-2"
466490 style = { {
@@ -504,13 +528,16 @@ export default function SystemPromptDisplay({
504528 </ MilkdownProvider >
505529 </ div >
506530 < div className = "mt-4 flex justify-end" >
507- < button
531+ < Button
532+ type = "text"
533+ size = "small"
534+ icon = { < SaveOutlined /> }
508535 onClick = { handleSaveTunedPrompt }
509- className = "px-4 py-1.5 rounded-md flex items-center text-sm bg- blue-500 text-white hover:bg-blue-600 "
510- style = { { border : "none" } }
536+ className = "text-blue-500 hover: text-blue-600 hover:bg-blue-50 "
537+ title = { t ( 'systemPrompt.modal.button.save' ) }
511538 >
512539 { t ( 'systemPrompt.modal.button.save' ) }
513- </ button >
540+ </ Button >
514541 </ div >
515542 </ div >
516543 ) }
@@ -520,7 +547,7 @@ export default function SystemPromptDisplay({
520547 { /* Expand Card Content Modal */ }
521548 < Modal
522549 title = {
523- < div className = "flex justify-end items-center pr-4" >
550+ < div className = "flex justify-end items-center pr-4 -mb-2 " >
524551 < button
525552 onClick = { handleCloseExpandedModal }
526553 className = "px-4 py-1.5 rounded-md flex items-center text-sm bg-gray-100 text-gray-700 hover:bg-gray-200"
@@ -540,7 +567,10 @@ export default function SystemPromptDisplay({
540567 content : { top : 20 }
541568 } }
542569 >
543- < div className = "flex flex-col h-[80vh]" >
570+ < div
571+ className = "flex flex-col"
572+ style = { { height : `${ calculateModalHeight ( expandContent ) } vh` } }
573+ >
544574 < div className = "flex-1 border border-gray-200 rounded-md overflow-y-auto" >
545575 < MilkdownProvider >
546576 < PromptEditor
0 commit comments