This commit is contained in:
1 parent
8f15361557
commit
b3132edfb7
3 files changed
+139
-22
No files matched your search
@@ -181,12 +181,14 @@ const sslGroups = [
|
||||
field('tls.certificateRef', '证书文件', 'text', {
|
||||
wide: true,
|
||||
show: externalManagedCertificate,
|
||||
placeholder: 'config/ssl/example.com/fullchain.pem'
|
||||
placeholder: 'config/ssl/example.com/fullchain.pem',
|
||||
hint: '填写后端服务器上的 PEM 证书路径。自定义模式支持绝对路径或相对运行根目录的路径,保存后显示导入后的受管路径;Web 服务器管理模式填写已有受管证书的相对路径。'
|
||||
}),
|
||||
field('tls.privateKeyRef', '私钥文件', 'text', {
|
||||
wide: true,
|
||||
show: externalManagedCertificate,
|
||||
placeholder: 'config/ssl/example.com/privkey.pem'
|
||||
placeholder: 'config/ssl/example.com/privkey.pem',
|
||||
hint: '填写与证书匹配的 PEM 私钥文件路径,不是私钥内容。文件必须可被后端运行用户读取;自定义模式保存后显示受管副本的路径。'
|
||||
})
|
||||
])
|
||||
]
|
||||
|
||||
@@ -275,7 +275,7 @@ export function usePage(pageKey = 'base') {
|
||||
}
|
||||
}
|
||||
|
||||
const loadSection = async () => {
|
||||
const loadSection = async ({ minimumGeneration = 0 } = {}) => {
|
||||
const requestId = ++sectionRequestId
|
||||
const section = apiSection()
|
||||
sectionLoading.value = true
|
||||
@@ -290,19 +290,25 @@ export function usePage(pageKey = 'base') {
|
||||
savedInput = null
|
||||
try {
|
||||
const response = await http.get(`/api/v1/config/${section}`)
|
||||
if (requestId !== sectionRequestId) return
|
||||
if (requestId !== sectionRequestId || disposed) return false
|
||||
notifyResponseError(response, '配置分区读取失败')
|
||||
const publicConfig = response.data || {}
|
||||
const generation = Number(section === 'base' ? publicConfig.generation : publicConfig.meta?.generation)
|
||||
if (minimumGeneration && (!Number.isSafeInteger(generation) || generation < minimumGeneration)) {
|
||||
throw new Error('读取到的配置版本落后于本次保存,请刷新状态核对')
|
||||
}
|
||||
editorText.value = JSON.stringify(publicConfig, null, 2)
|
||||
loadedText.value = editorText.value
|
||||
if (section === 'base') {
|
||||
const database = publicConfig.database || {}
|
||||
Object.assign(databaseConfig, { type: database.type || '', name: database.name || '', localRef: database.localRef || '' })
|
||||
}
|
||||
return true
|
||||
} catch (error) {
|
||||
if (requestId !== sectionRequestId) return
|
||||
if (requestId !== sectionRequestId || disposed) return false
|
||||
sectionError.value = error.message || '配置分区读取失败'
|
||||
editorText.value = ''
|
||||
return false
|
||||
} finally {
|
||||
if (requestId === sectionRequestId) sectionLoading.value = false
|
||||
}
|
||||
@@ -597,6 +603,8 @@ export function usePage(pageKey = 'base') {
|
||||
return false
|
||||
}
|
||||
working.value = 'apply'
|
||||
const generation = savedGeneration.value
|
||||
let applied = false
|
||||
try {
|
||||
const response = await requestWithRecentAuthentication(() => http.post(
|
||||
`/api/v1/config/${apiSection()}/apply`,
|
||||
@@ -606,13 +614,30 @@ export function usePage(pageKey = 'base') {
|
||||
}
|
||||
))
|
||||
notifyResponseError(response, '配置保存失败')
|
||||
savedGeneration.value = 0
|
||||
await Promise.all([loadStatus(), loadSection()])
|
||||
applied = true
|
||||
// 服务端已提交的候选不能再次应用;回读失败时只允许刷新,不误报保存失败或展示旧配置。
|
||||
pendingCandidate.value = null
|
||||
invalidateCandidate()
|
||||
await loadStatus()
|
||||
if (disposed) return false
|
||||
if (!Number.isSafeInteger(Number(status.activeGeneration)) || Number(status.activeGeneration) < generation) {
|
||||
throw new Error('配置状态尚未更新')
|
||||
}
|
||||
if (!await loadSection({ minimumGeneration: generation })) throw new Error('最新配置读取失败')
|
||||
await loadPending()
|
||||
if (disposed) return false
|
||||
ElMessage.success(successMessage)
|
||||
return true
|
||||
} catch (error) {
|
||||
if (disposed) return false
|
||||
if (isRecentAuthenticationCancelled(error)) return false
|
||||
if (applied) {
|
||||
sectionError.value = '配置已应用,但最新配置读取失败,请刷新状态核对'
|
||||
editorText.value = ''
|
||||
loadedText.value = ''
|
||||
ElMessage.warning(sectionError.value)
|
||||
return false
|
||||
}
|
||||
ElMessage.error(error.message || '配置保存失败')
|
||||
return false
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user