更新平台治理

This commit is contained in:
wangjiming
2026-08-17 09:15:36 +08:00
parent de9c8e4ffe
commit 6c1bf61ff7
13 changed files with 561 additions and 339 deletions

View File

@@ -10,8 +10,18 @@ const tenant = ref<Tenant | null>(null)
const loading = ref(false)
const quotaForm = reactive({ gpu: 0, storage: 0, maxProjects: 0 })
function parseQuota(quota: Record<string, unknown> | undefined | null) {
const q = quota || {}
function parseQuota(quota: Record<string, unknown> | undefined | null | string) {
// 兼容处理quota 可能是 JSON 字符串或嵌套 { quota: {...} } 格式
let q: Record<string, unknown> = {}
if (typeof quota === 'string') {
try { q = JSON.parse(quota) || {} } catch { q = {} }
} else if (quota && typeof quota === 'object') {
q = quota
}
// 如果是嵌套格式 { quota: { gpu: 4, ... } },提取内层
if (q.quota && typeof q.quota === 'object' && !q.gpu) {
q = q.quota as Record<string, unknown>
}
return {
gpu: Number(q.gpu || q.gpu_quota || 0),
storage: Number(q.storage || q.storage_quota || 0),