99 sendMessage,
1010 stopStreaming
1111} = useAssistant ()
12+ const { trackEvent } = useArms ()
1213
1314const onEnter = (e : KeyboardEvent ) => {
1415 if (e .isComposing ) {
@@ -18,6 +19,7 @@ const onEnter = (e: KeyboardEvent) => {
1819}
1920
2021const handleFormSubmit = async () => {
22+ trackEvent (' 发起对话' , ' 按钮点击' )
2123 try {
2224 await sendMessage (userInput .value )
2325 } catch (error ) {
@@ -33,22 +35,40 @@ watch([suggestions, status], async () => {
3335 suggestionsRef .value ?.scrollIntoView ({ behavior: ' smooth' , block: ' end' })
3436 }
3537})
38+
39+ function onClose() {
40+ trackEvent (' 关闭助手面板' , ' 按钮点击' )
41+ toggleOpen ()
42+ }
43+
44+ function onSuggestionClick(item : string ) {
45+ trackEvent (' 参考问题' , ' 按钮点击' )
46+ sendMessage (item )
47+ }
48+
49+ function onStopStreaming() {
50+ trackEvent (' 停止对话' , ' 按钮点击' )
51+ stopStreaming ()
52+ }
3653 </script >
3754
3855<template >
3956 <Transition name =" slide" >
4057 <div
4158 v-if =" isOpen"
42- class =" h-full shrink-0 overflow-hidden"
59+ class =" h-screen sticky top-0 shrink-0 overflow-hidden"
4360 >
4461 <UDashboardSidebar
4562 id =" assistant"
4663 class =" overflow-y-auto h-full border-l border-default -ml-px"
4764 side =" right"
4865 resizable
49- :default-size =" 368 "
50- :min-size =" 368 "
66+ :default-size =" 400 "
67+ :min-size =" 400 "
5168 :max-size =" 576"
69+ :ui =" {
70+ body: 'pb-4'
71+ }"
5272 >
5373 <div class =" flex items-center justify-between" >
5474 <div class =" flex items-center gap-1.5" >
@@ -61,7 +81,7 @@ watch([suggestions, status], async () => {
6181 <div class =" flex items-center gap-2" >
6282 <button
6383 class =" group flex items-center hover:bg-gray-100 dark:hover:bg-white/10 p-1.5 rounded-lg cursor-pointer"
64- @click =" toggleOpen "
84+ @click =" onClose "
6585 >
6686 <UIcon
6787 name =" i-lucide:x"
@@ -73,7 +93,7 @@ watch([suggestions, status], async () => {
7393
7494 <UChatPalette
7595 :ui =" {
76- content: 'scrollbar-hide'
96+ content: 'scrollbar-hide pr-px '
7797 }"
7898 >
7999 <UChatMessage
@@ -90,12 +110,12 @@ watch([suggestions, status], async () => {
90110 :status =" status"
91111 should-auto-scroll
92112 :ui =" {
93- root: 'px-0'
113+ root: 'px-0 [ & >article]:last-of-type:min-h-auto '
94114 }"
95115 >
96116 <template #content =" { message } " >
97117 <AssistantMDC
98- v-if =" message.role === 'assistant'"
118+ v-if =" message.role === 'assistant' && message.content "
99119 :value =" message.content"
100120 class =" text-sm"
101121 />
@@ -120,7 +140,7 @@ watch([suggestions, status], async () => {
120140 v-for =" (item, index) in suggestions"
121141 :key =" index"
122142 class =" hover:text-primary/80 cursor-pointer"
123- @click =" sendMessage (item)"
143+ @click =" onSuggestionClick (item)"
124144 >
125145 {{ item }}
126146 </li >
@@ -140,8 +160,10 @@ watch([suggestions, status], async () => {
140160 >
141161 <UChatPromptSubmit
142162 size =" sm"
163+ submitted-icon =" i-lucide-circle"
164+ streaming-icon =" i-lucide-circle"
143165 :status =" status"
144- @stop =" stopStreaming "
166+ @stop =" onStopStreaming "
145167 />
146168 </UChatPrompt >
147169 </template >
0 commit comments