统一 frontend、backend、test、test-log 和 out 目录,更新构建、部署及测试入口;纳入配置管理兼容与首次安全引导修复;排除本机配置、密钥和测试产物。
This commit is contained in:
1 parent
28cd9d3406
commit
f60d3b0880
603 files changed
+2351
-660
No files matched your search
@@ -0,0 +1,399 @@
|
||||
.config-settings {
|
||||
display: grid;
|
||||
gap: 24px;
|
||||
padding-bottom: 28px;
|
||||
}
|
||||
.settings-header,
|
||||
.panel-heading,
|
||||
.status-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
}
|
||||
.settings-header h3,
|
||||
.panel-heading h4,
|
||||
.status-heading h4 {
|
||||
margin: 0;
|
||||
color: var(--pm-text-primary);
|
||||
}
|
||||
.settings-header h3 {
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.settings-header {
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.settings-header .settings-desc {
|
||||
margin: 0;
|
||||
}
|
||||
.config-availability {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: 16px;
|
||||
}
|
||||
.config-availability .el-alert {
|
||||
width: 100%;
|
||||
}
|
||||
.panel-heading h4,
|
||||
.status-heading h4 {
|
||||
margin-top: 5px;
|
||||
font-size: 18px;
|
||||
}
|
||||
.settings-desc {
|
||||
max-width: 680px;
|
||||
margin: 8px 0 0;
|
||||
color: var(--pm-text-secondary);
|
||||
line-height: 1.65;
|
||||
}
|
||||
.section-eyebrow {
|
||||
color: var(--pm-primary-color);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: .08em;
|
||||
}
|
||||
.status-panel,
|
||||
.editor-panel,
|
||||
.rollback-panel,
|
||||
.audit-panel {
|
||||
padding: 20px;
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: var(--pm-radius-lg);
|
||||
background: var(--pm-bg-secondary);
|
||||
}
|
||||
.status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.status-item {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
padding: 14px;
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: var(--pm-bg-primary);
|
||||
}
|
||||
.status-item span {
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.status-item strong {
|
||||
color: var(--pm-text-primary);
|
||||
font-size: 14px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.status-wide {
|
||||
grid-column: span 3;
|
||||
}
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
.config-alert,
|
||||
.degraded-alert {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.config-workspace {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 176px;
|
||||
grid-template-areas: "main submenu";
|
||||
align-items: start;
|
||||
gap: 20px;
|
||||
}
|
||||
.config-submenu {
|
||||
grid-area: submenu;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
align-self: start;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: var(--pm-radius-lg);
|
||||
background: var(--pm-bg-secondary);
|
||||
}
|
||||
.config-submenu-item {
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
color: var(--pm-text-secondary);
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
border: 0;
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
transition: color .2s ease, background-color .2s ease;
|
||||
}
|
||||
.config-submenu-item:hover,
|
||||
.config-submenu-item.active {
|
||||
color: var(--pm-primary-color);
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
.config-submenu-item.active {
|
||||
font-weight: 600;
|
||||
}
|
||||
.config-main {
|
||||
grid-area: main;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 24px;
|
||||
min-width: 0;
|
||||
}
|
||||
.config-main > section {
|
||||
min-width: 0;
|
||||
}
|
||||
.panel-heading {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.selected-section-label {
|
||||
color: var(--pm-primary-color);
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.editor-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 20px;
|
||||
margin: 18px 0 10px;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.config-editor :deep(.el-textarea__inner) {
|
||||
min-height: 300px !important;
|
||||
padding: 14px;
|
||||
color: var(--pm-text-primary);
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
line-height: 1.6;
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: var(--pm-bg-primary);
|
||||
}
|
||||
.secret-editor {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
padding: 14px;
|
||||
border: 1px dashed var(--pm-border-color);
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: var(--pm-bg-primary);
|
||||
}
|
||||
.secret-editor strong {
|
||||
color: var(--pm-text-primary);
|
||||
}
|
||||
.secret-editor p {
|
||||
margin: 5px 0 0;
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.confirmation-check {
|
||||
margin-top: 16px;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.confirmation-check :deep(.el-checkbox__label) {
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.confirmation-check :deep(.el-checkbox__input) {
|
||||
margin-top: 3px;
|
||||
}
|
||||
.action-row,
|
||||
.audit-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.backup-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.backup-item {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
padding: 12px;
|
||||
color: var(--pm-text-primary);
|
||||
text-align: left;
|
||||
border: 1px solid var(--pm-border-color);
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: var(--pm-bg-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
.backup-item:hover,
|
||||
.backup-item.selected {
|
||||
border-color: var(--pm-primary-color);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--pm-primary-color) 16%, transparent);
|
||||
}
|
||||
.backup-item small {
|
||||
color: var(--pm-text-secondary);
|
||||
}
|
||||
.preview-box,
|
||||
.result-box {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin-top: 16px;
|
||||
padding: 14px;
|
||||
border-radius: var(--pm-radius-sm);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.preview-box {
|
||||
color: var(--pm-text-primary);
|
||||
background: color-mix(in srgb, var(--pm-primary-color) 8%, var(--pm-bg-primary));
|
||||
}
|
||||
.result-success {
|
||||
color: #166534;
|
||||
background: #f0fdf4;
|
||||
}
|
||||
.result-error {
|
||||
color: #991b1b;
|
||||
background: #fef2f2;
|
||||
}
|
||||
.result-box ul {
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
.audit-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.audit-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: var(--pm-bg-primary);
|
||||
}
|
||||
.audit-item div {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
.audit-item strong {
|
||||
color: var(--pm-text-primary);
|
||||
}
|
||||
.audit-item span,
|
||||
.audit-item time {
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.audit-item time {
|
||||
flex: none;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.status-panel,
|
||||
.editor-panel,
|
||||
.rollback-panel,
|
||||
.audit-panel {
|
||||
padding: 16px;
|
||||
}
|
||||
.status-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.status-wide {
|
||||
grid-column: auto;
|
||||
}
|
||||
.settings-header,
|
||||
.panel-heading,
|
||||
.status-heading,
|
||||
.audit-item {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
.config-workspace {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-areas:
|
||||
"submenu"
|
||||
"main";
|
||||
gap: 16px;
|
||||
}
|
||||
.config-submenu {
|
||||
position: static;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
padding: 6px;
|
||||
}
|
||||
.config-submenu-item {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.selected-section-label {
|
||||
white-space: normal;
|
||||
}
|
||||
.action-row .el-button,
|
||||
.audit-actions .el-button {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
}
|
||||
}
|
||||
.panel-desc {
|
||||
margin: 14px 0 0;
|
||||
color: var(--pm-text-secondary);
|
||||
line-height: 1.6;
|
||||
}
|
||||
.migration-source {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.migration-source > div {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
padding: 12px 14px;
|
||||
border-radius: var(--pm-radius-sm);
|
||||
background: var(--pm-bg-primary);
|
||||
}
|
||||
.migration-source span {
|
||||
color: var(--pm-text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.migration-source strong {
|
||||
color: var(--pm-text-primary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.migration-form {
|
||||
margin-top: 16px;
|
||||
}
|
||||
.migration-form :deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.migration-result-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.migration-error {
|
||||
color: #b42318;
|
||||
}
|
||||
.restart-services {
|
||||
margin-top: 18px;
|
||||
}
|
||||
.restart-result {
|
||||
margin-top: 16px;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.migration-source {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.migration-result-heading {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { http } from '@/utils/axios'
|
||||
import { useGlobalStatusStore } from '@/stores/useGlobalStatusStore'
|
||||
|
||||
const sections = [
|
||||
{ value: 'base', label: '基础配置' },
|
||||
{ value: 'smtp', label: 'SMTP 配置' },
|
||||
{ value: 'email', label: '邮箱策略' },
|
||||
{ value: 'ssl', label: 'SSL 配置' },
|
||||
{ value: 'plugins', label: '插件配置' }
|
||||
]
|
||||
|
||||
const serviceLabels = {
|
||||
smtp: 'SMTP 服务',
|
||||
email: '邮箱服务',
|
||||
ssl: 'SSL 服务',
|
||||
plugins: '插件服务'
|
||||
}
|
||||
|
||||
const sectionLabels = Object.fromEntries(sections.map(item => [item.value, item.label]))
|
||||
const operationLabels = {
|
||||
validate: '验证配置',
|
||||
update: '保存配置',
|
||||
apply: '应用配置',
|
||||
rollback_preview: '预览回滚',
|
||||
rollback_ticket: '签发回滚票据',
|
||||
rollback: '执行回滚'
|
||||
}
|
||||
|
||||
export function usePage() {
|
||||
const globalStatus = useGlobalStatusStore()
|
||||
const loading = ref(false)
|
||||
const availabilityError = ref('')
|
||||
const working = ref('')
|
||||
const backupsLoading = ref(false)
|
||||
const auditLoading = ref(false)
|
||||
const backupsError = ref('')
|
||||
const auditError = ref('')
|
||||
const status = reactive({
|
||||
setupState: '',
|
||||
activeGeneration: 0,
|
||||
lastValidAt: '',
|
||||
pendingRestart: [],
|
||||
degradedReasons: []
|
||||
})
|
||||
const selectedSection = ref('base')
|
||||
const editorText = ref('')
|
||||
const sectionError = ref('')
|
||||
const secretValue = ref('')
|
||||
const confirmed = ref(false)
|
||||
const savedGeneration = ref(0)
|
||||
const validationResult = ref(null)
|
||||
const backups = ref([])
|
||||
const rollbackGeneration = ref(0)
|
||||
const rollbackConfirmed = ref(false)
|
||||
const rollbackPreview = ref(null)
|
||||
const auditItems = ref([])
|
||||
const databaseConfig = reactive({ type: '', name: '', localRef: '' })
|
||||
const migrationTargetName = ref('')
|
||||
const migrationPreview = ref(null)
|
||||
const migrationToken = ref('')
|
||||
const migrationRecord = ref(null)
|
||||
const restartPreview = ref(null)
|
||||
|
||||
const canWrite = computed(() => globalStatus.hasCapability('config.write_global'))
|
||||
const canRollback = computed(() => globalStatus.hasCapability('config.rollback'))
|
||||
const canAudit = computed(() => globalStatus.hasCapability('audit.read'))
|
||||
const canExportAudit = computed(() => globalStatus.hasCapability('audit.export'))
|
||||
const canMigrate = computed(() => globalStatus.hasCapability('database.migrate'))
|
||||
const canRestart = computed(() => globalStatus.hasCapability('service.restart'))
|
||||
const stateLabel = computed(() => ({ new: '未初始化', bootstrap: '初始化中', ready: '就绪', degraded: '降级' }[status.setupState] || status.setupState || '未知'))
|
||||
const stateTagType = computed(() => ({ ready: 'success', degraded: 'warning', bootstrap: 'info', new: 'danger' }[status.setupState] || 'info'))
|
||||
const secretField = computed(() => {
|
||||
if (selectedSection.value === 'base') {
|
||||
return { label: '数据库密码', description: '只在本次请求内传输,保存后仅保留密文状态。留空表示保持原值。', placeholder: '输入新数据库密码(可选)' }
|
||||
}
|
||||
if (selectedSection.value === 'smtp') {
|
||||
return { label: 'SMTP Relay 密码', description: '只在本次请求内传输,保存后仅保留密文状态。留空表示保持原值。', placeholder: '输入新的 Relay 密码(可选)' }
|
||||
}
|
||||
return null
|
||||
})
|
||||
const sensitiveHint = computed(() => secretField.value ? '密码字段已脱敏,修改请使用下方输入框' : '当前分区不包含可编辑密文')
|
||||
|
||||
const notifyResponseError = (response, fallback) => {
|
||||
if (!response || response.errorNo !== 0) {
|
||||
throw new Error(response?.errorMsg || fallback)
|
||||
}
|
||||
}
|
||||
|
||||
const formatTime = value => value ? new Date(value).toLocaleString('zh-CN', { hour12: false }) : '-'
|
||||
const serviceLabel = value => serviceLabels[value] || value
|
||||
const sectionLabel = value => sectionLabels[value] || value || '-'
|
||||
const operationLabel = value => operationLabels[value] || value || '-'
|
||||
const migrationStatusLabels = {
|
||||
previewed: '已生成预览',
|
||||
created: '已创建',
|
||||
copying: '复制中',
|
||||
verifying: '校验中',
|
||||
switching: '切换中',
|
||||
succeeded: '已完成',
|
||||
failed: '失败'
|
||||
}
|
||||
const migrationStatusLabel = value => migrationStatusLabels[value] || value || '未知'
|
||||
const migrationStatusType = value => ({
|
||||
previewed: 'info',
|
||||
created: 'info',
|
||||
copying: 'warning',
|
||||
verifying: 'warning',
|
||||
switching: 'warning',
|
||||
succeeded: 'success',
|
||||
failed: 'danger'
|
||||
}[value] || 'info')
|
||||
const databaseTypeLabel = value => ({ mysql: 'MySQL', postgresql: 'PostgreSQL', sqlite: 'SQLite' }[value] || value || '-')
|
||||
const loadStatus = async () => {
|
||||
const response = await http.get('/api/v1/config/status')
|
||||
notifyResponseError(response, '配置状态读取失败')
|
||||
Object.assign(status, response.data || {})
|
||||
}
|
||||
|
||||
const loadSection = async () => {
|
||||
sectionError.value = ''
|
||||
secretValue.value = ''
|
||||
validationResult.value = null
|
||||
savedGeneration.value = 0
|
||||
try {
|
||||
const response = await http.get(`/api/v1/config/${selectedSection.value}`)
|
||||
notifyResponseError(response, '配置分区读取失败')
|
||||
const publicConfig = response.data || {}
|
||||
editorText.value = JSON.stringify(publicConfig, null, 2)
|
||||
if (selectedSection.value === 'base') {
|
||||
const database = publicConfig.database || {}
|
||||
Object.assign(databaseConfig, { type: database.type || '', name: database.name || '', localRef: database.localRef || '' })
|
||||
}
|
||||
} catch (error) {
|
||||
sectionError.value = error.message || '配置分区读取失败'
|
||||
editorText.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const selectSection = value => {
|
||||
if (selectedSection.value === value) return
|
||||
selectedSection.value = value
|
||||
loadSection()
|
||||
}
|
||||
|
||||
const loadBackups = async () => {
|
||||
if (!canRollback.value) return
|
||||
backupsLoading.value = true
|
||||
backupsError.value = ''
|
||||
try {
|
||||
const response = await http.get('/api/v1/config/backups')
|
||||
notifyResponseError(response, '配置备份读取失败')
|
||||
backups.value = Array.isArray(response.data) ? response.data : []
|
||||
} catch (error) {
|
||||
backups.value = []
|
||||
rollbackGeneration.value = 0
|
||||
rollbackPreview.value = null
|
||||
rollbackConfirmed.value = false
|
||||
backupsError.value = error.message || '配置备份读取失败'
|
||||
} finally {
|
||||
backupsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadAudit = async () => {
|
||||
if (!canAudit.value) return
|
||||
auditLoading.value = true
|
||||
auditError.value = ''
|
||||
try {
|
||||
const response = await http.get('/api/v1/audits/config?limit=50')
|
||||
notifyResponseError(response, '配置审计读取失败')
|
||||
auditItems.value = Array.isArray(response.data) ? response.data : []
|
||||
} catch (error) {
|
||||
auditItems.value = []
|
||||
auditError.value = error.message || '配置审计读取失败'
|
||||
} finally {
|
||||
auditLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const previewDatabaseMigration = async () => {
|
||||
if (!canMigrate.value || !migrationTargetName.value.trim()) return
|
||||
working.value = 'migration-preview'
|
||||
migrationPreview.value = null
|
||||
migrationRecord.value = null
|
||||
migrationToken.value = ''
|
||||
try {
|
||||
const response = await http.post('/api/v1/database/migrations/preview', {
|
||||
targetName: migrationTargetName.value.trim(),
|
||||
expectedGeneration: Number(status.activeGeneration)
|
||||
})
|
||||
notifyResponseError(response, '数据库迁移预览失败')
|
||||
migrationPreview.value = response.data?.migration || null
|
||||
migrationRecord.value = migrationPreview.value
|
||||
migrationToken.value = response.data?.token || ''
|
||||
ElMessage.success('数据库迁移预览已生成,请确认目标名称后执行')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '数据库迁移预览失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const loadMigrationStatus = async () => {
|
||||
if (!migrationRecord.value?.id) return
|
||||
working.value = 'migration-status'
|
||||
try {
|
||||
const response = await http.get(`/api/v1/database/migrations/${migrationRecord.value.id}`)
|
||||
notifyResponseError(response, '数据库迁移状态读取失败')
|
||||
migrationRecord.value = response.data || migrationRecord.value
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '数据库迁移状态读取失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const executeDatabaseMigration = async () => {
|
||||
if (!migrationPreview.value?.id || !migrationToken.value) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'迁移将复制数据库内容并切换配置,旧数据库会保留。确认继续吗?',
|
||||
'确认执行数据库迁移',
|
||||
{ type: 'warning', confirmButtonText: '继续迁移', cancelButtonText: '取消' }
|
||||
)
|
||||
working.value = 'migration-execute'
|
||||
const response = await http.post('/api/v1/database/migrations', {
|
||||
id: migrationPreview.value.id,
|
||||
token: migrationToken.value
|
||||
})
|
||||
notifyResponseError(response, '数据库迁移执行失败')
|
||||
migrationRecord.value = response.data || migrationPreview.value
|
||||
migrationToken.value = ''
|
||||
migrationPreview.value = null
|
||||
await Promise.all([loadStatus(), loadSection()])
|
||||
if (migrationRecord.value.status === 'succeeded') {
|
||||
ElMessage.success('数据库迁移已完成,旧数据库仍然保留')
|
||||
} else {
|
||||
ElMessage.warning(`数据库迁移${migrationStatusLabel(migrationRecord.value.status)}`)
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== 'cancel' && error !== 'close') ElMessage.error(error.message || '数据库迁移执行失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const previewRestart = async () => {
|
||||
if (!canRestart.value) return
|
||||
working.value = 'restart-preview'
|
||||
try {
|
||||
const response = await http.post('/api/v1/system/restart/preview', {})
|
||||
notifyResponseError(response, '重启预览读取失败')
|
||||
restartPreview.value = response.data || null
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '重启预览读取失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const requestRestart = async () => {
|
||||
if (!canRestart.value) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'服务将按固定服务管理器重启,当前页面可能会短暂断开。确认继续吗?',
|
||||
'确认重启 Smail',
|
||||
{ type: 'warning', confirmButtonText: '确认重启', cancelButtonText: '取消' }
|
||||
)
|
||||
working.value = 'restart'
|
||||
const response = await http.post('/api/v1/system/restart', {})
|
||||
notifyResponseError(response, '重启请求提交失败')
|
||||
ElMessage.success('重启请求已提交,请等待服务恢复')
|
||||
restartPreview.value = null
|
||||
} catch (error) {
|
||||
if (error !== 'cancel' && error !== 'close') ElMessage.error(error.message || '重启请求提交失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
const loadAll = async () => {
|
||||
loading.value = true
|
||||
availabilityError.value = ''
|
||||
try {
|
||||
await loadStatus()
|
||||
if (status.available === false) {
|
||||
availabilityError.value = status.unavailableReason || '在线配置管理尚未启用'
|
||||
return
|
||||
}
|
||||
await Promise.all([loadSection(), loadBackups(), loadAudit()])
|
||||
} catch (error) {
|
||||
availabilityError.value = error.message || '配置管理数据读取失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const parsePayload = () => {
|
||||
try {
|
||||
const payload = JSON.parse(editorText.value)
|
||||
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
||||
throw new Error('配置必须是 JSON 对象')
|
||||
}
|
||||
if (selectedSection.value === 'base') {
|
||||
delete payload.databasePasswordStatus
|
||||
}
|
||||
if (selectedSection.value === 'smtp') {
|
||||
delete payload.relayPasswordStatus
|
||||
}
|
||||
if (selectedSection.value === 'plugins' && payload.plugins && typeof payload.plugins === 'object') {
|
||||
Object.values(payload.plugins).forEach(plugin => {
|
||||
if (plugin && typeof plugin === 'object') {
|
||||
delete plugin.settingsConfigured
|
||||
}
|
||||
})
|
||||
}
|
||||
return payload
|
||||
} catch (error) {
|
||||
throw new Error(error.message || 'JSON 格式错误')
|
||||
}
|
||||
}
|
||||
|
||||
const buildRequest = () => {
|
||||
const secretChanges = {}
|
||||
const value = secretValue.value.trim()
|
||||
if (value && selectedSection.value === 'base') {
|
||||
secretChanges['database.password'] = { operation: 'replace', value: { plaintext: value } }
|
||||
}
|
||||
if (value && selectedSection.value === 'smtp') {
|
||||
secretChanges['relay.password'] = { operation: 'replace', value: { plaintext: value } }
|
||||
}
|
||||
return {
|
||||
expectedGeneration: Number(status.activeGeneration),
|
||||
payload: parsePayload(),
|
||||
secretChanges,
|
||||
confirmation: { confirmed: confirmed.value, method: 'recent_auth' }
|
||||
}
|
||||
}
|
||||
|
||||
const validateConfig = async () => {
|
||||
working.value = 'validate'
|
||||
try {
|
||||
const request = buildRequest()
|
||||
const response = await http.post(`/api/v1/config/${selectedSection.value}/validate`, request)
|
||||
notifyResponseError(response, '配置验证失败')
|
||||
validationResult.value = response.data || null
|
||||
ElMessage[validationResult.value?.valid ? 'success' : 'warning'](validationResult.value?.valid ? '配置验证通过' : '配置验证未通过')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '配置验证失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const saveConfig = async () => {
|
||||
working.value = 'save'
|
||||
try {
|
||||
const request = buildRequest()
|
||||
const response = await http.put(`/api/v1/config/${selectedSection.value}`, request)
|
||||
notifyResponseError(response, '配置保存失败')
|
||||
savedGeneration.value = response.data?.generation || 0
|
||||
validationResult.value = { valid: true, generation: savedGeneration.value, issues: [] }
|
||||
await loadStatus()
|
||||
ElMessage.success(`候选配置已保存,代次 ${savedGeneration.value} 等待应用`)
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '配置保存失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const applyConfig = async () => {
|
||||
if (!savedGeneration.value) return
|
||||
working.value = 'apply'
|
||||
try {
|
||||
const response = await http.post(`/api/v1/config/${selectedSection.value}/apply`, { generation: savedGeneration.value })
|
||||
notifyResponseError(response, '配置应用失败')
|
||||
savedGeneration.value = 0
|
||||
await Promise.all([loadStatus(), loadSection()])
|
||||
ElMessage.success('配置已应用')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '配置应用失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const previewRollback = async () => {
|
||||
if (!rollbackGeneration.value) return
|
||||
working.value = 'preview'
|
||||
rollbackPreview.value = null
|
||||
try {
|
||||
const response = await http.post('/api/v1/config/rollback/preview', { targetGeneration: rollbackGeneration.value })
|
||||
notifyResponseError(response, '回滚预览失败')
|
||||
rollbackPreview.value = response.data || null
|
||||
ElMessage.success('回滚预览已生成,请确认变更分区')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '回滚预览失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const executeRollback = async () => {
|
||||
if (!rollbackPreview.value || !rollbackConfirmed.value) return
|
||||
try {
|
||||
await ElMessageBox.confirm('回滚会替换当前候选配置并可能需要重启服务,确定继续吗?', '确认执行回滚', { type: 'warning', confirmButtonText: '继续回滚', cancelButtonText: '取消' })
|
||||
working.value = 'rollback'
|
||||
const ticketResponse = await http.post('/api/v1/config/rollback/ticket', {
|
||||
targetGeneration: rollbackPreview.value.targetGeneration,
|
||||
confirmation: { confirmed: true, method: 'recent_auth' }
|
||||
})
|
||||
notifyResponseError(ticketResponse, '回滚票据签发失败')
|
||||
const response = await http.post('/api/v1/config/rollback', { ticket: ticketResponse.data?.ticket })
|
||||
notifyResponseError(response, '配置回滚失败')
|
||||
rollbackPreview.value = null
|
||||
rollbackConfirmed.value = false
|
||||
await Promise.all([loadStatus(), loadSection(), loadBackups()])
|
||||
ElMessage.success('配置已回滚')
|
||||
} catch (error) {
|
||||
if (error !== 'cancel' && error !== 'close') ElMessage.error(error.message || '配置回滚失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const exportAudit = async format => {
|
||||
working.value = format === 'csv' ? 'export-csv' : 'export'
|
||||
try {
|
||||
const response = await http.post('/api/v1/audits/config', { format, limit: 500 }, { responseType: 'blob' })
|
||||
const blob = response.data instanceof Blob ? response.data : new Blob([response.data], { type: format === 'csv' ? 'text/csv' : 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = url
|
||||
anchor.download = `smail-config-audit.${format}`
|
||||
anchor.click()
|
||||
URL.revokeObjectURL(url)
|
||||
ElMessage.success('审计记录已导出')
|
||||
} catch (error) {
|
||||
ElMessage.error(error.message || '审计导出失败')
|
||||
} finally {
|
||||
working.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadAll)
|
||||
|
||||
return {
|
||||
loading, availabilityError, working, status, stateLabel, stateTagType, sectionOptions: sections,
|
||||
selectedSection, selectSection, editorText, sectionError, sensitiveHint, secretField, secretValue,
|
||||
confirmed, savedGeneration, validationResult, canWrite, canRollback, canAudit, canExportAudit,
|
||||
backupsLoading, backupsError, backups, rollbackGeneration, rollbackConfirmed, rollbackPreview,
|
||||
auditLoading, auditError, auditItems, loadAll, loadSection, validateConfig, saveConfig, applyConfig,
|
||||
loadBackups, previewRollback, executeRollback, loadAudit, exportAudit, formatTime,
|
||||
serviceLabel, sectionLabel, operationLabel, databaseConfig, databaseTypeLabel, canMigrate,
|
||||
migrationTargetName, migrationPreview, migrationRecord, migrationStatusLabel, migrationStatusType,
|
||||
previewDatabaseMigration, loadMigrationStatus, executeDatabaseMigration, canRestart, restartPreview,
|
||||
previewRestart, requestRestart
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
<template>
|
||||
<div class="config-settings" v-loading="loading">
|
||||
<div class="settings-header">
|
||||
<h3>配置管理</h3>
|
||||
<p class="settings-desc">按配置分区安全编辑、验证、应用和回滚,敏感凭据只显示状态,不会回显明文。</p>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="!canWrite"
|
||||
title="当前账号仅能查看配置,保存、应用和回滚操作已隐藏。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="config-alert"
|
||||
/>
|
||||
|
||||
<div v-if="availabilityError" class="config-availability" role="status">
|
||||
<el-alert :title="availabilityError" type="warning" :closable="false" show-icon />
|
||||
<el-button :loading="loading" @click="loadAll">重新检查</el-button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!loading" class="config-workspace">
|
||||
<nav class="config-submenu" aria-label="配置分区">
|
||||
<button
|
||||
v-for="item in sectionOptions"
|
||||
:key="item.value"
|
||||
type="button"
|
||||
class="config-submenu-item"
|
||||
:class="{ active: selectedSection === item.value }"
|
||||
:aria-current="selectedSection === item.value ? 'page' : undefined"
|
||||
@click="selectSection(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="config-main">
|
||||
<section class="status-panel">
|
||||
<div class="status-heading">
|
||||
<div>
|
||||
<span class="section-eyebrow">运行状态</span>
|
||||
<h4>配置快照</h4>
|
||||
</div>
|
||||
<el-button size="small" plain :loading="loading" @click="loadAll">刷新</el-button>
|
||||
</div>
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<span>状态</span>
|
||||
<el-tag :type="stateTagType">{{ stateLabel }}</el-tag>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span>当前生效代次</span>
|
||||
<strong>{{ status.activeGeneration || '-' }}</strong>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<span>最近校验时间</span>
|
||||
<strong>{{ formatTime(status.lastValidAt) }}</strong>
|
||||
</div>
|
||||
<div class="status-item status-wide">
|
||||
<span>待重启服务</span>
|
||||
<div v-if="status.pendingRestart?.length" class="tag-list">
|
||||
<el-tag v-for="service in status.pendingRestart" :key="service" type="warning" effect="plain">
|
||||
{{ serviceLabel(service) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<strong v-else>无</strong>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert
|
||||
v-for="issue in status.degradedReasons || []"
|
||||
:key="`${issue.code}-${issue.message}`"
|
||||
:title="`${issue.code}:${issue.message}`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="degraded-alert"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="editor-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<span class="section-eyebrow">分区配置</span>
|
||||
<h4>编辑候选配置</h4>
|
||||
</div>
|
||||
<strong class="selected-section-label">{{ sectionOptions.find(item => item.value === selectedSection)?.label }}</strong>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="sectionError"
|
||||
:title="sectionError"
|
||||
type="error"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="config-alert"
|
||||
/>
|
||||
|
||||
<div class="editor-meta">
|
||||
<span>编辑代次:{{ status.activeGeneration || '-' }}</span>
|
||||
<span>敏感字段:{{ sensitiveHint }}</span>
|
||||
</div>
|
||||
<el-input
|
||||
v-model="editorText"
|
||||
type="textarea"
|
||||
:rows="16"
|
||||
resize="vertical"
|
||||
spellcheck="false"
|
||||
class="config-editor"
|
||||
:readonly="!canWrite"
|
||||
aria-label="配置 JSON 编辑器"
|
||||
/>
|
||||
|
||||
<div v-if="secretField" class="secret-editor">
|
||||
<div>
|
||||
<strong>{{ secretField.label }}</strong>
|
||||
<p>{{ secretField.description }}</p>
|
||||
</div>
|
||||
<el-input
|
||||
v-model="secretValue"
|
||||
type="password"
|
||||
show-password
|
||||
clearable
|
||||
:disabled="!canWrite"
|
||||
:placeholder="secretField.placeholder"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-checkbox v-if="canWrite" v-model="confirmed" class="confirmation-check">
|
||||
我已确认这是受控变更,并允许使用最近认证完成高风险配置操作
|
||||
</el-checkbox>
|
||||
<div class="action-row">
|
||||
<el-button :loading="working === 'validate'" :disabled="!canWrite" @click="validateConfig">只验证</el-button>
|
||||
<el-button type="primary" :loading="working === 'save'" :disabled="!canWrite" @click="saveConfig">保存候选配置</el-button>
|
||||
<el-button type="success" plain :loading="working === 'apply'" :disabled="!canWrite || !savedGeneration" @click="applyConfig">
|
||||
应用 {{ savedGeneration ? `代次 ${savedGeneration}` : '' }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="validationResult" class="result-box" :class="validationResult.valid ? 'result-success' : 'result-error'">
|
||||
<strong>{{ validationResult.valid ? '验证通过' : '验证未通过' }}</strong>
|
||||
<span v-if="validationResult.generation">候选代次:{{ validationResult.generation }}</span>
|
||||
<ul v-if="validationResult.issues?.length">
|
||||
<li v-for="issue in validationResult.issues" :key="`${issue.code}-${issue.message}`">{{ issue.code }}:{{ issue.message }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="canMigrate" class="migration-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<span class="section-eyebrow">数据库迁移</span>
|
||||
<h4>安全迁移数据库</h4>
|
||||
</div>
|
||||
<el-tag type="warning" effect="plain">仅允许修改数据库名称</el-tag>
|
||||
</div>
|
||||
<p class="panel-desc">系统会先生成一次性预览票据,再复制并校验数据。主机、端口、用户名和密码保持不变,旧数据库不会自动删除。</p>
|
||||
<div class="migration-source">
|
||||
<div>
|
||||
<span>当前数据库类型</span>
|
||||
<strong>{{ databaseTypeLabel(databaseConfig.type) }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>当前数据库</span>
|
||||
<strong>{{ databaseConfig.type === 'sqlite' ? databaseConfig.localRef || '-' : databaseConfig.name || '-' }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<el-form label-position="top" class="migration-form">
|
||||
<el-form-item :label="databaseConfig.type === 'sqlite' ? '目标数据库文件引用' : '目标数据库名称'">
|
||||
<el-input
|
||||
v-model="migrationTargetName"
|
||||
:placeholder="databaseConfig.type === 'sqlite' ? '例如 smail-next.db' : '例如 smail_next'"
|
||||
maxlength="128"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="action-row">
|
||||
<el-button :loading="working === 'migration-preview'" @click="previewDatabaseMigration">生成迁移预览</el-button>
|
||||
<el-button type="primary" :loading="working === 'migration-execute'" :disabled="!migrationPreview || !migrationToken" @click="executeDatabaseMigration">
|
||||
执行迁移
|
||||
</el-button>
|
||||
<el-button v-if="migrationRecord?.id" plain :loading="working === 'migration-status'" @click="loadMigrationStatus">刷新迁移状态</el-button>
|
||||
</div>
|
||||
<div v-if="migrationRecord" class="preview-box migration-result">
|
||||
<div class="migration-result-heading">
|
||||
<strong>迁移状态</strong>
|
||||
<el-tag :type="migrationStatusType(migrationRecord.status)" effect="plain">{{ migrationStatusLabel(migrationRecord.status) }}</el-tag>
|
||||
</div>
|
||||
<span>迁移编号:{{ migrationRecord.id }}</span>
|
||||
<span>源数据库:{{ migrationRecord.source?.name || migrationRecord.source?.localRef || '-' }}</span>
|
||||
<span>目标数据库:{{ migrationRecord.target?.name || migrationRecord.target?.localRef || '-' }}</span>
|
||||
<span v-if="migrationRecord.errorCode" class="migration-error">错误代码:{{ migrationRecord.errorCode }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="canRestart && status.pendingRestart?.length" class="restart-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<span class="section-eyebrow">受控重启</span>
|
||||
<h4>应用待重启服务</h4>
|
||||
</div>
|
||||
<el-tag type="warning" effect="plain">固定目标:Smail</el-tag>
|
||||
</div>
|
||||
<p class="panel-desc">配置变更需要重启时,只能通过固定的 Smail 服务管理器提交请求,不接受外部命令、服务名或参数。</p>
|
||||
<div class="tag-list restart-services">
|
||||
<el-tag v-for="service in status.pendingRestart" :key="service" type="warning">{{ serviceLabel(service) }}</el-tag>
|
||||
</div>
|
||||
<div class="action-row">
|
||||
<el-button :loading="working === 'restart-preview'" @click="previewRestart">查看重启预览</el-button>
|
||||
<el-button type="danger" :loading="working === 'restart'" :disabled="!restartPreview?.triggerAvailable" @click="requestRestart">提交重启请求</el-button>
|
||||
</div>
|
||||
<div v-if="restartPreview" class="preview-box restart-result">
|
||||
<strong>重启预览</strong>
|
||||
<span>目标:{{ restartPreview.target }} · 操作:{{ restartPreview.action }}</span>
|
||||
<span>服务管理器:{{ restartPreview.serviceManager }}</span>
|
||||
<span>{{ restartPreview.triggerAvailable ? '重启通道可用' : '重启通道暂不可用,请先检查服务部署' }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="canRollback" class="rollback-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<span class="section-eyebrow">受控回滚</span>
|
||||
<h4>备份与回滚</h4>
|
||||
</div>
|
||||
<el-button size="small" plain :loading="backupsLoading" @click="loadBackups">刷新备份</el-button>
|
||||
</div>
|
||||
<el-alert v-if="backupsError" :title="backupsError" type="warning" :closable="false" show-icon />
|
||||
<el-empty v-else-if="!backups.length && !backupsLoading" description="暂无可用配置备份" :image-size="72" />
|
||||
<div v-else class="backup-list">
|
||||
<button
|
||||
v-for="backup in backups"
|
||||
:key="backup.generation"
|
||||
type="button"
|
||||
class="backup-item"
|
||||
:class="{ selected: rollbackGeneration === backup.generation }"
|
||||
@click="rollbackGeneration = backup.generation"
|
||||
>
|
||||
<span>代次 {{ backup.generation }}</span>
|
||||
<small>{{ formatTime(backup.createdAt) }}</small>
|
||||
</button>
|
||||
</div>
|
||||
<el-checkbox v-model="rollbackConfirmed" class="confirmation-check">我已阅读回滚预览,并确认执行一次性回滚</el-checkbox>
|
||||
<div class="action-row">
|
||||
<el-button :loading="working === 'preview'" :disabled="!rollbackGeneration" @click="previewRollback">预览回滚</el-button>
|
||||
<el-button type="danger" plain :loading="working === 'rollback'" :disabled="!rollbackPreview || !rollbackConfirmed" @click="executeRollback">执行回滚</el-button>
|
||||
</div>
|
||||
<div v-if="rollbackPreview" class="preview-box">
|
||||
<strong>回滚预览</strong>
|
||||
<span>当前代次 {{ rollbackPreview.currentGeneration }} → 目标代次 {{ rollbackPreview.targetGeneration }}</span>
|
||||
<span>候选代次:{{ rollbackPreview.candidateGeneration }}</span>
|
||||
<span>变更分区:{{ rollbackPreview.changedSections?.map(sectionLabel).join('、') || '无' }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="canAudit" class="audit-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<span class="section-eyebrow">审计记录</span>
|
||||
<h4>配置操作审计</h4>
|
||||
</div>
|
||||
<div class="audit-actions">
|
||||
<el-button size="small" plain :loading="auditLoading" @click="loadAudit">查询</el-button>
|
||||
<el-button v-if="canExportAudit" size="small" type="primary" plain :loading="working === 'export'" @click="exportAudit('json')">导出 JSON</el-button>
|
||||
<el-button v-if="canExportAudit" size="small" plain :loading="working === 'export-csv'" @click="exportAudit('csv')">导出 CSV</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-alert v-if="auditError" :title="auditError" type="warning" :closable="false" show-icon />
|
||||
<div v-else-if="auditItems.length" class="audit-list">
|
||||
<div v-for="item in auditItems" :key="item.id || `${item.createdAt}-${item.operation}`" class="audit-item">
|
||||
<div>
|
||||
<strong>{{ operationLabel(item.operation) }}</strong>
|
||||
<span>{{ sectionLabel(item.section) }} · {{ item.actorId || '系统' }}</span>
|
||||
</div>
|
||||
<time>{{ formatTime(item.createdAt) }}</time>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else-if="!auditLoading" description="暂无配置审计记录" :image-size="72" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { usePage } from './ConfigSettings.js'
|
||||
|
||||
const {
|
||||
availabilityError,
|
||||
loading,
|
||||
working,
|
||||
status,
|
||||
stateLabel,
|
||||
stateTagType,
|
||||
sectionOptions,
|
||||
selectedSection,
|
||||
selectSection,
|
||||
editorText,
|
||||
sectionError,
|
||||
sensitiveHint,
|
||||
secretField,
|
||||
secretValue,
|
||||
confirmed,
|
||||
savedGeneration,
|
||||
validationResult,
|
||||
canWrite,
|
||||
canRollback,
|
||||
canAudit,
|
||||
canExportAudit,
|
||||
backupsLoading,
|
||||
backupsError,
|
||||
backups,
|
||||
rollbackGeneration,
|
||||
rollbackConfirmed,
|
||||
rollbackPreview,
|
||||
auditLoading,
|
||||
auditError,
|
||||
auditItems,
|
||||
databaseConfig,
|
||||
migrationTargetName,
|
||||
migrationPreview,
|
||||
migrationToken,
|
||||
migrationRecord,
|
||||
migrationStatusLabel,
|
||||
migrationStatusType,
|
||||
databaseTypeLabel,
|
||||
canMigrate,
|
||||
canRestart,
|
||||
restartPreview,
|
||||
loadAll,
|
||||
validateConfig,
|
||||
saveConfig,
|
||||
applyConfig,
|
||||
loadBackups,
|
||||
previewDatabaseMigration,
|
||||
loadMigrationStatus,
|
||||
executeDatabaseMigration,
|
||||
previewRestart,
|
||||
requestRestart,
|
||||
previewRollback,
|
||||
executeRollback,
|
||||
loadAudit,
|
||||
exportAudit,
|
||||
formatTime,
|
||||
serviceLabel,
|
||||
sectionLabel,
|
||||
operationLabel
|
||||
} = usePage()
|
||||
|
||||
void computed
|
||||
</script>
|
||||
|
||||
<style scoped src="./ConfigSettings.css"></style>
|
||||
Reference in new issue
Block a user