feat: 精简部署工作空间并接入真实助手
- 项目首页保留部署状态与日志入口,发布和管理功能收进更多菜单。 - 统一记录步骤与日志,限制轮询、日志渲染和助手短会话开销。 - 接入只读 Agent 问答、来源与个人历史,补充权限和并发回归。
This commit is contained in:
+67
-135
@@ -9,18 +9,15 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import { devopsApi } from '../services/devopsApi'
|
||||
import { useSessionStore } from '../stores/session'
|
||||
|
||||
type LoginRole = 'super_admin' | 'member'
|
||||
|
||||
const SUPER_ADMIN_ACCOUNT = 'zhanxi'
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const session = useSessionStore()
|
||||
const loading = ref(false)
|
||||
const forgotPasswordLoading = ref(false)
|
||||
const loginRole = ref<LoginRole>('super_admin')
|
||||
|
||||
const loginForm = reactive({
|
||||
account: SUPER_ADMIN_ACCOUNT,
|
||||
account: '',
|
||||
password: '',
|
||||
})
|
||||
|
||||
@@ -30,34 +27,23 @@ const passwordForm = reactive({
|
||||
confirmPassword: '',
|
||||
})
|
||||
|
||||
const redirect = computed(() =>
|
||||
typeof route.query.redirect === 'string' ? route.query.redirect : '/overview',
|
||||
)
|
||||
const roleHint = computed(() =>
|
||||
loginRole.value === 'super_admin'
|
||||
? '超级管理员不提供忘记密码入口,请通过服务器运维方式重置。'
|
||||
: '普通成员首次登录或重置密码后,必须先修改临时密码。',
|
||||
)
|
||||
const isSuperAdminLogin = computed(() => loginRole.value === 'super_admin')
|
||||
|
||||
function switchLoginRole(role: LoginRole) {
|
||||
loginRole.value = role
|
||||
loginForm.account = role === 'super_admin' ? SUPER_ADMIN_ACCOUNT : ''
|
||||
loginForm.password = ''
|
||||
}
|
||||
|
||||
function handleLoginRoleChange(value: unknown) {
|
||||
if (value === 'super_admin' || value === 'member') {
|
||||
switchLoginRole(value)
|
||||
}
|
||||
}
|
||||
const redirect = computed(() => {
|
||||
const value = route.query.redirect
|
||||
return typeof value === 'string' && value.startsWith('/') && !value.startsWith('//')
|
||||
? value
|
||||
: '/overview'
|
||||
})
|
||||
const isSuperAdminLogin = computed(() => loginForm.account.trim() === SUPER_ADMIN_ACCOUNT)
|
||||
const loginError = ref('')
|
||||
|
||||
async function submitLogin() {
|
||||
if (loading.value) return
|
||||
loginError.value = ''
|
||||
loading.value = true
|
||||
|
||||
try {
|
||||
const user = await session.login({
|
||||
account: isSuperAdminLogin.value ? SUPER_ADMIN_ACCOUNT : loginForm.account.trim(),
|
||||
account: loginForm.account.trim(),
|
||||
password: loginForm.password,
|
||||
})
|
||||
passwordForm.currentPassword = loginForm.password
|
||||
@@ -69,7 +55,7 @@ async function submitLogin() {
|
||||
|
||||
await router.push(redirect.value)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '登录失败')
|
||||
loginError.value = error instanceof Error ? error.message : '登录失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -88,15 +74,11 @@ async function requestPasswordReset() {
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认向超级管理员发送账号 ${account} 的密码重置请求?`,
|
||||
'忘记密码',
|
||||
{
|
||||
confirmButtonText: '发送请求',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
await ElMessageBox.confirm(`确认向超级管理员发送账号 ${account} 的密码重置请求?`, '忘记密码', {
|
||||
confirmButtonText: '发送请求',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
@@ -162,28 +144,20 @@ function accountLabel() {
|
||||
<section class="login-panel">
|
||||
<div class="login-copy">
|
||||
<ElIcon><Monitor /></ElIcon>
|
||||
<h1>DevOps 运维平台</h1>
|
||||
<p>使用平台账号进入控制台。</p>
|
||||
<h1>登录 DevOps</h1>
|
||||
<p>项目发布,简单有序。</p>
|
||||
</div>
|
||||
<ElForm class="login-form" label-position="top" @submit.prevent="submit">
|
||||
<template v-if="!session.mustChangePassword">
|
||||
<div class="role-switch">
|
||||
<ElRadioGroup
|
||||
:model-value="loginRole"
|
||||
size="large"
|
||||
@change="handleLoginRoleChange"
|
||||
>
|
||||
<ElRadioButton value="super_admin">超级管理员</ElRadioButton>
|
||||
<ElRadioButton value="member">普通成员</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
<p>{{ roleHint }}</p>
|
||||
</div>
|
||||
<ElFormItem label="账号">
|
||||
<ElInput
|
||||
v-model="loginForm.account"
|
||||
size="large"
|
||||
autocomplete="username"
|
||||
:readonly="isSuperAdminLogin"
|
||||
name="username"
|
||||
required
|
||||
:spellcheck="false"
|
||||
placeholder="输入平台账号…"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="密码">
|
||||
@@ -192,9 +166,11 @@ function accountLabel() {
|
||||
size="large"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
required
|
||||
show-password
|
||||
/>
|
||||
</ElFormItem>
|
||||
<p v-if="loginError" class="login-error" role="alert">{{ loginError }}</p>
|
||||
<ElButton
|
||||
type="primary"
|
||||
size="large"
|
||||
@@ -270,111 +246,67 @@ function accountLabel() {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: #eef2f7;
|
||||
padding: 28px 20px;
|
||||
background: #f8f9fb;
|
||||
}
|
||||
|
||||
.login-panel {
|
||||
display: grid;
|
||||
width: min(860px, 100%);
|
||||
grid-template-columns: 1fr 360px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #dfe6f0;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 18px 50px rgb(15 23 42 / 10%);
|
||||
width: min(410px, 100%);
|
||||
padding: 38px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.login-copy {
|
||||
padding: 44px;
|
||||
border-right: 1px solid #e6ebf3;
|
||||
background: #f8fafc;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.login-copy .el-icon {
|
||||
color: #1d5fd0;
|
||||
font-size: 34px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
margin-bottom: 24px;
|
||||
border-radius: 9px;
|
||||
background: #272d3a;
|
||||
color: #fff;
|
||||
font-size: 23px;
|
||||
}
|
||||
|
||||
.login-copy h1 {
|
||||
margin: 18px 0 10px;
|
||||
color: #111827;
|
||||
font-size: 28px;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.login-copy p {
|
||||
max-width: 420px;
|
||||
color: #697386;
|
||||
font-size: 14px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
padding: 44px 36px;
|
||||
}
|
||||
|
||||
.role-switch {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.role-switch :deep(.el-radio-group) {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.role-switch :deep(.el-radio-button__inner) {
|
||||
width: 100%;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.role-switch p {
|
||||
min-height: 20px;
|
||||
margin: 0;
|
||||
color: #697386;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: var(--text);
|
||||
font-size: 23px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.login-copy p {
|
||||
margin: 10px 0 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-form .el-button {
|
||||
width: 100%;
|
||||
margin-top: 8px;
|
||||
margin: 8px 0 0;
|
||||
}
|
||||
|
||||
.forgot-password {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
.login-error {
|
||||
padding: 10px 12px;
|
||||
border-radius: 5px;
|
||||
background: #fff4f4;
|
||||
color: #b04747;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.change-title {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
margin-bottom: 18px;
|
||||
color: #111827;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.change-title span {
|
||||
color: #697386;
|
||||
gap: 6px;
|
||||
margin-bottom: 22px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.switch-account {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
.change-title span {
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 780px) {
|
||||
@media (max-width: 480px) {
|
||||
.login-panel {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.login-copy {
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #e6ebf3;
|
||||
padding: 30px 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+64
-170
@@ -124,43 +124,9 @@ const filteredMessages = computed(() => {
|
||||
return messages.value.filter((message) => message.status === messageStatusFilter.value)
|
||||
})
|
||||
|
||||
const memberOverview = computed(() => {
|
||||
const activeCount = members.value.filter((member) => member.status === 'active').length
|
||||
const buildAccountCount = members.value.filter(memberHasBuildPermission).length
|
||||
const mustChangePasswordCount = members.value.filter((member) => member.mustChangePassword).length
|
||||
const resetRequestCount = members.value.filter((member) => member.hasPendingPasswordResetRequest).length
|
||||
|
||||
return [
|
||||
{ key: 'total', label: '平台账号', value: members.value.length, tone: 'neutral' },
|
||||
{ key: 'active', label: '启用账号', value: activeCount, tone: 'success' },
|
||||
{ key: 'build', label: '构建账号', value: buildAccountCount, tone: 'active' },
|
||||
{
|
||||
key: 'must-change',
|
||||
label: '待改密',
|
||||
value: mustChangePasswordCount,
|
||||
tone: mustChangePasswordCount > 0 ? 'warning' : 'neutral',
|
||||
},
|
||||
{
|
||||
key: 'reset',
|
||||
label: '请求重置',
|
||||
value: resetRequestCount,
|
||||
tone: resetRequestCount > 0 ? 'danger' : 'neutral',
|
||||
},
|
||||
{
|
||||
key: 'messages',
|
||||
label: '待处理消息',
|
||||
value: pendingMessages.value.length,
|
||||
tone: pendingMessages.value.length > 0 ? 'warning' : 'neutral',
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const hasActiveMemberFilters = computed(() =>
|
||||
Boolean(
|
||||
accountKeyword.value.trim() ||
|
||||
roleFilter.value ||
|
||||
statusFilter.value ||
|
||||
securityFilter.value,
|
||||
accountKeyword.value.trim() || roleFilter.value || statusFilter.value || securityFilter.value,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -292,25 +258,18 @@ async function updatePermissions() {
|
||||
}
|
||||
|
||||
async function resetPassword(member: MemberSummary) {
|
||||
await ElMessageBox.confirm(
|
||||
`确认为 ${member.displayName} 生成一次性临时密码?`,
|
||||
'重置密码',
|
||||
{
|
||||
confirmButtonText: '重置',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
await ElMessageBox.confirm(`确认为 ${member.displayName} 生成一次性临时密码?`, '重置密码', {
|
||||
confirmButtonText: '重置',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
const updated = await devopsApi.resetMemberPassword(member.id)
|
||||
upsertMember(updated)
|
||||
await loadMessages()
|
||||
await showTemporaryPassword(updated, '临时密码已生成')
|
||||
}
|
||||
|
||||
async function showTemporaryPassword(
|
||||
member: MemberCredentialResult,
|
||||
title: string,
|
||||
) {
|
||||
async function showTemporaryPassword(member: MemberCredentialResult, title: string) {
|
||||
await ElMessageBox.alert(
|
||||
`请将以下临时密码安全发送给 ${member.displayName},成员首次登录后必须修改密码。\n\n${member.temporaryPassword}`,
|
||||
title,
|
||||
@@ -341,15 +300,11 @@ async function toggleStatus(member: MemberSummary) {
|
||||
}
|
||||
|
||||
async function deleteMember(member: MemberSummary) {
|
||||
await ElMessageBox.confirm(
|
||||
`确认删除成员 ${member.displayName}?`,
|
||||
'删除成员',
|
||||
{
|
||||
confirmButtonText: '删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
await ElMessageBox.confirm(`确认删除成员 ${member.displayName}?`, '删除成员', {
|
||||
confirmButtonText: '删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
await devopsApi.deleteMember(member.id)
|
||||
members.value = members.value.filter((item) => item.id !== member.id)
|
||||
ElMessage.success('成员已删除')
|
||||
@@ -394,10 +349,9 @@ async function loadMessages() {
|
||||
}
|
||||
|
||||
function upsertMember(member: MemberSummary) {
|
||||
members.value = [
|
||||
member,
|
||||
...members.value.filter((item) => item.id !== member.id),
|
||||
].sort((left, right) => roleOrder(left) - roleOrder(right))
|
||||
members.value = [member, ...members.value.filter((item) => item.id !== member.id)].sort(
|
||||
(left, right) => roleOrder(left) - roleOrder(right),
|
||||
)
|
||||
}
|
||||
|
||||
function roleOrder(member: MemberSummary) {
|
||||
@@ -410,10 +364,7 @@ function resetPermissionMap(target: PermissionMap, member?: MemberSummary) {
|
||||
}
|
||||
|
||||
const permissionByProject = new Map(
|
||||
member?.projectPermissions.map((permission) => [
|
||||
permission.projectKey,
|
||||
permission.level,
|
||||
]) ?? [],
|
||||
member?.projectPermissions.map((permission) => [permission.projectKey, permission.level]) ?? [],
|
||||
)
|
||||
|
||||
for (const project of platform.projects) {
|
||||
@@ -444,11 +395,6 @@ function memberMatchesSecurityFilter(member: MemberSummary, filter: MemberSecuri
|
||||
return !member.mustChangePassword && !member.hasPendingPasswordResetRequest
|
||||
}
|
||||
|
||||
function memberHasBuildPermission(member: MemberSummary) {
|
||||
return member.role === 'super_admin' ||
|
||||
member.projectPermissions.some((permission) => permission.level === 'build')
|
||||
}
|
||||
|
||||
function memberBuildPermissionCount(member: MemberSummary) {
|
||||
if (member.role === 'super_admin') {
|
||||
return platform.projects.length
|
||||
@@ -584,32 +530,28 @@ function formatDateTime(value?: string) {
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<ElButton :icon="Refresh" @click="loadData">刷新</ElButton>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateDialog">
|
||||
新增成员
|
||||
</ElButton>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateDialog"> 新增成员 </ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="member-overview-grid">
|
||||
<article
|
||||
v-for="item in memberOverview"
|
||||
:key="item.key"
|
||||
class="member-overview-card"
|
||||
:class="`tone-${item.tone}`"
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
<strong>{{ item.value }}</strong>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>密码消息</h2>
|
||||
<span>{{ filteredMessages.length }} / {{ messages.length }} 条,{{ pendingMessages.length }} 条待处理</span>
|
||||
</div>
|
||||
<details class="panel message-disclosure">
|
||||
<summary class="panel-header">
|
||||
<h2>密码重置请求</h2>
|
||||
<span
|
||||
>{{ filteredMessages.length }} / {{ messages.length }} 条,{{
|
||||
pendingMessages.length
|
||||
}}
|
||||
条待处理</span
|
||||
>
|
||||
</summary>
|
||||
<div class="panel-body">
|
||||
<div class="message-filter-bar">
|
||||
<ElSelect v-model="messageStatusFilter" clearable placeholder="消息状态">
|
||||
<ElSelect
|
||||
aria-label="筛选密码消息状态"
|
||||
v-model="messageStatusFilter"
|
||||
clearable
|
||||
placeholder="消息状态"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in messageStatusOptions"
|
||||
:key="option.value"
|
||||
@@ -653,7 +595,7 @@ function formatDateTime(value?: string) {
|
||||
:image-size="72"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</details>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
@@ -663,13 +605,14 @@ function formatDateTime(value?: string) {
|
||||
<div class="panel-body">
|
||||
<div class="member-filter-bar">
|
||||
<ElInput
|
||||
aria-label="搜索成员"
|
||||
v-model="accountKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
placeholder="搜索账号 / 名称 / 项目权限"
|
||||
class="member-search"
|
||||
/>
|
||||
<ElSelect v-model="roleFilter" clearable placeholder="角色">
|
||||
<ElSelect aria-label="筛选成员角色" v-model="roleFilter" clearable placeholder="角色">
|
||||
<ElOption
|
||||
v-for="option in roleOptions"
|
||||
:key="option.value"
|
||||
@@ -677,7 +620,12 @@ function formatDateTime(value?: string) {
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElSelect v-model="statusFilter" clearable placeholder="账号状态">
|
||||
<ElSelect
|
||||
aria-label="筛选成员状态"
|
||||
v-model="statusFilter"
|
||||
clearable
|
||||
placeholder="账号状态"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in statusOptions"
|
||||
:key="option.value"
|
||||
@@ -685,7 +633,12 @@ function formatDateTime(value?: string) {
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElSelect v-model="securityFilter" clearable placeholder="安全状态">
|
||||
<ElSelect
|
||||
aria-label="筛选账号安全状态"
|
||||
v-model="securityFilter"
|
||||
clearable
|
||||
placeholder="安全状态"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in securityOptions"
|
||||
:key="option.value"
|
||||
@@ -743,13 +696,14 @@ function formatDateTime(value?: string) {
|
||||
<ElTableColumn label="安全状态" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div class="security-tags">
|
||||
<ElTag v-if="row.mustChangePassword" type="warning" round>
|
||||
待改密
|
||||
</ElTag>
|
||||
<ElTag v-if="row.mustChangePassword" type="warning" round> 待改密 </ElTag>
|
||||
<ElTag v-if="row.hasPendingPasswordResetRequest" type="danger" round>
|
||||
请求重置
|
||||
</ElTag>
|
||||
<span v-if="!row.mustChangePassword && !row.hasPendingPasswordResetRequest" class="muted">
|
||||
<span
|
||||
v-if="!row.mustChangePassword && !row.hasPendingPasswordResetRequest"
|
||||
class="muted"
|
||||
>
|
||||
正常
|
||||
</span>
|
||||
</div>
|
||||
@@ -763,7 +717,11 @@ function formatDateTime(value?: string) {
|
||||
<ElTableColumn label="操作" width="330" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="row-actions">
|
||||
<ElButton size="small" :disabled="!canMutate(row)" @click="openPermissionDialog(row)">
|
||||
<ElButton
|
||||
size="small"
|
||||
:disabled="!canMutate(row)"
|
||||
@click="openPermissionDialog(row)"
|
||||
>
|
||||
权限
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@@ -774,11 +732,7 @@ function formatDateTime(value?: string) {
|
||||
>
|
||||
重置
|
||||
</ElButton>
|
||||
<ElButton
|
||||
size="small"
|
||||
:disabled="!canMutate(row)"
|
||||
@click="toggleStatus(row)"
|
||||
>
|
||||
<ElButton size="small" :disabled="!canMutate(row)" @click="toggleStatus(row)">
|
||||
{{ row.status === 'active' ? '禁用' : '启用' }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
@@ -852,10 +806,7 @@ function formatDateTime(value?: string) {
|
||||
{{ groupPermissionSummary(group) }}
|
||||
</span>
|
||||
</button>
|
||||
<div
|
||||
v-show="isPermissionGroupExpanded(group.key)"
|
||||
class="permission-project-list"
|
||||
>
|
||||
<div v-show="isPermissionGroupExpanded(group.key)" class="permission-project-list">
|
||||
<div
|
||||
v-for="project in group.children"
|
||||
:key="project.key"
|
||||
@@ -910,63 +861,11 @@ function formatDateTime(value?: string) {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.member-overview-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
.message-disclosure summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.member-overview-card {
|
||||
min-width: 0;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #d8e2ef;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.member-overview-card span {
|
||||
display: block;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.member-overview-card strong {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: #0f172a;
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.member-overview-card.tone-active {
|
||||
border-color: #bfdbfe;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.member-overview-card.tone-success {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
|
||||
.member-overview-card.tone-warning {
|
||||
border-color: #fde68a;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.member-overview-card.tone-danger {
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
.message-filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.message-filter-bar .el-select {
|
||||
width: 160px;
|
||||
.message-disclosure:not([open]) summary {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.member-filter-bar {
|
||||
@@ -1214,17 +1113,12 @@ function formatDateTime(value?: string) {
|
||||
}
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
.member-overview-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.member-filter-bar {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.member-overview-grid,
|
||||
.member-filter-bar,
|
||||
.member-form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
+248
-685
@@ -1,734 +1,297 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Cpu,
|
||||
Failed,
|
||||
Finished,
|
||||
Promotion,
|
||||
Refresh,
|
||||
Tickets,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { computed } from 'vue'
|
||||
import type { RouteLocationRaw } from 'vue-router'
|
||||
import MetricTile from '../components/MetricTile.vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { useAssistantStore } from '../stores/assistant'
|
||||
import { usePlatformStore } from '../stores/platform'
|
||||
import type { HealthState, ProjectConfig, ReleaseRun } from '../types/devops'
|
||||
import { formatTime, latestRunsByEnvironment } from '../utils/releases'
|
||||
import type { ReleaseRun } from '../types/devops'
|
||||
|
||||
const platform = usePlatformStore()
|
||||
|
||||
const successCount = computed(() => platform.runs.filter((run) => run.status === 'success').length)
|
||||
const failedCount = computed(() => platform.failedRuns.length)
|
||||
const runningCount = computed(() => platform.runningRuns.length)
|
||||
const readyProjectCount = computed(
|
||||
() => platform.projects.filter((project) => projectReadinessState(project) === 'ready').length,
|
||||
const assistant = useAssistantStore()
|
||||
const question = ref('')
|
||||
const search = ref('')
|
||||
const filter = ref<'all' | 'active' | 'failed'>('all')
|
||||
const latest = computed(() => latestRunsByEnvironment(platform.runs))
|
||||
const projectRows = computed(() =>
|
||||
platform.projects
|
||||
.map((project) => {
|
||||
const active = platform.runningRuns.filter((run) => run.projectKey === project.key)
|
||||
const last = platform.runs.find((run) => run.projectKey === project.key)
|
||||
const run: ReleaseRun | undefined = active[0] || last
|
||||
const failed = [...latest.value.values()].some(
|
||||
(run) => run.projectKey === project.key && run.status === 'failed',
|
||||
)
|
||||
return { project, run, activeCount: active.length, failed }
|
||||
})
|
||||
.filter(
|
||||
(row) =>
|
||||
`${row.project.key} ${row.project.name}`
|
||||
.toLowerCase()
|
||||
.includes(search.value.trim().toLowerCase()) &&
|
||||
(filter.value === 'all' ||
|
||||
(filter.value === 'active' && row.activeCount > 0) ||
|
||||
(filter.value === 'failed' && row.failed)),
|
||||
)
|
||||
.sort((a, b) => Number(b.activeCount > 0) - Number(a.activeCount > 0)),
|
||||
)
|
||||
const blockedProjects = computed(
|
||||
() => platform.projects.filter((project) => projectReadinessState(project) === 'blocked'),
|
||||
)
|
||||
const attentionProjects = computed(
|
||||
() => platform.projects.filter((project) => projectReadinessState(project) === 'attention'),
|
||||
)
|
||||
const notificationAttentionCount = computed(
|
||||
() =>
|
||||
platform.notificationOutbox.filter(
|
||||
(item) => item.status === 'pending' || item.status === 'failed' || item.status === 'dead',
|
||||
).length,
|
||||
)
|
||||
const integrationAttentionCount = computed(
|
||||
() => platform.integrationConfig.integrations.filter((item) => item.status !== 'configured').length,
|
||||
)
|
||||
|
||||
type ProjectReadinessState = 'ready' | 'attention' | 'blocked' | 'readonly'
|
||||
type FocusTone = 'success' | 'warning' | 'danger' | 'active' | 'neutral'
|
||||
type FocusItem = {
|
||||
key: string
|
||||
label: string
|
||||
value: string | number
|
||||
detail: string
|
||||
tone: FocusTone
|
||||
action: string
|
||||
to: RouteLocationRaw
|
||||
}
|
||||
|
||||
const focusItems = computed<FocusItem[]>(() => {
|
||||
const items: FocusItem[] = []
|
||||
|
||||
if (failedCount.value > 0) {
|
||||
items.push({
|
||||
key: 'failed-runs',
|
||||
label: '失败待诊断',
|
||||
value: failedCount.value,
|
||||
detail: '优先查看失败节点、日志摘要和复盘材料。',
|
||||
tone: 'danger',
|
||||
action: '查看失败 Run',
|
||||
to: { name: 'runs' },
|
||||
})
|
||||
const activeCount = computed(() => new Set(platform.runningRuns.map((run) => run.projectKey)).size)
|
||||
function ask() {
|
||||
if (question.value.trim() && !assistant.pending) {
|
||||
assistant.open(question.value)
|
||||
question.value = ''
|
||||
}
|
||||
|
||||
if (runningCount.value > 0) {
|
||||
items.push({
|
||||
key: 'running-runs',
|
||||
label: '执行中发布',
|
||||
value: runningCount.value,
|
||||
detail: '关注 Jenkins queue/build 状态和流程节点推进。',
|
||||
tone: 'active',
|
||||
action: '查看进度',
|
||||
to: { name: 'runs' },
|
||||
})
|
||||
}
|
||||
|
||||
if (blockedProjects.value.length > 0) {
|
||||
items.push({
|
||||
key: 'blocked-projects',
|
||||
label: '项目阻断',
|
||||
value: blockedProjects.value.length,
|
||||
detail: 'Gitea、Webhook、Jenkins 或通知链路存在阻断。',
|
||||
tone: 'danger',
|
||||
action: '查看项目',
|
||||
to: { name: 'projects' },
|
||||
})
|
||||
}
|
||||
|
||||
if (attentionProjects.value.length > 0) {
|
||||
items.push({
|
||||
key: 'attention-projects',
|
||||
label: '配置关注',
|
||||
value: attentionProjects.value.length,
|
||||
detail: '存在待配置项,生产发布前需要复核。',
|
||||
tone: 'warning',
|
||||
action: '定位配置',
|
||||
to: { name: 'projects' },
|
||||
})
|
||||
}
|
||||
|
||||
if (notificationAttentionCount.value > 0) {
|
||||
items.push({
|
||||
key: 'notification-outbox',
|
||||
label: '通知待排查',
|
||||
value: notificationAttentionCount.value,
|
||||
detail: '通知 outbox 存在待投递、失败或终止记录。',
|
||||
tone: 'warning',
|
||||
action: '查看 outbox',
|
||||
to: { name: 'settings' },
|
||||
})
|
||||
}
|
||||
|
||||
if (integrationAttentionCount.value > 0) {
|
||||
items.push({
|
||||
key: 'integration-config',
|
||||
label: '集成缺口',
|
||||
value: integrationAttentionCount.value,
|
||||
detail: '系统配置中存在未配置或部分配置的集成项。',
|
||||
tone: 'warning',
|
||||
action: '查看系统配置',
|
||||
to: { name: 'settings' },
|
||||
})
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
return items
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
key: 'stable',
|
||||
label: '当前稳定',
|
||||
value: 'OK',
|
||||
detail: '未发现失败 run、项目阻断或待处理通知。',
|
||||
tone: 'success',
|
||||
action: '查看项目',
|
||||
to: { name: 'projects' },
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const priorityRuns = computed(() => {
|
||||
return [...platform.runs]
|
||||
.sort((left, right) => {
|
||||
const priorityDiff = runPriority(left) - runPriority(right)
|
||||
|
||||
if (priorityDiff !== 0) {
|
||||
return priorityDiff
|
||||
}
|
||||
|
||||
return dateValue(right.startedAt) - dateValue(left.startedAt)
|
||||
})
|
||||
.slice(0, 5)
|
||||
})
|
||||
|
||||
const projectAttentionQueue = computed(() => {
|
||||
return [...blockedProjects.value, ...attentionProjects.value]
|
||||
.filter((project, index, list) => list.findIndex((item) => item.key === project.key) === index)
|
||||
.slice(0, 5)
|
||||
})
|
||||
|
||||
function runPriority(run: ReleaseRun): number {
|
||||
const priority: Record<ReleaseRun['status'], number> = {
|
||||
failed: 0,
|
||||
running: 1,
|
||||
queued: 2,
|
||||
canceled: 3,
|
||||
success: 4,
|
||||
idle: 5,
|
||||
}
|
||||
|
||||
return priority[run.status] ?? 6
|
||||
}
|
||||
|
||||
function dateValue(value?: string): number {
|
||||
if (!value || value === '-') {
|
||||
return 0
|
||||
}
|
||||
|
||||
const date = new Date(value)
|
||||
return Number.isNaN(date.getTime()) ? 0 : date.getTime()
|
||||
}
|
||||
|
||||
function formatRunTime(value?: string): string {
|
||||
if (!value || value === '-') {
|
||||
return '-'
|
||||
}
|
||||
|
||||
const date = new Date(value)
|
||||
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return value
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(date)
|
||||
}
|
||||
|
||||
function projectReadinessState(project: ProjectConfig): ProjectReadinessState {
|
||||
if (projectHasBlockingIssue(project)) {
|
||||
return 'blocked'
|
||||
}
|
||||
|
||||
if (projectHasWarningIssue(project)) {
|
||||
return 'attention'
|
||||
}
|
||||
|
||||
if (!platform.canBuildProject(project.key)) {
|
||||
return 'readonly'
|
||||
}
|
||||
|
||||
return 'ready'
|
||||
}
|
||||
|
||||
function projectReadinessLabel(project: ProjectConfig): string {
|
||||
const state = projectReadinessState(project)
|
||||
|
||||
if (state === 'ready') {
|
||||
return '可发布'
|
||||
}
|
||||
|
||||
if (state === 'blocked') {
|
||||
return '有阻断'
|
||||
}
|
||||
|
||||
if (state === 'readonly') {
|
||||
return '只读'
|
||||
}
|
||||
|
||||
return '需关注'
|
||||
}
|
||||
|
||||
function projectReadinessTagType(
|
||||
project: ProjectConfig,
|
||||
): 'success' | 'warning' | 'danger' | 'info' {
|
||||
const state = projectReadinessState(project)
|
||||
|
||||
if (state === 'ready') {
|
||||
return 'success'
|
||||
}
|
||||
|
||||
if (state === 'blocked') {
|
||||
return 'danger'
|
||||
}
|
||||
|
||||
return state === 'attention' ? 'warning' : 'info'
|
||||
}
|
||||
|
||||
function projectReadinessSummary(project: ProjectConfig): string {
|
||||
const issues = projectIssueSummaries(project)
|
||||
|
||||
if (issues.length > 0) {
|
||||
return issues[0]
|
||||
}
|
||||
|
||||
if (!platform.canBuildProject(project.key)) {
|
||||
return '当前账号只有只读权限'
|
||||
}
|
||||
|
||||
return '发布链路可用'
|
||||
}
|
||||
|
||||
function projectIssueSummaries(project: ProjectConfig): string[] {
|
||||
const issues: string[] = []
|
||||
|
||||
appendHealthIssue(issues, 'Gitea 仓库', project.giteaStatus, project.giteaMessage)
|
||||
appendHealthIssue(issues, 'Webhook / Relay', project.giteaWebhookStatus, project.giteaWebhookMessage)
|
||||
|
||||
for (const env of project.environments) {
|
||||
appendHealthIssue(issues, `${env.label} Jenkins`, env.jenkinsStatus, env.jenkinsMessage)
|
||||
}
|
||||
|
||||
appendHealthIssue(issues, '通知链路', project.integrations.wecom)
|
||||
|
||||
return issues
|
||||
}
|
||||
|
||||
function appendHealthIssue(
|
||||
issues: string[],
|
||||
label: string,
|
||||
state: HealthState,
|
||||
message?: string,
|
||||
) {
|
||||
if (state === 'healthy') {
|
||||
return
|
||||
}
|
||||
|
||||
const stateText = state === 'warning' ? '待配置' : state === 'offline' ? '离线' : '异常'
|
||||
issues.push(`${label}${message ? `:${message}` : `:${stateText}`}`)
|
||||
}
|
||||
|
||||
function projectHasBlockingIssue(project: ProjectConfig): boolean {
|
||||
return projectHealthStates(project).some((state) => state === 'error' || state === 'offline')
|
||||
}
|
||||
|
||||
function projectHasWarningIssue(project: ProjectConfig): boolean {
|
||||
return projectHealthStates(project).some((state) => state === 'warning')
|
||||
}
|
||||
|
||||
function projectHealthStates(project: ProjectConfig): HealthState[] {
|
||||
return [
|
||||
project.giteaStatus,
|
||||
project.giteaWebhookStatus,
|
||||
project.integrations.wecom,
|
||||
...project.environments.map((env) => env.jenkinsStatus),
|
||||
]
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-shell">
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>运维总览</h1>
|
||||
<p>集中查看纳管项目环境、待处理发布、Jenkins/Gitea/通知平台/LLM 当前状态。</p>
|
||||
</div>
|
||||
<ElButton :icon="Refresh" type="primary" plain :loading="platform.loading" @click="platform.loadAll">
|
||||
刷新数据
|
||||
</ElButton>
|
||||
<div class="page-shell deployment-home">
|
||||
<form class="ask-bar" @submit.prevent="ask">
|
||||
<ElInput
|
||||
v-model="question"
|
||||
aria-label="向运维助手提问"
|
||||
placeholder="问问最近部署、项目情况或失败原因…"
|
||||
maxlength="2000"
|
||||
/><ElButton
|
||||
:disabled="!question.trim() || assistant.pending"
|
||||
:loading="assistant.pending"
|
||||
native-type="submit"
|
||||
>问助手 ↗</ElButton
|
||||
>
|
||||
</form>
|
||||
<div class="project-heading">
|
||||
<h1>项目</h1>
|
||||
<span v-if="activeCount" class="active-count">{{ activeCount }} 个项目正在部署</span
|
||||
><span v-else class="muted">当前没有部署任务</span
|
||||
><span v-if="platform.runningRuns.length" class="refresh-hint">执行中自动更新</span>
|
||||
</div>
|
||||
|
||||
<div class="status-grid">
|
||||
<MetricTile label="纳管项目" :value="platform.projects.length" caption="含 DevOps 平台自管理项目" :icon="Cpu" />
|
||||
<MetricTile label="可发布项目" :value="readyProjectCount" caption="无阻断且当前账号可构建" :icon="Promotion" tone="success" />
|
||||
<MetricTile label="运行中发布" :value="runningCount" caption="当前 Jenkins 或健康检查处理中" :icon="Finished" tone="warning" />
|
||||
<MetricTile label="失败提醒" :value="failedCount" caption="需要诊断或重试的 run" :icon="Failed" tone="danger" />
|
||||
</div>
|
||||
|
||||
<div class="section-grid">
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>值班焦点</h2>
|
||||
<span>{{ focusItems.length }} 项</span>
|
||||
<section class="panel project-list">
|
||||
<div class="list-toolbar">
|
||||
<div class="list-tabs" role="group" aria-label="部署筛选">
|
||||
<button :aria-pressed="filter === 'all'" @click="filter = 'all'">全部</button
|
||||
><button :aria-pressed="filter === 'active'" @click="filter = 'active'">部署中</button
|
||||
><button :aria-pressed="filter === 'failed'" @click="filter = 'failed'">最近失败</button>
|
||||
</div>
|
||||
<div class="panel-body focus-list">
|
||||
<div
|
||||
v-for="item in focusItems"
|
||||
:key="item.key"
|
||||
class="focus-row"
|
||||
:class="`tone-${item.tone}`"
|
||||
>
|
||||
<div class="focus-main">
|
||||
<span>{{ item.label }}</span>
|
||||
<strong>{{ item.value }}</strong>
|
||||
<small>{{ item.detail }}</small>
|
||||
</div>
|
||||
<RouterLink v-slot="{ navigate }" custom :to="item.to">
|
||||
<ElButton link type="primary" @click="navigate">{{ item.action }}</ElButton>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>优先 Run 队列</h2>
|
||||
<span>{{ priorityRuns.length }} / {{ platform.runs.length }} 条</span>
|
||||
</div>
|
||||
<div class="panel-body compact-list">
|
||||
<div v-for="run in priorityRuns" :key="run.id" class="list-row run-row">
|
||||
<span>
|
||||
<strong>{{ run.projectName }} · {{ run.ref }}</strong>
|
||||
<small>{{ run.environment }} · {{ run.actor }} · {{ formatRunTime(run.startedAt) }} · {{ run.duration }}</small>
|
||||
</span>
|
||||
<div class="row-actions">
|
||||
<StatusPill :state="run.status" />
|
||||
<RouterLink :to="{ name: 'runs', query: { runId: run.id } }">
|
||||
<ElButton :icon="Tickets" link type="primary">详情</ElButton>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<ElEmpty v-if="priorityRuns.length === 0" description="暂无运行记录" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>项目发布健康</h2>
|
||||
<span>{{ readyProjectCount }} / {{ platform.projects.length }} 个项目可发布</span>
|
||||
<ElInput
|
||||
v-model="search"
|
||||
:prefix-icon="Search"
|
||||
aria-label="搜索项目"
|
||||
placeholder="搜索项目…"
|
||||
clearable
|
||||
class="project-search"
|
||||
/>
|
||||
</div>
|
||||
<div class="panel-body project-attention-grid">
|
||||
<article class="health-summary-card">
|
||||
<span>成功记录</span>
|
||||
<strong>{{ successCount }}</strong>
|
||||
<small>最近发布成功数</small>
|
||||
</article>
|
||||
<article class="health-summary-card warning">
|
||||
<span>需关注</span>
|
||||
<strong>{{ attentionProjects.length }}</strong>
|
||||
<small>存在待配置项</small>
|
||||
</article>
|
||||
<article class="health-summary-card danger">
|
||||
<span>有阻断</span>
|
||||
<strong>{{ blockedProjects.length }}</strong>
|
||||
<small>发布前需要处理</small>
|
||||
</article>
|
||||
<div class="attention-list">
|
||||
<div v-if="projectAttentionQueue.length === 0" class="attention-empty">
|
||||
<strong>项目链路当前稳定</strong>
|
||||
<span>纳管项目未发现阻断或关注项。</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="project in projectAttentionQueue"
|
||||
:key="project.key"
|
||||
class="attention-row"
|
||||
>
|
||||
<div>
|
||||
<strong>{{ project.name }}</strong>
|
||||
<small>{{ projectReadinessSummary(project) }}</small>
|
||||
</div>
|
||||
<div class="row-actions">
|
||||
<ElTag :type="projectReadinessTagType(project)" effect="light" round>
|
||||
{{ projectReadinessLabel(project) }}
|
||||
</ElTag>
|
||||
<RouterLink :to="{ name: 'projects' }">
|
||||
<ElButton link type="primary">查看</ElButton>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<article
|
||||
v-for="row in projectRows"
|
||||
:key="row.project.key"
|
||||
class="project-row"
|
||||
:class="{ deploying: row.activeCount }"
|
||||
>
|
||||
<div class="project-name">
|
||||
<strong>{{ row.project.name }}</strong
|
||||
><small v-if="row.run"
|
||||
>{{ row.run.environment === 'production' ? '生产' : '测试' }} ·
|
||||
<span class="mono">{{ row.run.ref }}</span
|
||||
><span v-if="row.activeCount > 1"> · 另有 {{ row.activeCount - 1 }} 个任务</span></small
|
||||
><small v-else>尚无发布记录</small>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>项目环境</h2>
|
||||
<span>测试/生产状态和快捷入口</span>
|
||||
</div>
|
||||
<div class="project-grid panel-body">
|
||||
<article
|
||||
v-for="project in platform.projects"
|
||||
:key="project.key"
|
||||
class="project-card"
|
||||
:class="`readiness-${projectReadinessState(project)}`"
|
||||
>
|
||||
<div class="project-head">
|
||||
<div>
|
||||
<strong>{{ project.name }}</strong>
|
||||
<small>{{ project.serviceType }}</small>
|
||||
</div>
|
||||
<ElTag type="info" round>{{ project.defaultBranch }}</ElTag>
|
||||
</div>
|
||||
<div class="project-readiness">
|
||||
<ElTag :type="projectReadinessTagType(project)" effect="light" round>
|
||||
{{ projectReadinessLabel(project) }}
|
||||
</ElTag>
|
||||
<small>{{ projectReadinessSummary(project) }}</small>
|
||||
</div>
|
||||
<div class="compact-list">
|
||||
<div v-for="env in project.environments" :key="env.name" class="env-row">
|
||||
<span>
|
||||
<strong>{{ env.label }}</strong>
|
||||
<small>{{ env.version }} · {{ env.lastReleasedAt }}</small>
|
||||
</span>
|
||||
<StatusPill :state="env.status" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="project-card-actions">
|
||||
<RouterLink
|
||||
v-slot="{ navigate }"
|
||||
custom
|
||||
:to="{ name: 'releases', query: { projectKey: project.key } }"
|
||||
>
|
||||
<ElButton
|
||||
:icon="Promotion"
|
||||
link
|
||||
type="primary"
|
||||
:disabled="!platform.canBuildProject(project.key)"
|
||||
@click="navigate"
|
||||
>
|
||||
发布
|
||||
</ElButton>
|
||||
</RouterLink>
|
||||
<RouterLink :to="{ name: 'runs', query: { projectKey: project.key } }">
|
||||
<ElButton :icon="Tickets" link type="primary">运行记录</ElButton>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</article>
|
||||
<StatusPill v-if="row.run" :state="row.run.status" /><span v-else class="no-status">—</span
|
||||
><time>{{ formatTime(row.run?.startedAt) }}</time
|
||||
><RouterLink
|
||||
v-if="row.run"
|
||||
class="log-link"
|
||||
:to="{ name: 'runs', query: { runId: row.run.id } }"
|
||||
>查看日志 →</RouterLink
|
||||
><span v-else class="no-log">暂无日志</span>
|
||||
</article>
|
||||
<div v-if="!projectRows.length" class="quiet-empty">
|
||||
<strong>{{ search || filter !== 'all' ? '没有匹配的项目' : '暂无可访问的项目' }}</strong>
|
||||
<p>{{ search || filter !== 'all' ? '调整筛选后再试。' : '请联系管理员分配项目权限。' }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.focus-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
.deployment-home {
|
||||
gap: 23px;
|
||||
}
|
||||
|
||||
.focus-row {
|
||||
.ask-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 86px;
|
||||
padding: 14px;
|
||||
border: 1px solid #e3e8f2;
|
||||
border-radius: 8px;
|
||||
background: #fbfcff;
|
||||
padding: 10px 12px 10px 18px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 9px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.focus-row.tone-danger {
|
||||
border-color: #fecaca;
|
||||
background: #fff7f7;
|
||||
.ask-bar :deep(.el-input__wrapper) {
|
||||
box-shadow: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.focus-row.tone-warning {
|
||||
border-color: #fde68a;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.focus-row.tone-active {
|
||||
border-color: #bfdbfe;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.focus-row.tone-success {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
|
||||
.focus-main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.focus-main span,
|
||||
.health-summary-card span {
|
||||
display: block;
|
||||
color: #64748b;
|
||||
.ask-bar :deep(.el-input__inner) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.focus-main strong,
|
||||
.health-summary-card strong {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: #0f172a;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.focus-main small,
|
||||
.health-summary-card small {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: #64748b;
|
||||
.ask-bar .el-button {
|
||||
flex-shrink: 0;
|
||||
border-color: transparent;
|
||||
color: var(--accent);
|
||||
background: #f4f2fa;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.row-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.run-row {
|
||||
min-height: 68px;
|
||||
}
|
||||
|
||||
.project-attention-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(140px, 0.35fr)) minmax(320px, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.health-summary-card {
|
||||
min-width: 0;
|
||||
padding: 14px;
|
||||
border: 1px solid #d8e2ef;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.health-summary-card.warning {
|
||||
border-color: #fde68a;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.health-summary-card.danger {
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
.attention-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.attention-row,
|
||||
.attention-empty {
|
||||
.project-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 68px;
|
||||
padding: 12px;
|
||||
border: 1px solid #e3e8f2;
|
||||
border-radius: 8px;
|
||||
background: #fbfcff;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.attention-row strong,
|
||||
.attention-empty strong {
|
||||
display: block;
|
||||
color: #172033;
|
||||
font-size: 14px;
|
||||
.project-heading h1 {
|
||||
margin: 0;
|
||||
font-size: 21px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.attention-row small,
|
||||
.attention-empty span {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
.project-heading > span {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.project-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.project-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 14px;
|
||||
border: 1px solid #e3e8f2;
|
||||
border-radius: 8px;
|
||||
background: #fbfcff;
|
||||
}
|
||||
|
||||
.project-card.readiness-blocked {
|
||||
border-color: #fecaca;
|
||||
background: #fffafa;
|
||||
}
|
||||
|
||||
.project-card.readiness-attention {
|
||||
border-color: #fde68a;
|
||||
background: #fffdf5;
|
||||
}
|
||||
|
||||
.project-head,
|
||||
.env-row {
|
||||
display: flex;
|
||||
.active-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.project-head {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.project-head strong,
|
||||
.env-row strong {
|
||||
display: block;
|
||||
color: #172033;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.project-head small,
|
||||
.env-row small {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: #7b8798;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.env-row {
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.project-readiness {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
min-height: 54px;
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.project-readiness small {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
.active-count::before {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
content: '';
|
||||
}
|
||||
|
||||
.project-card-actions {
|
||||
.refresh-hint {
|
||||
color: var(--text-muted);
|
||||
margin-left: auto;
|
||||
}
|
||||
.list-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: auto;
|
||||
padding-top: 2px;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 15px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
.project-grid,
|
||||
.project-attention-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
.list-tabs {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
}
|
||||
.list-tabs button {
|
||||
border: 0;
|
||||
padding: 6px 0;
|
||||
color: var(--text-muted);
|
||||
background: transparent;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.list-tabs button[aria-pressed='true'] {
|
||||
color: var(--accent);
|
||||
font-weight: 550;
|
||||
}
|
||||
.project-search {
|
||||
max-width: 180px;
|
||||
}
|
||||
.project-search :deep(.el-input__wrapper) {
|
||||
box-shadow: none;
|
||||
background: #f7f7fa;
|
||||
}
|
||||
.project-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(200px, 1fr) 85px 135px 100px;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
padding: 15px 24px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.project-row:last-of-type {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.project-row.deploying {
|
||||
background: #fcfbff;
|
||||
}
|
||||
.project-name {
|
||||
min-width: 0;
|
||||
}
|
||||
.project-name strong {
|
||||
font-size: 13px;
|
||||
font-weight: 550;
|
||||
color: #353c49;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.project-name small {
|
||||
display: block;
|
||||
margin-top: 7px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.project-row time {
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.log-link {
|
||||
justify-self: end;
|
||||
font-size: 12px;
|
||||
color: var(--accent);
|
||||
}
|
||||
.log-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.no-status,
|
||||
.no-log {
|
||||
color: #9b9fac;
|
||||
font-size: 11px;
|
||||
}
|
||||
.no-log {
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.project-grid,
|
||||
.project-attention-grid {
|
||||
grid-template-columns: 1fr;
|
||||
.project-row {
|
||||
grid-template-columns: minmax(140px, 1fr) 72px 85px;
|
||||
gap: 12px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.focus-row,
|
||||
.attention-row,
|
||||
.attention-empty {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
.project-row time {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.row-actions {
|
||||
justify-content: flex-start;
|
||||
.list-toolbar {
|
||||
padding: 13px 16px;
|
||||
}
|
||||
.project-search {
|
||||
max-width: 145px;
|
||||
}
|
||||
.list-tabs {
|
||||
gap: 14px;
|
||||
}
|
||||
.refresh-hint {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 430px) {
|
||||
.list-toolbar {
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.project-search {
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
}
|
||||
.project-row {
|
||||
padding: 20px 16px;
|
||||
grid-template-columns: minmax(120px, 1fr) 60px 76px;
|
||||
gap: 10px;
|
||||
}
|
||||
.log-link {
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+206
-674
@@ -1,269 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 项目配置页展示项目仓库、发布环境、Gitea 仓库诊断和真实 Jenkins job 诊断状态。
|
||||
*/
|
||||
import { Promotion, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Search, Refresh } from '@element-plus/icons-vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { usePlatformStore } from '../stores/platform'
|
||||
import type { EnvironmentStatus, HealthState, ProjectConfig, ProjectPermissionLevel } from '../types/devops'
|
||||
import { useSessionStore } from '../stores/session'
|
||||
import type { ProjectConfig } from '../types/devops'
|
||||
|
||||
const platform = usePlatformStore()
|
||||
const diagnosticsLoading = ref(false)
|
||||
const searchKeyword = ref('')
|
||||
const readinessFilter = ref<ProjectReadinessState | ''>('')
|
||||
const permissionFilter = ref<ProjectPermissionLevel | ''>('')
|
||||
|
||||
type ProjectReadinessState = 'ready' | 'attention' | 'blocked' | 'readonly'
|
||||
|
||||
const readinessOptions: Array<{ label: string; value: ProjectReadinessState }> = [
|
||||
{ label: '可发布', value: 'ready' },
|
||||
{ label: '需关注', value: 'attention' },
|
||||
{ label: '有阻断', value: 'blocked' },
|
||||
{ label: '只读', value: 'readonly' },
|
||||
]
|
||||
|
||||
const permissionOptions: Array<{ label: string; value: ProjectPermissionLevel }> = [
|
||||
{ label: '构建权限', value: 'build' },
|
||||
{ label: '只读权限', value: 'read' },
|
||||
]
|
||||
|
||||
const filteredProjects = computed(() => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase()
|
||||
|
||||
return platform.projects.filter((project) => {
|
||||
if (readinessFilter.value && projectReadinessState(project) !== readinessFilter.value) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (permissionFilter.value && platform.projectPermissionLevel(project.key) !== permissionFilter.value) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!keyword) {
|
||||
return true
|
||||
}
|
||||
|
||||
return [
|
||||
project.name,
|
||||
project.key,
|
||||
project.serviceType,
|
||||
project.repository,
|
||||
project.defaultBranch,
|
||||
project.tagPolicy,
|
||||
project.permissionLevelName,
|
||||
]
|
||||
.filter((value): value is string => typeof value === 'string' && value.length > 0)
|
||||
.some((value) => value.toLowerCase().includes(keyword))
|
||||
})
|
||||
})
|
||||
|
||||
const projectOverview = computed(() => {
|
||||
const ready = platform.projects.filter((project) => projectReadinessState(project) === 'ready').length
|
||||
const attention = platform.projects.filter((project) => projectReadinessState(project) === 'attention').length
|
||||
const blocked = platform.projects.filter((project) => projectReadinessState(project) === 'blocked').length
|
||||
const readOnly = platform.projects.filter((project) => projectReadinessState(project) === 'readonly').length
|
||||
|
||||
return [
|
||||
{ key: 'total', label: '纳管项目', value: platform.projects.length, tone: 'neutral' },
|
||||
{ key: 'ready', label: '可发布', value: ready, tone: 'success' },
|
||||
{ key: 'attention', label: '需关注', value: attention, tone: attention > 0 ? 'warning' : 'neutral' },
|
||||
{ key: 'blocked', label: '有阻断', value: blocked, tone: blocked > 0 ? 'danger' : 'neutral' },
|
||||
{ key: 'readonly', label: '只读项目', value: readOnly, tone: readOnly > 0 ? 'muted' : 'neutral' },
|
||||
]
|
||||
})
|
||||
|
||||
const hasActiveFilters = computed(() => Boolean(
|
||||
searchKeyword.value.trim() ||
|
||||
readinessFilter.value ||
|
||||
permissionFilter.value,
|
||||
))
|
||||
|
||||
onMounted(() => {
|
||||
void refreshProjectDiagnostics()
|
||||
})
|
||||
|
||||
async function refreshProjectDiagnostics() {
|
||||
diagnosticsLoading.value = true
|
||||
|
||||
try {
|
||||
await Promise.all([
|
||||
platform.loadProjectJenkinsDiagnostics(),
|
||||
platform.loadProjectGiteaDiagnostics(),
|
||||
])
|
||||
} finally {
|
||||
diagnosticsLoading.value = false
|
||||
}
|
||||
const session = useSessionStore()
|
||||
const search = ref('')
|
||||
const route = useRoute()
|
||||
const selectedKey = ref(typeof route.query.projectKey === 'string' ? route.query.projectKey : '')
|
||||
watch(
|
||||
() => route.query.projectKey,
|
||||
(key) => {
|
||||
if (typeof key === 'string') selectedKey.value = key
|
||||
},
|
||||
)
|
||||
const diagnosing = ref(false)
|
||||
const diagnosisError = ref('')
|
||||
const selected = computed(() =>
|
||||
platform.projects.find((project) => project.key === selectedKey.value),
|
||||
)
|
||||
const projects = computed(() =>
|
||||
platform.projects.filter((project) =>
|
||||
`${project.name} ${project.repository}`
|
||||
.toLowerCase()
|
||||
.includes(search.value.trim().toLowerCase()),
|
||||
),
|
||||
)
|
||||
const hasDiagnostics = computed(() =>
|
||||
Boolean(platform.projectGiteaDiagnostics || platform.projectJenkinsDiagnostics),
|
||||
)
|
||||
function openProject(project: ProjectConfig) {
|
||||
selectedKey.value = project.key
|
||||
}
|
||||
|
||||
function lastBuildText(env: EnvironmentStatus): string {
|
||||
if (!env.jenkinsLastBuild?.number) {
|
||||
return '-'
|
||||
async function diagnose() {
|
||||
diagnosing.value = true
|
||||
diagnosisError.value = ''
|
||||
const results = await Promise.allSettled([
|
||||
platform.loadProjectGiteaDiagnostics(),
|
||||
platform.loadProjectJenkinsDiagnostics(),
|
||||
])
|
||||
const failures = results.filter((result) => result.status === 'rejected')
|
||||
if (failures.length) {
|
||||
diagnosisError.value = failures
|
||||
.map((result) => (result.reason instanceof Error ? result.reason.message : '诊断失败'))
|
||||
.join(';')
|
||||
ElMessage.error(diagnosisError.value)
|
||||
}
|
||||
|
||||
if (env.jenkinsLastBuild.building) {
|
||||
return `#${env.jenkinsLastBuild.number} 运行中`
|
||||
}
|
||||
|
||||
return `#${env.jenkinsLastBuild.number} ${env.jenkinsLastBuild.result || 'UNKNOWN'}`
|
||||
}
|
||||
|
||||
function commitText(project: ProjectConfig): string {
|
||||
const commit = project.giteaLatestCommit
|
||||
|
||||
if (!commit?.sha) {
|
||||
return '-'
|
||||
}
|
||||
|
||||
const title = commit.message.split('\n')[0] || '无提交说明'
|
||||
return `${commit.sha.slice(0, 8)} · ${title}`
|
||||
}
|
||||
|
||||
function branchTagText(project: ProjectConfig): string {
|
||||
if (project.giteaBranchCount === undefined && project.giteaTagCount === undefined) {
|
||||
return '尚未诊断'
|
||||
}
|
||||
|
||||
const branchCount = project.giteaBranchCount ?? 0
|
||||
const tagCount = project.giteaTagCount ?? 0
|
||||
|
||||
return `${branchCount} branches · ${tagCount} tags`
|
||||
}
|
||||
|
||||
function webhookCountText(project: ProjectConfig): string {
|
||||
if (
|
||||
project.giteaWebhookHookCount === undefined &&
|
||||
project.giteaWebhookActivePushHookCount === undefined
|
||||
) {
|
||||
return '尚未诊断'
|
||||
}
|
||||
|
||||
return `${project.giteaWebhookActivePushHookCount ?? 0}/${project.giteaWebhookHookCount ?? 0} 个 active push hook`
|
||||
}
|
||||
|
||||
function webhookHookText(hook: ProjectConfig['giteaWebhookHooks'][number]): string {
|
||||
const events = hook.events.length > 0 ? hook.events.join(', ') : '无事件'
|
||||
const branch = hook.branchFilter ? ` · ${hook.branchFilter}` : ''
|
||||
const matched = hook.matchesExpectedRelay ? ' · relay 匹配' : ''
|
||||
const active = hook.active ? '启用' : '停用'
|
||||
|
||||
return `#${hook.id} ${hook.type} · ${active} · ${events}${branch}${matched}`
|
||||
}
|
||||
|
||||
function projectReadinessState(project: ProjectConfig): ProjectReadinessState {
|
||||
if (projectHasBlockingIssue(project)) {
|
||||
return 'blocked'
|
||||
}
|
||||
|
||||
if (projectHasWarningIssue(project)) {
|
||||
return 'attention'
|
||||
}
|
||||
|
||||
if (!platform.canBuildProject(project.key)) {
|
||||
return 'readonly'
|
||||
}
|
||||
|
||||
return 'ready'
|
||||
}
|
||||
|
||||
function projectReadinessLabel(project: ProjectConfig): string {
|
||||
const state = projectReadinessState(project)
|
||||
|
||||
if (state === 'ready') {
|
||||
return '可发布'
|
||||
}
|
||||
|
||||
if (state === 'blocked') {
|
||||
return '有阻断'
|
||||
}
|
||||
|
||||
if (state === 'readonly') {
|
||||
return '只读'
|
||||
}
|
||||
|
||||
return '需关注'
|
||||
}
|
||||
|
||||
function projectReadinessTagType(
|
||||
project: ProjectConfig,
|
||||
): 'success' | 'warning' | 'danger' | 'info' {
|
||||
const state = projectReadinessState(project)
|
||||
|
||||
if (state === 'ready') {
|
||||
return 'success'
|
||||
}
|
||||
|
||||
if (state === 'blocked') {
|
||||
return 'danger'
|
||||
}
|
||||
|
||||
return state === 'attention' ? 'warning' : 'info'
|
||||
}
|
||||
|
||||
function projectReadinessSummary(project: ProjectConfig): string {
|
||||
const issues = projectIssueSummaries(project)
|
||||
|
||||
if (issues.length > 0) {
|
||||
return issues[0]
|
||||
}
|
||||
|
||||
if (!platform.canBuildProject(project.key)) {
|
||||
return '当前账号只有只读权限'
|
||||
}
|
||||
|
||||
return 'Gitea、Jenkins、Webhook 和通知链路均未发现异常'
|
||||
}
|
||||
|
||||
function projectIssueSummaries(project: ProjectConfig): string[] {
|
||||
const issues: string[] = []
|
||||
|
||||
appendHealthIssue(issues, 'Gitea 仓库', project.giteaStatus, project.giteaMessage)
|
||||
appendHealthIssue(issues, 'Webhook / Relay', project.giteaWebhookStatus, project.giteaWebhookMessage)
|
||||
|
||||
for (const env of project.environments) {
|
||||
appendHealthIssue(issues, `${env.label} Jenkins`, env.jenkinsStatus, env.jenkinsMessage)
|
||||
}
|
||||
|
||||
appendHealthIssue(issues, '通知链路', project.integrations.wecom)
|
||||
|
||||
return issues
|
||||
}
|
||||
|
||||
function appendHealthIssue(
|
||||
issues: string[],
|
||||
label: string,
|
||||
state: HealthState,
|
||||
message?: string,
|
||||
) {
|
||||
if (state === 'healthy') {
|
||||
return
|
||||
}
|
||||
|
||||
const stateText = state === 'warning' ? '待配置' : state === 'offline' ? '离线' : '异常'
|
||||
issues.push(`${label}${message ? `:${message}` : `:${stateText}`}`)
|
||||
}
|
||||
|
||||
function projectHasBlockingIssue(project: ProjectConfig): boolean {
|
||||
return projectHealthStates(project).some((state) => state === 'error' || state === 'offline')
|
||||
}
|
||||
|
||||
function projectHasWarningIssue(project: ProjectConfig): boolean {
|
||||
return projectHealthStates(project).some((state) => state === 'warning')
|
||||
}
|
||||
|
||||
function projectHealthStates(project: ProjectConfig): HealthState[] {
|
||||
return [
|
||||
project.giteaStatus,
|
||||
project.giteaWebhookStatus,
|
||||
project.integrations.wecom,
|
||||
...project.environments.map((env) => env.jenkinsStatus),
|
||||
]
|
||||
}
|
||||
|
||||
function resetProjectFilters() {
|
||||
searchKeyword.value = ''
|
||||
readinessFilter.value = ''
|
||||
permissionFilter.value = ''
|
||||
diagnosing.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -271,442 +59,186 @@ function resetProjectFilters() {
|
||||
<div class="page-shell">
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>项目配置</h1>
|
||||
<p>展示后端返回的项目、环境、Jenkins Job、Gitea 仓库和通知通道绑定关系。</p>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<ElTag type="info" round>后端配置源</ElTag>
|
||||
<ElButton
|
||||
:icon="Refresh"
|
||||
type="primary"
|
||||
plain
|
||||
:loading="diagnosticsLoading"
|
||||
@click="refreshProjectDiagnostics"
|
||||
>
|
||||
刷新项目诊断
|
||||
</ElButton>
|
||||
<h1>项目接入</h1>
|
||||
<p>查看仓库、发布环境与构建任务的对应关系。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="project-overview-grid">
|
||||
<article
|
||||
v-for="item in projectOverview"
|
||||
:key="item.key"
|
||||
class="project-overview-card"
|
||||
:class="`tone-${item.tone}`"
|
||||
<ElButton
|
||||
v-if="session.role === 'super_admin'"
|
||||
:icon="Refresh"
|
||||
:loading="diagnosing"
|
||||
@click="diagnose"
|
||||
>检查接入</ElButton
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
<strong>{{ item.value }}</strong>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<ElAlert
|
||||
v-if="diagnosisError"
|
||||
title="部分接入检查失败"
|
||||
:description="diagnosisError"
|
||||
type="error"
|
||||
:closable="false"
|
||||
/>
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>项目清单</h2>
|
||||
<span>{{ filteredProjects.length }} / {{ platform.projects.length }} 个项目</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="project-filter-bar">
|
||||
<ElInput
|
||||
v-model="searchKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
placeholder="搜索项目 / 仓库 / 默认分支"
|
||||
class="project-search-input"
|
||||
/>
|
||||
<ElSelect v-model="readinessFilter" clearable placeholder="发布态">
|
||||
<ElOption
|
||||
v-for="option in readinessOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElSelect v-model="permissionFilter" clearable placeholder="权限">
|
||||
<ElOption
|
||||
v-for="option in permissionOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElButton :disabled="!hasActiveFilters" @click="resetProjectFilters">
|
||||
重置筛选
|
||||
</ElButton>
|
||||
</div>
|
||||
<ElTable :data="filteredProjects" row-key="key" empty-text="没有符合条件的项目">
|
||||
<ElTableColumn type="expand">
|
||||
<template #default="{ row }">
|
||||
<div class="env-config">
|
||||
<div class="project-diagnostic-card">
|
||||
<div class="env-config-head">
|
||||
<strong>Gitea 仓库诊断</strong>
|
||||
<StatusPill :state="row.giteaStatus" />
|
||||
</div>
|
||||
<dl>
|
||||
<dt>仓库状态</dt>
|
||||
<dd>
|
||||
<StatusPill :state="row.giteaStatus" />
|
||||
<span class="diagnostic-message">{{ row.giteaMessage }}</span>
|
||||
</dd>
|
||||
<dt>公开地址</dt>
|
||||
<dd>
|
||||
<a
|
||||
v-if="row.giteaWebUrl"
|
||||
:href="row.giteaWebUrl"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
{{ row.giteaWebUrl }}
|
||||
</a>
|
||||
<span v-else class="mono">{{ row.repository }}</span>
|
||||
</dd>
|
||||
<dt>默认分支</dt>
|
||||
<dd>{{ row.giteaDefaultBranch || row.defaultBranch }}</dd>
|
||||
<dt>分支 / Tag</dt>
|
||||
<dd>{{ branchTagText(row) }}</dd>
|
||||
<dt>默认分支 commit</dt>
|
||||
<dd class="mono">{{ commitText(row) }}</dd>
|
||||
<dt>Webhook / Relay</dt>
|
||||
<dd>
|
||||
<StatusPill :state="row.giteaWebhookStatus" />
|
||||
<span class="diagnostic-message">{{ row.giteaWebhookMessage }}</span>
|
||||
</dd>
|
||||
<dt>Relay 目标</dt>
|
||||
<dd class="mono">{{ row.giteaWebhookExpectedRelayTarget || '-' }}</dd>
|
||||
<dt>Hook 数量</dt>
|
||||
<dd>{{ webhookCountText(row) }}</dd>
|
||||
<dt>Hook 明细</dt>
|
||||
<dd>
|
||||
<div v-if="row.giteaWebhookHooks.length > 0" class="webhook-hook-list">
|
||||
<div
|
||||
v-for="hook in row.giteaWebhookHooks"
|
||||
:key="hook.id"
|
||||
class="webhook-hook-item"
|
||||
>
|
||||
<span>{{ webhookHookText(hook) }}</span>
|
||||
<small class="mono">{{ hook.target || '-' }}</small>
|
||||
</div>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div v-for="env in row.environments" :key="env.name" class="env-config-card">
|
||||
<div class="env-config-head">
|
||||
<strong>{{ env.label }}</strong>
|
||||
<StatusPill :state="env.status" />
|
||||
</div>
|
||||
<dl>
|
||||
<dt>分支策略</dt>
|
||||
<dd>{{ env.branchPolicy }}</dd>
|
||||
<dt>Jenkins Job</dt>
|
||||
<dd class="mono">{{ env.jenkinsJob }}</dd>
|
||||
<dt>Job 状态</dt>
|
||||
<dd>
|
||||
<StatusPill :state="env.jenkinsStatus" />
|
||||
<span class="diagnostic-message">{{ env.jenkinsMessage }}</span>
|
||||
</dd>
|
||||
<dt>最近构建</dt>
|
||||
<dd>
|
||||
<a
|
||||
v-if="env.jenkinsLastBuild?.url"
|
||||
:href="env.jenkinsLastBuild.url"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
{{ lastBuildText(env) }}
|
||||
</a>
|
||||
<span v-else>{{ lastBuildText(env) }}</span>
|
||||
</dd>
|
||||
<dt>通知通道</dt>
|
||||
<dd>{{ env.wecomRobot }}</dd>
|
||||
<dt>最近发布</dt>
|
||||
<dd>
|
||||
<div v-if="env.lastRunId !== '-'" class="latest-release">
|
||||
<div class="latest-release-head">
|
||||
<StatusPill :state="env.status" />
|
||||
<RouterLink
|
||||
class="run-link mono"
|
||||
:to="{ name: 'runs', query: { runId: env.lastRunId } }"
|
||||
>
|
||||
{{ env.lastRunId }}
|
||||
</RouterLink>
|
||||
</div>
|
||||
<small>
|
||||
{{ env.version }} · {{ env.lastActor }} · {{ env.lastReleasedAt }}
|
||||
</small>
|
||||
</div>
|
||||
<span v-else>暂无真实发布记录</span>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="name" label="项目" min-width="150" />
|
||||
<ElTableColumn label="发布态" min-width="190">
|
||||
<template #default="{ row }">
|
||||
<div class="readiness-cell">
|
||||
<ElTag :type="projectReadinessTagType(row)" effect="light" round>
|
||||
{{ projectReadinessLabel(row) }}
|
||||
</ElTag>
|
||||
<small>{{ projectReadinessSummary(row) }}</small>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="权限" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="platform.canBuildProject(row.key) ? 'success' : 'info'" effect="plain" round>
|
||||
{{ platform.canBuildProject(row.key) ? '构建' : '只读' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="serviceType" label="类型" min-width="130" />
|
||||
<ElTableColumn prop="repository" label="Gitea 仓库" min-width="320">
|
||||
<template #default="{ row }">
|
||||
<span class="mono">{{ row.repository }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="defaultBranch" label="默认分支" width="120" />
|
||||
<ElTableColumn prop="tagPolicy" label="Tag 策略" min-width="220" />
|
||||
<ElTableColumn label="集成状态" width="280">
|
||||
<template #default="{ row }">
|
||||
<div class="status-tags">
|
||||
<StatusPill :state="row.integrations.jenkins" text="Jenkins" />
|
||||
<StatusPill :state="row.integrations.gitea" text="Gitea" />
|
||||
<StatusPill :state="row.integrations.wecom" text="通知" />
|
||||
<StatusPill :state="row.integrations.llm" text="LLM" />
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="操作" width="170" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="project-actions">
|
||||
<RouterLink
|
||||
v-slot="{ navigate }"
|
||||
custom
|
||||
:to="{ name: 'releases', query: { projectKey: row.key } }"
|
||||
>
|
||||
<ElButton
|
||||
:icon="Promotion"
|
||||
link
|
||||
type="primary"
|
||||
:disabled="!platform.canBuildProject(row.key)"
|
||||
@click="navigate"
|
||||
>
|
||||
发布
|
||||
</ElButton>
|
||||
</RouterLink>
|
||||
<RouterLink :to="{ name: 'runs', query: { projectKey: row.key } }">
|
||||
<ElButton link type="primary">运行记录</ElButton>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<h2>纳管项目 · {{ projects.length }}</h2>
|
||||
<ElInput
|
||||
v-model="search"
|
||||
:prefix-icon="Search"
|
||||
aria-label="搜索项目接入"
|
||||
placeholder="搜索项目或仓库…"
|
||||
clearable
|
||||
class="project-search"
|
||||
/>
|
||||
</div>
|
||||
<ElTable :data="projects" empty-text="没有可访问的项目">
|
||||
<ElTableColumn label="项目" min-width="210"
|
||||
><template #default="{ row }"
|
||||
><button class="project-name" @click="openProject(row)">{{ row.name }}</button>
|
||||
<div class="field-hint">{{ row.defaultBranch }}</div></template
|
||||
></ElTableColumn
|
||||
>
|
||||
<ElTableColumn label="仓库" min-width="190"
|
||||
><template #default="{ row }"
|
||||
><span class="mono">{{ row.owner }}/{{ row.repo }}</span></template
|
||||
></ElTableColumn
|
||||
>
|
||||
<ElTableColumn label="发布环境" min-width="150"
|
||||
><template #default="{ row }"
|
||||
><div class="toolbar">
|
||||
<ElTag
|
||||
v-for="environment in row.environments"
|
||||
:key="environment.name"
|
||||
type="info"
|
||||
effect="plain"
|
||||
>{{ environment.label }}</ElTag
|
||||
>
|
||||
</div></template
|
||||
></ElTableColumn
|
||||
>
|
||||
<ElTableColumn v-if="hasDiagnostics" label="接入检查" width="145"
|
||||
><template #default="{ row }"
|
||||
><StatusPill :state="row.giteaStatus" text="仓库" /><StatusPill
|
||||
:state="row.integrations.jenkins"
|
||||
text="构建" /></template
|
||||
></ElTableColumn>
|
||||
<ElTableColumn label="" width="100"
|
||||
><template #default="{ row }"
|
||||
><ElButton text @click="openProject(row)">查看配置</ElButton></template
|
||||
></ElTableColumn
|
||||
>
|
||||
</ElTable>
|
||||
</section>
|
||||
<p class="field-hint">
|
||||
项目与环境配置由服务端维护。需要新增项目或修改构建任务时,请更新服务端配置。
|
||||
</p>
|
||||
<ElDrawer
|
||||
:model-value="Boolean(selected)"
|
||||
:title="selected?.name || '项目配置'"
|
||||
size="520px"
|
||||
@close="selectedKey = ''"
|
||||
>
|
||||
<template v-if="selected">
|
||||
<dl class="project-details">
|
||||
<dt>代码仓库</dt>
|
||||
<dd>
|
||||
<a
|
||||
class="text-link"
|
||||
:href="selected.repository.replace(/\.git$/, '')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ selected.owner }}/{{ selected.repo }}</a
|
||||
>
|
||||
</dd>
|
||||
<dt>默认分支</dt>
|
||||
<dd class="mono">{{ selected.defaultBranch }}</dd>
|
||||
<dt>操作权限</dt>
|
||||
<dd>{{ platform.canBuildProject(selected.key) ? '可发布' : '只读' }}</dd>
|
||||
</dl>
|
||||
<section
|
||||
v-for="environment in selected.environments"
|
||||
:key="environment.name"
|
||||
class="environment-config"
|
||||
>
|
||||
<h2>{{ environment.label }}</h2>
|
||||
<dl class="project-details">
|
||||
<dt>构建任务</dt>
|
||||
<dd class="mono">{{ environment.jenkinsJob }}</dd>
|
||||
<dt>发布策略</dt>
|
||||
<dd>{{ environment.branchPolicy }}</dd>
|
||||
</dl>
|
||||
<p v-if="hasDiagnostics" class="field-hint">
|
||||
<StatusPill :state="environment.jenkinsStatus" /> {{ environment.jenkinsMessage }}
|
||||
</p>
|
||||
<RouterLink
|
||||
v-if="platform.canBuildProject(selected.key)"
|
||||
class="button-link"
|
||||
:to="{
|
||||
name: 'releases',
|
||||
query: { projectKey: selected.key, environment: environment.name },
|
||||
}"
|
||||
>发布到此环境</RouterLink
|
||||
>
|
||||
</section>
|
||||
<details v-if="hasDiagnostics" class="diagnostics">
|
||||
<summary>仓库与 Webhook 诊断</summary>
|
||||
<p>{{ selected.giteaMessage || '暂无仓库诊断' }}</p>
|
||||
<p>{{ selected.giteaWebhookMessage || '暂无 Webhook 诊断' }}</p>
|
||||
</details>
|
||||
</template>
|
||||
</ElDrawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.project-overview-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
.project-search {
|
||||
width: 230px;
|
||||
}
|
||||
|
||||
.project-overview-card {
|
||||
min-width: 0;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #d8e2ef;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.project-overview-card span {
|
||||
display: block;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.project-overview-card strong {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: #0f172a;
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.project-overview-card.tone-success {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
|
||||
.project-overview-card.tone-warning {
|
||||
border-color: #fde68a;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.project-overview-card.tone-danger {
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
.project-overview-card.tone-muted {
|
||||
border-color: #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.project-filter-bar {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(260px, 1.4fr) 150px 150px max-content;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.project-search-input {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.env-config {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
padding: 14px 46px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.env-config-card {
|
||||
padding: 14px;
|
||||
border: 1px solid #e1e8f2;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.project-diagnostic-card {
|
||||
grid-column: 1 / -1;
|
||||
padding: 14px;
|
||||
border: 1px solid #d7e5ff;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.env-config-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
dl {
|
||||
display: grid;
|
||||
grid-template-columns: 100px minmax(0, 1fr);
|
||||
gap: 8px 12px;
|
||||
margin: 0;
|
||||
color: #596578;
|
||||
.project-name {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
font-weight: 550;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
dt {
|
||||
color: #7b8798;
|
||||
.project-name:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
dd {
|
||||
.project-details {
|
||||
display: grid;
|
||||
grid-template-columns: 84px minmax(0, 1fr);
|
||||
gap: 15px;
|
||||
margin: 5px 0 25px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.project-details dt {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.project-details dd {
|
||||
margin: 0;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.status-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
.environment-config {
|
||||
padding: 22px 0;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.readiness-cell {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
.environment-config h2 {
|
||||
margin: 0 0 20px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.readiness-cell small {
|
||||
color: #64748b;
|
||||
.diagnostics {
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.project-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
.diagnostics summary {
|
||||
cursor: pointer;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.diagnostic-message {
|
||||
margin-left: 8px;
|
||||
color: #596578;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.latest-release {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.latest-release-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.latest-release small {
|
||||
color: #7b8798;
|
||||
}
|
||||
|
||||
.webhook-hook-list {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.webhook-hook-item {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.webhook-hook-item small {
|
||||
color: #7b8798;
|
||||
}
|
||||
|
||||
.run-link {
|
||||
color: #2563eb;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.run-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.project-overview-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.project-filter-bar {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.project-overview-grid,
|
||||
.project-filter-bar {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.env-config {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 12px;
|
||||
@media (max-width: 520px) {
|
||||
.project-search {
|
||||
width: 170px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+474
-1143
File diff suppressed because it is too large
Load Diff
+407
-790
File diff suppressed because it is too large
Load Diff
+110
-275
@@ -5,8 +5,8 @@
|
||||
import { Connection, Refresh, Search } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import AuditJsonCell from '../components/AuditJsonCell.vue'
|
||||
import StatusPill from '../components/StatusPill.vue'
|
||||
import { devopsApi } from '../services/devopsApi'
|
||||
import { usePlatformStore } from '../stores/platform'
|
||||
import { useSessionStore } from '../stores/session'
|
||||
@@ -20,6 +20,29 @@ import type {
|
||||
} from '../types/devops'
|
||||
|
||||
const platform = usePlatformStore()
|
||||
const route = useRoute()
|
||||
const tabs = [
|
||||
{ key: 'integrations', label: '集成接入' },
|
||||
{ key: 'notifications', label: '通知' },
|
||||
{ key: 'audit', label: '审计' },
|
||||
{ key: 'agent', label: '运维助手' },
|
||||
]
|
||||
const activeTab = computed(() =>
|
||||
tabs.some((tab) => tab.key === route.query.tab) ? String(route.query.tab) : 'integrations',
|
||||
)
|
||||
const adminLoading = ref(false)
|
||||
const adminError = ref('')
|
||||
async function refreshAdmin() {
|
||||
adminLoading.value = true
|
||||
adminError.value = ''
|
||||
try {
|
||||
await platform.loadAdminData()
|
||||
} catch (error) {
|
||||
adminError.value = error instanceof Error ? error.message : '管理数据读取失败'
|
||||
} finally {
|
||||
adminLoading.value = false
|
||||
}
|
||||
}
|
||||
const session = useSessionStore()
|
||||
const agentConfigLoading = ref(false)
|
||||
const agentConfigTesting = ref(false)
|
||||
@@ -70,45 +93,12 @@ const outboxStatusOptions: Array<{ label: string; value: NotificationOutboxStatu
|
||||
onMounted(() => {
|
||||
if (canManageSystemConfig.value) {
|
||||
void loadAgentConfig()
|
||||
void refreshAdmin()
|
||||
}
|
||||
})
|
||||
|
||||
const canManageSystemConfig = computed(() => session.role === 'super_admin')
|
||||
|
||||
const operationOverview = computed(() => {
|
||||
const integrations = platform.integrationConfig.integrations
|
||||
const configured = integrations.filter((item) => item.status === 'configured').length
|
||||
const missing = integrations.filter((item) => item.status === 'missing').length
|
||||
const partial = integrations.filter((item) => item.status === 'partial').length
|
||||
const outboxAttention = platform.notificationOutbox.filter(
|
||||
(item) => item.status === 'pending' || item.status === 'failed' || item.status === 'dead',
|
||||
).length
|
||||
|
||||
return [
|
||||
{ key: 'integrations', label: '集成项', value: integrations.length, tone: 'neutral' },
|
||||
{ key: 'configured', label: '已配置', value: configured, tone: 'success' },
|
||||
{
|
||||
key: 'attention',
|
||||
label: '配置关注',
|
||||
value: missing + partial,
|
||||
tone: missing + partial > 0 ? 'warning' : 'neutral',
|
||||
},
|
||||
{
|
||||
key: 'agent',
|
||||
label: 'Agent 密钥',
|
||||
value: agentConfig.value?.hasKey ? '已保存' : '未配置',
|
||||
tone: agentConfig.value?.hasKey ? 'success' : 'warning',
|
||||
},
|
||||
{
|
||||
key: 'outbox',
|
||||
label: '通知待排查',
|
||||
value: outboxAttention,
|
||||
tone: outboxAttention > 0 ? 'danger' : 'neutral',
|
||||
},
|
||||
{ key: 'audit', label: '审计记录', value: platform.auditLogs.length, tone: 'active' },
|
||||
]
|
||||
})
|
||||
|
||||
const agentConfigDisabledReason = computed(() => {
|
||||
if (!canManageSystemConfig.value) {
|
||||
return '仅超级管理员可维护 Agent 模型配置'
|
||||
@@ -200,9 +190,7 @@ function configStatusLabel(status: IntegrationConfigState): string {
|
||||
return configStatusMeta[status]?.label ?? '未配置'
|
||||
}
|
||||
|
||||
function configStatusType(
|
||||
status: IntegrationConfigState,
|
||||
): 'success' | 'warning' | 'danger' {
|
||||
function configStatusType(status: IntegrationConfigState): 'success' | 'warning' | 'danger' {
|
||||
return configStatusMeta[status]?.type ?? 'danger'
|
||||
}
|
||||
|
||||
@@ -231,9 +219,7 @@ function auditActor(record: AuditLogEntry): string {
|
||||
}
|
||||
|
||||
function auditResource(record: AuditLogEntry): string {
|
||||
return record.resourceId
|
||||
? `${record.resourceType} / ${record.resourceId}`
|
||||
: record.resourceType
|
||||
return record.resourceId ? `${record.resourceType} / ${record.resourceId}` : record.resourceType
|
||||
}
|
||||
|
||||
function hasAuditRecord(value?: Record<string, unknown>): value is Record<string, unknown> {
|
||||
@@ -405,7 +391,7 @@ async function saveAgentConfig() {
|
||||
applyAgentConfig(config)
|
||||
agentConfigForm.key = ''
|
||||
ElMessage.success('Agent 配置已保存')
|
||||
await platform.loadAll()
|
||||
await platform.loadAdminData()
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : 'Agent 配置保存失败')
|
||||
} finally {
|
||||
@@ -508,38 +494,40 @@ function resetAuditFilters() {
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1>系统配置</h1>
|
||||
<p>展示后端集成配置状态、API 契约来源、流程映射、Agent 边界和通知维护状态。</p>
|
||||
<p>按需查看接入状态、通知投递和操作审计。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="settings-overview-grid">
|
||||
<article
|
||||
v-for="item in operationOverview"
|
||||
:key="item.key"
|
||||
class="settings-overview-card"
|
||||
:class="`tone-${item.tone}`"
|
||||
<nav class="settings-tabs" aria-label="设置分类">
|
||||
<RouterLink
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
:to="{ name: 'settings', query: { tab: tab.key } }"
|
||||
:aria-current="activeTab === tab.key ? 'page' : undefined"
|
||||
>{{ tab.label }}</RouterLink
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
<strong>{{ item.value }}</strong>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
</nav>
|
||||
<ElAlert v-if="adminError" title="管理数据读取失败" type="error" :closable="false"
|
||||
>{{ adminError }}<ElButton text @click="refreshAdmin">重试</ElButton></ElAlert
|
||||
>
|
||||
<div v-if="adminLoading" class="field-hint" role="status">正在更新设置…</div>
|
||||
<section v-if="activeTab === 'integrations'" class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>后端集成配置状态</h2>
|
||||
<h2>集成接入</h2>
|
||||
<span>检查时间:{{ formatCheckedAt(platform.integrationConfig.checkedAt) }}</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="secret-boundary">
|
||||
这里只展示环境变量名和配置状态;Jenkins token、Gitea token、通知 webhook、LLM key、数据库连接串不会进入浏览器。
|
||||
这里只展示环境变量名和配置状态;Jenkins token、Gitea token、通知 webhook、LLM
|
||||
key、数据库连接串不会进入浏览器。
|
||||
</div>
|
||||
<div class="config-list">
|
||||
<article
|
||||
<details
|
||||
v-for="item in platform.integrationConfig.integrations"
|
||||
:key="item.key"
|
||||
class="config-row"
|
||||
>
|
||||
<div class="config-row-main">
|
||||
<summary class="config-row-main">
|
||||
<div>
|
||||
<h3>{{ item.name }}</h3>
|
||||
<p v-if="item.note">{{ item.note }}</p>
|
||||
@@ -547,14 +535,10 @@ function resetAuditFilters() {
|
||||
<ElTag :type="configStatusType(item.status)" effect="light" round>
|
||||
{{ configStatusLabel(item.status) }}
|
||||
</ElTag>
|
||||
</div>
|
||||
</summary>
|
||||
|
||||
<div class="variable-grid">
|
||||
<div
|
||||
v-for="group in variableGroups(item)"
|
||||
:key="group.key"
|
||||
class="variable-group"
|
||||
>
|
||||
<div v-for="group in variableGroups(item)" :key="group.key" class="variable-group">
|
||||
<strong>{{ group.label }}</strong>
|
||||
<div class="variable-tags">
|
||||
<ElTooltip
|
||||
@@ -592,31 +576,12 @@ function resetAuditFilters() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="section-grid">
|
||||
<section v-for="item in platform.settings" :key="item.key" class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>{{ item.name }}</h2>
|
||||
<StatusPill :state="item.status" />
|
||||
</div>
|
||||
<div class="panel-body setting-card">
|
||||
<dl>
|
||||
<dt>责任方</dt>
|
||||
<dd>{{ item.owner }}</dd>
|
||||
<dt>契约</dt>
|
||||
<dd>{{ item.contract }}</dd>
|
||||
<dt>边界</dt>
|
||||
<dd>{{ item.boundary }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section v-if="canManageSystemConfig" class="panel">
|
||||
<section v-if="activeTab === 'agent' && canManageSystemConfig" class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>Agent 模型配置</h2>
|
||||
<span>{{ agentConfig?.hasKey ? '已保存密钥' : '未保存密钥' }}</span>
|
||||
@@ -626,6 +591,7 @@ function resetAuditFilters() {
|
||||
<ElForm label-position="top">
|
||||
<ElFormItem label="Base URL">
|
||||
<ElInput
|
||||
aria-label="模型服务地址"
|
||||
v-model="agentConfigForm.baseURL"
|
||||
placeholder="https://api.example.com/v1"
|
||||
autocomplete="off"
|
||||
@@ -633,6 +599,7 @@ function resetAuditFilters() {
|
||||
</ElFormItem>
|
||||
<ElFormItem label="模型">
|
||||
<ElInput
|
||||
aria-label="模型名称"
|
||||
v-model="agentConfigForm.model"
|
||||
placeholder="gpt-4.1"
|
||||
autocomplete="off"
|
||||
@@ -640,6 +607,7 @@ function resetAuditFilters() {
|
||||
</ElFormItem>
|
||||
<ElFormItem label="API Key">
|
||||
<ElInput
|
||||
aria-label="模型密钥"
|
||||
v-model="agentConfigForm.key"
|
||||
type="password"
|
||||
show-password
|
||||
@@ -665,11 +633,12 @@ function resetAuditFilters() {
|
||||
测试连接
|
||||
</ElButton>
|
||||
</div>
|
||||
<div
|
||||
class="agent-config-check"
|
||||
:class="{ ready: canSaveAgentConfig }"
|
||||
>
|
||||
{{ canSaveAgentConfig ? '保存前检查通过,API Key 只会提交给后端配置接口。' : agentConfigDisabledReason }}
|
||||
<div class="agent-config-check" :class="{ ready: canSaveAgentConfig }">
|
||||
{{
|
||||
canSaveAgentConfig
|
||||
? '保存前检查通过,API Key 只会提交给后端配置接口。'
|
||||
: agentConfigDisabledReason
|
||||
}}
|
||||
</div>
|
||||
</ElForm>
|
||||
</div>
|
||||
@@ -695,29 +664,23 @@ function resetAuditFilters() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-else class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>Agent 模型配置</h2>
|
||||
<span>仅超级管理员可维护</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="secret-boundary">
|
||||
当前账号只能查看系统配置边界;模型 key、baseURL 和 model 的保存、测试均需要后端超级管理员鉴权。
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="session.role === 'super_admin'" class="panel">
|
||||
<section v-if="activeTab === 'notifications' && session.role === 'super_admin'" class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>通知 outbox</h2>
|
||||
<span>{{ filteredNotificationOutbox.length }} / {{ platform.notificationOutbox.length }} 条</span>
|
||||
<ElButton :icon="Refresh" size="small" @click="refreshNotificationOutbox">
|
||||
刷新
|
||||
</ElButton>
|
||||
<span
|
||||
>{{ filteredNotificationOutbox.length }} /
|
||||
{{ platform.notificationOutbox.length }} 条</span
|
||||
>
|
||||
<ElButton :icon="Refresh" size="small" @click="refreshNotificationOutbox"> 刷新 </ElButton>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="settings-filter-bar">
|
||||
<ElSelect v-model="outboxStatusFilter" clearable placeholder="投递状态">
|
||||
<ElSelect
|
||||
aria-label="筛选通知投递状态"
|
||||
v-model="outboxStatusFilter"
|
||||
clearable
|
||||
placeholder="投递状态"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in outboxStatusOptions"
|
||||
:key="option.value"
|
||||
@@ -726,6 +689,7 @@ function resetAuditFilters() {
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElInput
|
||||
aria-label="搜索通知记录"
|
||||
v-model="outboxKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
@@ -736,7 +700,11 @@ function resetAuditFilters() {
|
||||
重置筛选
|
||||
</ElButton>
|
||||
</div>
|
||||
<ElTable :data="filteredNotificationOutbox" border empty-text="没有符合条件的通知 outbox 记录">
|
||||
<ElTable
|
||||
:data="filteredNotificationOutbox"
|
||||
border
|
||||
empty-text="没有符合条件的通知 outbox 记录"
|
||||
>
|
||||
<ElTableColumn label="创建时间" min-width="150">
|
||||
<template #default="{ row }">
|
||||
{{ formatCheckedAt(row.createdAt) }}
|
||||
@@ -794,23 +762,31 @@ function resetAuditFilters() {
|
||||
</ElTable>
|
||||
<ElEmpty
|
||||
v-if="filteredNotificationOutbox.length === 0"
|
||||
:description="platform.notificationOutbox.length ? '暂无符合条件的通知 outbox 记录' : '暂无通知 outbox 记录'"
|
||||
:description="
|
||||
platform.notificationOutbox.length
|
||||
? '暂无符合条件的通知 outbox 记录'
|
||||
: '暂无通知 outbox 记录'
|
||||
"
|
||||
:image-size="72"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<section v-if="activeTab === 'audit'" class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>最近运维审计</h2>
|
||||
<h2>操作审计</h2>
|
||||
<span>{{ filteredAuditLogs.length }} / {{ platform.auditLogs.length }} 条</span>
|
||||
<ElButton :icon="Refresh" size="small" @click="platform.loadAuditLogs()">
|
||||
刷新
|
||||
</ElButton>
|
||||
<ElButton :icon="Refresh" size="small" @click="platform.loadAuditLogs()"> 刷新 </ElButton>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="settings-filter-bar">
|
||||
<ElSelect v-model="auditResourceFilter" clearable filterable placeholder="资源类型">
|
||||
<ElSelect
|
||||
aria-label="筛选审计资源"
|
||||
v-model="auditResourceFilter"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="资源类型"
|
||||
>
|
||||
<ElOption
|
||||
v-for="resource in auditResourceOptions"
|
||||
:key="resource"
|
||||
@@ -819,6 +795,7 @@ function resetAuditFilters() {
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElInput
|
||||
aria-label="搜索审计记录"
|
||||
v-model="auditKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
@@ -859,167 +836,30 @@ function resetAuditFilters() {
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-header">
|
||||
<h2>前端环境变量</h2>
|
||||
<span>第一阶段仅保留 API 地址</span>
|
||||
</div>
|
||||
<div class="panel-body compact-list">
|
||||
<div class="list-row">
|
||||
<span>
|
||||
<strong class="mono">VITE_API_BASE_URL</strong>
|
||||
<small>联调时指向后端网关;未配置时默认 /api。</small>
|
||||
</span>
|
||||
<ElTag type="info" round>后端接口</ElTag>
|
||||
</div>
|
||||
<div class="list-row">
|
||||
<span>
|
||||
<strong>密钥策略</strong>
|
||||
<small>Jenkins token、Gitea token、通知 webhook、LLM key 均不得进入前端。</small>
|
||||
</span>
|
||||
<ElTag type="success" round>前端隔离</ElTag>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.settings-overview-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
.config-row-main {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.settings-overview-card {
|
||||
min-width: 0;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #d8e2ef;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
.settings-tabs {
|
||||
display: flex;
|
||||
gap: 28px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.settings-overview-card span {
|
||||
display: block;
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.settings-overview-card strong {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: #0f172a;
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.settings-overview-card.tone-active {
|
||||
border-color: #bfdbfe;
|
||||
background: #eff6ff;
|
||||
}
|
||||
|
||||
.settings-overview-card.tone-success {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
|
||||
.settings-overview-card.tone-warning {
|
||||
border-color: #fde68a;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.settings-overview-card.tone-danger {
|
||||
border-color: #fecaca;
|
||||
background: #fef2f2;
|
||||
}
|
||||
|
||||
.settings-filter-bar {
|
||||
display: grid;
|
||||
grid-template-columns: 180px minmax(260px, 1fr) max-content;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.settings-search-input {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.setting-card dl {
|
||||
display: grid;
|
||||
grid-template-columns: 74px minmax(0, 1fr);
|
||||
gap: 10px 12px;
|
||||
margin: 0;
|
||||
.settings-tabs a {
|
||||
padding: 8px 0 14px;
|
||||
color: var(--text-muted);
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
border-bottom: 2px solid transparent;
|
||||
}
|
||||
|
||||
.setting-card dt {
|
||||
color: #7b8798;
|
||||
}
|
||||
|
||||
.setting-card dd {
|
||||
margin: 0;
|
||||
color: #172033;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.secret-boundary {
|
||||
margin-bottom: 14px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #dbeafe;
|
||||
border-radius: 8px;
|
||||
background: #eff6ff;
|
||||
color: #25508f;
|
||||
font-size: 13px;
|
||||
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;
|
||||
}
|
||||
|
||||
.agent-config-check {
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #fde68a;
|
||||
border-radius: 8px;
|
||||
background: #fffbeb;
|
||||
color: #8a5a00;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agent-config-check.ready {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
color: #166534;
|
||||
.settings-tabs a[aria-current='page'] {
|
||||
color: var(--accent);
|
||||
border-color: var(--accent);
|
||||
font-weight: 550;
|
||||
}
|
||||
|
||||
.config-list {
|
||||
@@ -1133,10 +973,6 @@ function resetAuditFilters() {
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.settings-overview-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.settings-filter-bar {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
@@ -1151,7 +987,6 @@ function resetAuditFilters() {
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.settings-overview-grid,
|
||||
.settings-filter-bar {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user