This commit is contained in:
@@ -25,20 +25,13 @@
|
||||
<!-- 智能体选择 -->
|
||||
<div class="form-item">
|
||||
<label class="form-label">选择智能体</label>
|
||||
<Combobox v-model="selectedAgentId" :disabled="loadingAgents">
|
||||
<ComboboxAnchor class="agent-select-anchor">
|
||||
<ComboboxTrigger as-child>
|
||||
<ComboboxInput
|
||||
:placeholder="loadingAgents ? '加载中...' : '搜索或选择智能体...'"
|
||||
v-model="searchKeyword"
|
||||
:display-value="displayValue"
|
||||
/>
|
||||
</ComboboxTrigger>
|
||||
</ComboboxAnchor>
|
||||
<ComboboxList class="agent-combobox-list">
|
||||
<ComboboxEmpty>未找到匹配的智能体</ComboboxEmpty>
|
||||
<ComboboxItem
|
||||
v-for="agent in filteredAgents"
|
||||
<Select v-model="selectedAgentId" :disabled="loadingAgents" class="agent-select">
|
||||
<SelectTrigger class="agent-select-trigger">
|
||||
<SelectValue :placeholder="loadingAgents ? '加载中...' : '请选择智能体'" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem
|
||||
v-for="agent in agentList"
|
||||
:key="agent.id"
|
||||
:value="agent.id"
|
||||
>
|
||||
@@ -46,9 +39,9 @@
|
||||
<img v-if="agent.icon" :src="agent.icon" class="agent-icon" />
|
||||
<span class="agent-name">{{ agent.agentName }}</span>
|
||||
</div>
|
||||
</ComboboxItem>
|
||||
</ComboboxList>
|
||||
</Combobox>
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<!-- 主题输入 -->
|
||||
@@ -96,14 +89,12 @@ import { ref, computed, watch, onUnmounted } from 'vue'
|
||||
import { Icon } from '@iconify/vue'
|
||||
import { toast } from 'vue-sonner'
|
||||
import {
|
||||
Combobox,
|
||||
ComboboxAnchor,
|
||||
ComboboxEmpty,
|
||||
ComboboxInput,
|
||||
ComboboxItem,
|
||||
ComboboxList,
|
||||
ComboboxTrigger
|
||||
} from '@/components/ui/combobox'
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue
|
||||
} from '@/components/ui/select'
|
||||
import { getAgentList, sendChatStream } from '@/api/agent'
|
||||
|
||||
// Props
|
||||
@@ -126,7 +117,6 @@ const selectedAgentId = ref<number | null>(null)
|
||||
const theme = ref('')
|
||||
const generatedText = ref('')
|
||||
const isGenerating = ref(false)
|
||||
const searchKeyword = ref('')
|
||||
const abortController = ref<AbortController | null>(null)
|
||||
const popoverStyle = ref<Record<string, string>>({})
|
||||
|
||||
@@ -135,24 +125,6 @@ const canGenerate = computed(() => {
|
||||
return selectedAgentId.value && theme.value.trim().length > 0
|
||||
})
|
||||
|
||||
// 过滤后的智能体列表
|
||||
const filteredAgents = computed(() => {
|
||||
if (!searchKeyword.value.trim()) {
|
||||
return agentList.value
|
||||
}
|
||||
const keyword = searchKeyword.value.toLowerCase()
|
||||
return agentList.value.filter(agent =>
|
||||
agent.agentName?.toLowerCase().includes(keyword)
|
||||
)
|
||||
})
|
||||
|
||||
// 显示选中智能体的名称
|
||||
const displayValue = (val: number | null) => {
|
||||
if (!val) return ''
|
||||
const agent = agentList.value.find(a => a.id === val)
|
||||
return agent?.agentName || ''
|
||||
}
|
||||
|
||||
// 获取智能体列表
|
||||
const fetchAgents = async () => {
|
||||
loadingAgents.value = true
|
||||
|
||||
Reference in New Issue
Block a user