feat: 接入成员权限与 Agent 配置页面
- src/views/MembersView.vue: 新增成员、项目权限和密码消息管理 - src/views/SettingsView.vue: 接入 Agent 配置读取、保存和连接测试 - src/services/devopsApi.ts: 补齐成员、消息和 Agent 配置真实接口 - src/views/AgentView.vue: 移除旧独立 Agent 页面,保留顶部右侧抽屉入口
This commit is contained in:
+168
-1
@@ -2,17 +2,29 @@
|
||||
/**
|
||||
* 系统配置页展示集成变量说明、配置边界和审计日志脱敏 JSON。
|
||||
*/
|
||||
import { Refresh } from '@element-plus/icons-vue'
|
||||
import { Connection, Refresh } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import AuditJsonCell from '../components/AuditJsonCell.vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { devopsApi } from '../services/devopsApi'
|
||||
import { usePlatformStore } from '../stores/platform'
|
||||
import type {
|
||||
AgentConfigSummary,
|
||||
AuditLogEntry,
|
||||
IntegrationConfigItem,
|
||||
IntegrationConfigState,
|
||||
} from '../types/devops'
|
||||
|
||||
const platform = usePlatformStore()
|
||||
const agentConfigLoading = ref(false)
|
||||
const agentConfigTesting = ref(false)
|
||||
const agentConfig = ref<AgentConfigSummary | null>(null)
|
||||
const agentConfigForm = reactive({
|
||||
key: '',
|
||||
baseURL: '',
|
||||
model: '',
|
||||
})
|
||||
type VariableTagType = 'success' | 'warning' | 'danger' | 'info'
|
||||
type VariableGroup = {
|
||||
key: string
|
||||
@@ -31,6 +43,10 @@ const configStatusMeta: Record<
|
||||
missing: { label: '未配置', type: 'danger' },
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAgentConfig()
|
||||
})
|
||||
|
||||
function configStatusLabel(status: IntegrationConfigState): string {
|
||||
return configStatusMeta[status]?.label ?? '未配置'
|
||||
}
|
||||
@@ -150,6 +166,56 @@ function variableDescription(
|
||||
function variableSourceLabel(item: IntegrationConfigItem, name: string): string {
|
||||
return variableHelp(item, name)?.description ? '后端返回' : '等待后端说明'
|
||||
}
|
||||
|
||||
async function loadAgentConfig() {
|
||||
agentConfigLoading.value = true
|
||||
|
||||
try {
|
||||
const config = await devopsApi.getAgentConfig()
|
||||
applyAgentConfig(config)
|
||||
} finally {
|
||||
agentConfigLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveAgentConfig() {
|
||||
agentConfigLoading.value = true
|
||||
|
||||
try {
|
||||
const config = await devopsApi.saveAgentConfig({
|
||||
key: agentConfigForm.key.trim() || undefined,
|
||||
baseURL: agentConfigForm.baseURL.trim(),
|
||||
model: agentConfigForm.model.trim(),
|
||||
})
|
||||
applyAgentConfig(config)
|
||||
agentConfigForm.key = ''
|
||||
ElMessage.success('Agent 配置已保存')
|
||||
await platform.loadAll()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : 'Agent 配置保存失败')
|
||||
} finally {
|
||||
agentConfigLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function testAgentConfig() {
|
||||
agentConfigTesting.value = true
|
||||
|
||||
try {
|
||||
const result = await devopsApi.testAgentConfig()
|
||||
ElMessage.success(result.message)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : 'Agent 连接测试失败')
|
||||
} finally {
|
||||
agentConfigTesting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function applyAgentConfig(config: AgentConfigSummary) {
|
||||
agentConfig.value = config
|
||||
agentConfigForm.baseURL = config.baseURL
|
||||
agentConfigForm.model = config.model
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -253,6 +319,73 @@ function variableSourceLabel(item: IntegrationConfigItem, name: string): string
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>Agent 模型配置</h2>
|
||||
<span>{{ agentConfig?.hasKey ? '已保存密钥' : '未保存密钥' }}</span>
|
||||
</div>
|
||||
<div class="panel-body agent-config-grid" v-loading="agentConfigLoading">
|
||||
<div class="agent-config-form">
|
||||
<ElForm label-position="top">
|
||||
<ElFormItem label="Base URL">
|
||||
<ElInput
|
||||
v-model="agentConfigForm.baseURL"
|
||||
placeholder="https://api.example.com/v1"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="模型">
|
||||
<ElInput
|
||||
v-model="agentConfigForm.model"
|
||||
placeholder="gpt-4.1"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="API Key">
|
||||
<ElInput
|
||||
v-model="agentConfigForm.key"
|
||||
type="password"
|
||||
show-password
|
||||
autocomplete="new-password"
|
||||
placeholder="留空保留已保存密钥"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<div class="toolbar">
|
||||
<ElButton type="primary" :loading="agentConfigLoading" @click="saveAgentConfig">
|
||||
保存配置
|
||||
</ElButton>
|
||||
<ElButton
|
||||
:icon="Connection"
|
||||
:loading="agentConfigTesting"
|
||||
@click="testAgentConfig"
|
||||
>
|
||||
测试连接
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElForm>
|
||||
</div>
|
||||
<div class="agent-config-summary">
|
||||
<div class="secret-boundary">
|
||||
{{ agentConfig?.warning || '模型密钥仅保存在服务端,前端只提交到后端配置接口。' }}
|
||||
</div>
|
||||
<dl>
|
||||
<dt>密钥状态</dt>
|
||||
<dd>
|
||||
<ElTag :type="agentConfig?.hasKey ? 'success' : 'warning'" round>
|
||||
{{ agentConfig?.hasKey ? agentConfig.maskedKey : '未配置' }}
|
||||
</ElTag>
|
||||
</dd>
|
||||
<dt>Base URL</dt>
|
||||
<dd class="mono">{{ agentConfig?.baseURL || '-' }}</dd>
|
||||
<dt>模型</dt>
|
||||
<dd class="mono">{{ agentConfig?.model || '-' }}</dd>
|
||||
<dt>更新时间</dt>
|
||||
<dd>{{ formatCheckedAt(agentConfig?.updatedAt || '') }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>最近运维审计</h2>
|
||||
@@ -347,6 +480,36 @@ function variableSourceLabel(item: IntegrationConfigItem, name: string): string
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agent-config-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
|
||||
gap: 18px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.agent-config-form {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.agent-config-summary dl {
|
||||
display: grid;
|
||||
grid-template-columns: 82px minmax(0, 1fr);
|
||||
gap: 10px 12px;
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.agent-config-summary dt {
|
||||
color: #7b8798;
|
||||
}
|
||||
|
||||
.agent-config-summary dd {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
color: #172033;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.config-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -450,6 +613,10 @@ function variableSourceLabel(item: IntegrationConfigItem, name: string): string
|
||||
.variable-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.agent-config-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
|
||||
Reference in New Issue
Block a user