9393 </div >
9494 <!-- AI助手按钮(默认状态:隐藏) -->
9595 <div title =" AI助手" class =" ai-helper" >
96- <svg-icon name =" add-group" @click.stop =" openAIHelper" ></svg-icon >
97- <CanvasAIChat
98- v-if =" shouldShowAIChat"
99- class =" ai-component"
100- @complete =" handleAIChatComplete"
101- @close =" closeAIHelper"
102- ></CanvasAIChat >
103- <AILoadingDialog
104- v-if =" shouldShowAILoading"
105- class =" ai-component"
106- @cancel =" handleAILoadingCancel"
107- ></AILoadingDialog >
108- <AIConfirmDialog
109- v-if =" shouldShowAIConfirm"
110- class =" ai-component"
111- @confirm =" handleAIConfirm"
112- @cancel =" handleAICancel"
113- @refresh =" handleAIRefresh"
114- ></AIConfirmDialog >
96+ <TinyPopover
97+ v-model =" showAIPopover"
98+ placement =" bottom-start"
99+ width =" 360"
100+ popper-class =" ai-popper"
101+ trigger =" manual"
102+ :visible-arrow =" false"
103+ >
104+ <CanvasAIChat
105+ v-if =" shouldShowAIChat"
106+ class =" ai-component"
107+ @complete =" handleAIChatComplete"
108+ @close =" closeAIHelper"
109+ ></CanvasAIChat >
110+ <AILoadingDialog
111+ v-if =" shouldShowAILoading"
112+ class =" ai-component"
113+ @cancel =" handleAILoadingCancel"
114+ ></AILoadingDialog >
115+ <AIConfirmDialog
116+ v-if =" shouldShowAIConfirm"
117+ class =" ai-component"
118+ @confirm =" handleAIConfirm"
119+ @cancel =" handleAICancel"
120+ @refresh =" handleAIRefresh"
121+ ></AIConfirmDialog >
122+ <template #reference >
123+ <svg-icon name =" add-group" @click.stop =" openAIHelper" ></svg-icon >
124+ </template >
125+ </TinyPopover >
115126 </div >
116127 </div >
117128 </div >
@@ -367,6 +378,15 @@ export default {
367378 return shouldShowNodeAILoading (currentSchema .id )
368379 })
369380
381+ const showAIPopover = computed (() => {
382+ const currentSchema = getCurrent ().schema
383+ if (! currentSchema? .id ) {
384+ return false
385+ }
386+ const status = getNodeAIStatus (currentSchema? .id )
387+ return status? .state !== ' hidden' && ! status? .collapsed
388+ })
389+
370390 // 切换AI助手显示/隐藏
371391 const openAIHelper = () => {
372392 const currentSchema = getCurrent ().schema
@@ -377,23 +397,32 @@ export default {
377397
378398 const currentStatus = getNodeAIStatus (currentSchema .id )
379399
380- if (currentStatus && currentStatus .state !== ' hidden' ) {
381- // 如果AI助手当前不是隐藏状态,则关闭它
382- closeNodeAIHelper (currentSchema .id )
400+ if (currentStatus && currentStatus .collapsed ) {
401+ // 面板已收起,重新展开恢复原状态
402+ updateNodeAIStatus (currentSchema .id , { collapsed: false })
403+ } else if (currentStatus && currentStatus .state !== ' hidden' ) {
404+ // 面板当前可见,收起面板但保留业务状态
405+ updateNodeAIStatus (currentSchema .id , { collapsed: true })
383406 } else {
384- // 如果AI助手当前是隐藏状态,则打开它
407+ // hidden状态,进入chat
385408 openNodeAIChat (currentSchema .id )
386409 }
387410 }
388411
389- // 关闭AI助手(由其他组件调用,如AI聊天界面 )
412+ // 关闭AI助手(由其他组件调用,如AI聊天界面的关闭按钮 )
390413 const closeAIHelper = () => {
391414 const currentSchema = getCurrent ().schema
392415 if (! currentSchema? .id ) {
393416 return
394417 }
395418
396- closeNodeAIHelper (currentSchema .id )
419+ const currentStatus = getNodeAIStatus (currentSchema .id )
420+ // loading/confirm状态下只收起面板,保留状态以便重新打开恢复
421+ if (currentStatus && (currentStatus .state === ' loading' || currentStatus .state === ' confirm' )) {
422+ updateNodeAIStatus (currentSchema .id , { collapsed: true })
423+ } else {
424+ closeNodeAIHelper (currentSchema .id )
425+ }
397426 }
398427
399428 const optionRef = ref (null )
@@ -902,6 +931,7 @@ export default {
902931 showQuickAction,
903932 showPopover,
904933 showToParent,
934+ showAIPopover,
905935 activeSetting,
906936 isModal,
907937 onMousedown,
@@ -1234,4 +1264,8 @@ export default {
12341264 transform: translateY (10px );
12351265 }
12361266}
1267+ .ai - popper .ai - popper .tiny - popper .tiny - popover {
1268+ padding: 0 ;
1269+ border- radius: 40px ;
1270+ }
12371271< / style>
0 commit comments