@@ -34,11 +34,13 @@ const ThinkCollapse = styled(
3434 ( { title, children, className } : ThinkCollapseProps ) => {
3535 // 如果是 Thinking 状态,默认展开,否则折叠
3636 const defaultActive = title === Locale . NewChat . Thinking ? [ "1" ] : [ ] ;
37+ // 如果是 NoThink 状态,禁用
38+ const disabled = title === Locale . NewChat . NoThink ;
3739 const [ activeKeys , setActiveKeys ] = useState ( defaultActive ) ;
3840
39- // 当标题从 Thinking 变为 Think 时自动折叠
41+ // 当标题从 Thinking 变为 Think 或 NoThink 时自动折叠
4042 useEffect ( ( ) => {
41- if ( title === Locale . NewChat . Think ) {
43+ if ( title === Locale . NewChat . Think || title === Locale . NewChat . NoThink ) {
4244 setActiveKeys ( [ ] ) ;
4345 } else if ( title === Locale . NewChat . Thinking ) {
4446 setActiveKeys ( [ "1" ] ) ;
@@ -47,10 +49,10 @@ const ThinkCollapse = styled(
4749
4850 return (
4951 < Collapse
50- className = { className }
52+ className = { ` ${ className } ${ disabled ? "disabled" : "" } ` }
5153 size = "small"
5254 activeKey = { activeKeys }
53- onChange = { ( keys ) => setActiveKeys ( keys as string [ ] ) }
55+ onChange = { ( keys ) => ! disabled && setActiveKeys ( keys as string [ ] ) }
5456 bordered = { false }
5557 >
5658 < Panel header = { title } key = "1" >
@@ -91,6 +93,18 @@ const ThinkCollapse = styled(
9193 opacity: 0.8;
9294 }
9395 }
96+
97+ &.disabled {
98+ opacity: 0.9;
99+ pointer-events: none;
100+ .ant-collapse-item {
101+ border: none !important;
102+ background-color: transparent !important;
103+ }
104+ .ant-collapse-header {
105+ padding: 6px 0px !important;
106+ }
107+ }
94108` ;
95109
96110function Details ( props : { children : React . ReactNode } ) {
@@ -435,6 +449,10 @@ function formatThinkText(text: string): string {
435449 const pattern = / ^ < t h i n k > ( [ \s \S ] * ?) < \/ t h i n k > / ;
436450 return text . replace ( pattern , ( match , thinkContent ) => {
437451 // 渲染为"思考完成"状态
452+ // 如果 thinkContent 为空,则渲染为"没有思考过程"状态
453+ if ( thinkContent . trim ( ) === "" ) {
454+ return `<thinkcollapse title="${ Locale . NewChat . NoThink } ">\n</thinkcollapse>` ;
455+ }
438456 return `<thinkcollapse title="${ Locale . NewChat . Think } ">\n${ thinkContent } \n</thinkcollapse>` ;
439457 } ) ;
440458}
0 commit comments