feat: 更新 Web 前端页面
- 更新 Agents、Chat、Settings 等页面 - 新增 ModelAPIs 页面 - 更新各个模块的 composables - 更新 vite 配置和依赖版本 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
// Agent API 调用和状态管理
|
||||
|
||||
import { ref, computed } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { formatDate } from '@/utils/format'
|
||||
|
||||
const API_BASE = 'http://localhost:8082'
|
||||
import API_BASE from '@/composables/useApiBase'
|
||||
|
||||
// 类型定义
|
||||
export interface Skill {
|
||||
@@ -151,6 +150,15 @@ const isIndeterminate = computed(() => {
|
||||
return newAgent.value.selectedSkills.length > 0 && newAgent.value.selectedSkills.length < skillsOptions.value.length
|
||||
})
|
||||
|
||||
// 编辑模式下的全选状态
|
||||
const isAllSelectedEdit = computed(() => {
|
||||
return skillsOptions.value.length > 0 && editingAgent.value.selectedSkills.length === skillsOptions.value.length
|
||||
})
|
||||
|
||||
const isIndeterminateEdit = computed(() => {
|
||||
return editingAgent.value.selectedSkills.length > 0 && editingAgent.value.selectedSkills.length < skillsOptions.value.length
|
||||
})
|
||||
|
||||
// 方法
|
||||
async function fetchAgents() {
|
||||
try {
|
||||
@@ -203,12 +211,14 @@ async function fetchModels() {
|
||||
}
|
||||
const result = await response.json()
|
||||
if (result.list) {
|
||||
modelsList.value = result.list.map((m: any) => ({
|
||||
id: m.id,
|
||||
name: m.name,
|
||||
provider: m.provider,
|
||||
model: m.model
|
||||
}))
|
||||
modelsList.value = result.list
|
||||
.filter((m: any) => m.status !== 0)
|
||||
.map((m: any) => ({
|
||||
id: m.id,
|
||||
name: m.name,
|
||||
provider: m.provider,
|
||||
model: m.model
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch models:', error)
|
||||
@@ -380,6 +390,16 @@ async function toggleStatus(agent: Agent) {
|
||||
|
||||
async function deleteAgent(id: string) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'This action will permanently delete the agent. Continue?',
|
||||
'Delete Agent',
|
||||
{
|
||||
confirmButtonText: 'Delete',
|
||||
cancelButtonText: 'Cancel',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
|
||||
const response = await fetch(`${API_BASE}/api/agent/${id}`, { method: 'DELETE' })
|
||||
if (response.ok) {
|
||||
agents.value = agents.value.filter(a => a.id !== id)
|
||||
@@ -388,8 +408,10 @@ async function deleteAgent(id: string) {
|
||||
ElMessage.error('Failed to delete agent')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to delete agent:', error)
|
||||
ElMessage.error('Failed to delete agent')
|
||||
if (error !== 'cancel') {
|
||||
console.error('Failed to delete agent:', error)
|
||||
ElMessage.error('Failed to delete agent')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,6 +465,20 @@ function clearSkills() {
|
||||
newAgent.value.selectedSkills = []
|
||||
}
|
||||
|
||||
// 切换编辑模式下的全选
|
||||
function toggleSelectAllEdit() {
|
||||
if (isAllSelectedEdit.value) {
|
||||
editingAgent.value.selectedSkills = []
|
||||
} else {
|
||||
editingAgent.value.selectedSkills = skillsOptions.value.map(s => s.value)
|
||||
}
|
||||
}
|
||||
|
||||
// 清除编辑模式下的技能
|
||||
function clearSkillsEdit() {
|
||||
editingAgent.value.selectedSkills = []
|
||||
}
|
||||
|
||||
// 切换技能模式下拉框
|
||||
function toggleSkillsMode() {
|
||||
showSkillsDropdown.value = !showSkillsDropdown.value
|
||||
@@ -560,6 +596,8 @@ export function useAgents() {
|
||||
stats,
|
||||
isAllSelected,
|
||||
isIndeterminate,
|
||||
isAllSelectedEdit,
|
||||
isIndeterminateEdit,
|
||||
// 方法
|
||||
fetchAgents,
|
||||
fetchSkills,
|
||||
@@ -577,6 +615,8 @@ export function useAgents() {
|
||||
handleSkillsModeClickEdit,
|
||||
toggleSelectAll,
|
||||
clearSkills,
|
||||
toggleSelectAllEdit,
|
||||
clearSkillsEdit,
|
||||
handleClickOutside,
|
||||
toggleSkillsMode,
|
||||
selectSkillsMode,
|
||||
|
||||
Reference in New Issue
Block a user