feat:代码优化与Mock数据清理
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { pick } from 'lodash'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import api from '@/api/index.ts'
|
||||
import SvgIcon from '@/components/SvgIcon/index.vue'
|
||||
import { agentMapDuty } from '@/layout/components/config.ts'
|
||||
import { type Agent, useAgentsStore } from '@/stores'
|
||||
import { readConfig } from '@/utils/readJson.ts'
|
||||
import { useNotification } from '@/composables/useNotification.ts'
|
||||
import AgentRepoList from './AgentRepoList.vue'
|
||||
|
||||
const { error, success } = useNotification()
|
||||
|
||||
const agentsStore = useAgentsStore()
|
||||
|
||||
// 如果agentsStore.agents不存在就读取默认配置的json文件
|
||||
@@ -58,7 +60,7 @@ const readFileContent = (file: File) => {
|
||||
return
|
||||
}
|
||||
|
||||
const validAgents = jsonData.filter((agent) => {
|
||||
const validAgents = jsonData.filter(agent => {
|
||||
// 验证必需字段
|
||||
if (!agent.Name || typeof agent.Name !== 'string') {
|
||||
return false
|
||||
@@ -87,27 +89,24 @@ const readFileContent = (file: File) => {
|
||||
apiKey: agent.apiKey,
|
||||
apiModel: agent.apiModel
|
||||
}))
|
||||
|
||||
agentsStore.setAgents(processedAgents)
|
||||
|
||||
// 调用API
|
||||
api
|
||||
.setAgents(processedAgents)
|
||||
.then(() => {
|
||||
ElMessage.success('智能体上传成功')
|
||||
success('智能体上传成功')
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage.error('智能体上传失败')
|
||||
error('智能体上传失败')
|
||||
})
|
||||
} catch {
|
||||
ElMessage.error('JSON解析错误')
|
||||
error('JSON解析错误')
|
||||
}
|
||||
}
|
||||
|
||||
reader.onerror = () => {
|
||||
ElMessage.error('文件读取错误')
|
||||
error('文件读取错误')
|
||||
}
|
||||
|
||||
reader.readAsText(file)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user