Files
QLinker/frontend/src/views/ai/AiCenterView.vue
T
xiaowang 27182fc7d2 feat: 交付任务005-021全量改动(自动化/AI/联系人中心、消息中心改造、运维与容器化)
- 自动化中心:规则引擎、流程画布与触发器(V7/V10/V12/V18/V21)、测试全流程、安全边界、执行记录
- AI 中心:服务商/模型/调用与工具授权/治理(V8/V17)及配套前端页面
- 联系人中心:联系人目录、分组/标签、同步幂等(V19)与实装页面
- 消息中心:三栏布局重做、头像昵称服务端抓取与缓存(V16 conversation_profile)、出站归属修复
- 接入管理:NapCat 反向 WS/HTTP 回调多通道发送传输、连接状态统一口径
- 运维中心:备份保留与恢复确认(V13/V22/V24)、监控告警(V23)、日志与审计
- 全局:账号上下文切换(V20 account_profile)、统一 UI 基础组件、分页样式、Flyway 增量迁移护栏
- 部署:Dockerfile/docker-compose/Nginx 容器化编排与 CI 校验脚本
- 文档:任务 005-021 交付记录、设计画板导出、接口/数据库/架构文档同步
2026-11-17 17:29:06 +08:00

111 lines
4.2 KiB
Vue

<script setup>
import { ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { aiApi } from '../../api/ai'
import ChannelPanel from './ChannelPanel.vue'
import CallPanel from './CallPanel.vue'
import ToolPanel from './ToolPanel.vue'
import GovernancePanel from './GovernancePanel.vue'
const route = useRoute()
const router = useRouter()
const TABS = [
{ key: 'channels', label: '渠道', hint: '模型服务商与模型能力合并管理' },
{ key: 'calls', label: '调用与成本', hint: '用量、成本、耗时与错误分类' },
{ key: 'tools', label: '工具授权', hint: '风险分级、人工确认与执行审计' },
{ key: 'governance', label: '治理设置', hint: '脱敏、缓存与记忆保留' }
]
const tab = ref(String(route.query.tab || 'channels'))
if (!TABS.some((item) => item.key === tab.value)) tab.value = 'channels'
const counts = ref({ channels: null, tools: null })
const channelMeta = ref({ reserved: 0, unverified: 0 })
async function loadCounts() {
const [providerRows, modelRows, pending] = await Promise.allSettled([
aiApi.providers(),
aiApi.models(),
aiApi.toolCalls({ authorizationStatus: 'APPROVAL_REQUIRED', executionStatus: 'PENDING', page: 1, pageSize: 1 })
])
const providers = providerRows.status === 'fulfilled' ? (providerRows.value || []) : []
const models = modelRows.status === 'fulfilled' ? (modelRows.value || []) : []
counts.value = {
channels: providerRows.status === 'fulfilled' ? providers.length : null,
tools: pending.status === 'fulfilled' ? Number(pending.value?.total || 0) : null
}
channelMeta.value = {
reserved: providers.filter((item) => item.providerStatus !== 'ACTIVE').length,
unverified: models.filter((item) => item.modelStatus === 'UNVERIFIED').length
}
}
function select(key) {
if (tab.value === key) return
tab.value = key
router.replace({ query: { ...route.query, tab: key === 'channels' ? undefined : key } })
loadCounts()
}
watch(() => route.query.tab, (value) => {
const next = value ? String(value) : 'channels'
if (TABS.some((item) => item.key === next) && next !== tab.value) tab.value = next
})
loadCounts()
</script>
<template>
<div class="tabs-row">
<div class="tabs">
<button
v-for="item in TABS"
:key="item.key"
class="tab"
:class="{ active: tab === item.key }"
type="button" v-tooltip="item.hint"
@click="select(item.key)"
>
{{ item.label }}
<span
v-if="item.key === 'channels' && counts.channels"
:class="tab === 'channels' ? 'tab-badge' : 'tab-count'"
>{{ counts.channels }}</span>
<span
v-else-if="item.key === 'tools' && counts.tools"
:class="tab === 'tools' ? 'tab-badge' : 'tab-count'"
>{{ counts.tools }}</span>
</button>
</div>
<div v-if="tab === 'channels'" class="tab-side">
<span v-if="channelMeta.reserved" class="side-pill amber">预留 {{ channelMeta.reserved }}</span>
<span v-if="channelMeta.unverified" class="side-pill">未验证 {{ channelMeta.unverified }} 项</span>
</div>
</div>
<ChannelPanel v-if="tab === 'channels'" @changed="loadCounts" />
<CallPanel v-else-if="tab === 'calls'" />
<ToolPanel v-else-if="tab === 'tools'" />
<GovernancePanel v-else />
</template>
<style scoped>
.tabs-row {
display: flex; align-items: center; gap: 16px; border-bottom: 1px solid #edf0f5; margin-bottom: 12px;
}
.tabs-row .tabs { flex: 1; margin: 0; border-bottom: 0; }
.tab-badge {
display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px;
margin-left: 5px; padding: 0 5px; border-radius: 8px; background: #eef0fe; color: #4f5bef;
font-size: 9px; font-weight: 600; line-height: 1; vertical-align: 1px; font-variant-numeric: tabular-nums;
}
.tab-count { margin-left: 5px; color: #9aa1b2; font-size: 9px; font-variant-numeric: tabular-nums; }
.tab-side { display: flex; flex: none; gap: 8px; padding-right: 2px; }
.side-pill {
display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
background: #f3f4f6; color: #6b7280; font-size: 10px;
}
.side-pill.amber { background: #fffbeb; color: #b45309; }
</style>