feat(agent): 支持自定义API配置并优化UI交互
- 为agent.json添加apiUrl、apiKey、apiModel字段支持 - 更新API接口类型定义,支持传递自定义API配置 - 优化AgentRepoList组件UI样式和交互效果 - 增强JSON文件上传校验逻辑,支持API配置验证 - 改进任务结果页面布局和视觉呈现 - 添加任务过程查看抽屉功能 - 实现执行按钮动态样式和悬停效果 - 优化节点连接线渲染逻辑和性能
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ref } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
@@ -12,6 +12,9 @@ export interface Agent {
|
||||
Profile: string
|
||||
Icon: string
|
||||
Classification: string
|
||||
apiUrl?: string
|
||||
apiKey?: string
|
||||
apiModel?: string
|
||||
}
|
||||
|
||||
type HslColorVector = [number, number, number]
|
||||
@@ -64,7 +67,6 @@ function clearStorageByVersion() {
|
||||
|
||||
export const useAgentsStore = defineStore('agents', () => {
|
||||
const configStore = useConfigStore()
|
||||
|
||||
const agents = useStorage<Agent[]>(`${storageKey}-repository`, [])
|
||||
function setAgents(agent: Agent[]) {
|
||||
agents.value = agent
|
||||
@@ -76,7 +78,10 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
searchValue.value = value
|
||||
}
|
||||
|
||||
const storageVersionIdentifier = useStorage<string>(`${storageKey}-storage-version-identifier`, '')
|
||||
const storageVersionIdentifier = useStorage<string>(
|
||||
`${storageKey}-storage-version-identifier`,
|
||||
'',
|
||||
)
|
||||
// 监听 configStore.config.agentRepository.storageVersionIdentifier 改变
|
||||
watch(
|
||||
() => configStore.config.agentRepository.storageVersionIdentifier,
|
||||
@@ -89,7 +94,7 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// 当前的展示的任务流程
|
||||
@@ -127,6 +132,36 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
executePlan.value = []
|
||||
}
|
||||
|
||||
// 额外的产物列表
|
||||
const additionalOutputs = ref<string[]>([])
|
||||
|
||||
// 添加新产物
|
||||
function addNewOutput(outputObject: string) {
|
||||
if (!outputObject.trim()) return false
|
||||
|
||||
const trimmedOutput = outputObject.trim()
|
||||
if (!additionalOutputs.value.includes(trimmedOutput)) {
|
||||
additionalOutputs.value.push(trimmedOutput)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 删除额外产物
|
||||
function removeAdditionalOutput(outputObject: string) {
|
||||
const index = additionalOutputs.value.indexOf(outputObject)
|
||||
if (index > -1) {
|
||||
additionalOutputs.value.splice(index, 1)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 清除额外产物
|
||||
function clearAdditionalOutputs() {
|
||||
additionalOutputs.value = []
|
||||
}
|
||||
|
||||
return {
|
||||
agents,
|
||||
setAgents,
|
||||
@@ -139,6 +174,10 @@ export const useAgentsStore = defineStore('agents', () => {
|
||||
executePlan,
|
||||
setExecutePlan,
|
||||
resetAgent,
|
||||
additionalOutputs,
|
||||
addNewOutput,
|
||||
removeAdditionalOutput,
|
||||
clearAdditionalOutputs,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { readConfig } from '@/utils/readJson.ts'
|
||||
import { store } from '@/stores'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user