更新平台治理
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user