diff --git a/src/views/virtualization/ImageDetail.vue b/src/views/virtualization/ImageDetail.vue index 35ccd10..5129f48 100644 --- a/src/views/virtualization/ImageDetail.vue +++ b/src/views/virtualization/ImageDetail.vue @@ -32,8 +32,13 @@ {{ statusLabel(detail.status) }} + + {{ detail.mode === 'remote' ? '远端模式' : '本地模式' }} + {{ detail.size ? formatSize(detail.size) : '-' }} {{ detail.path || '-' }} + {{ detail.url || '-' }} + {{ detail.source || '-' }} {{ detail.description || '-' }} {{ formatTimestamp(detail.created_at) }} {{ formatTimestamp(detail.updated_at) }} @@ -79,6 +84,11 @@ + + + + + @@ -160,7 +170,7 @@ const syncHostId = ref('') const reloadHostId = ref('') const formRef = ref(null) -const formData = reactive({ name: '', path: '', os_type: 'linux', type: 'system', description: '', status: '' }) +const formData = reactive({ name: '', path: '', os_type: 'linux', type: 'system', description: '', status: '', mode: 'local' }) const formRules = { name: [{ required: true, message: '请输入名称', trigger: 'blur' }], path: [{ required: true, message: '请输入路径', trigger: 'blur' }] @@ -232,7 +242,7 @@ const loadHostStatus = async () => { const handleEdit = () => { if (!detail.value) return const d = detail.value - Object.assign(formData, { name: d.name || '', path: d.path || '', os_type: d.os_type || 'linux', type: d.type || 'system', description: d.description || '', status: d.status || '' }) + Object.assign(formData, { name: d.name || '', path: d.path || '', os_type: d.os_type || 'linux', type: d.type || 'system', description: d.description || '', status: d.status || '', mode: d.mode || 'local' }) editDialogVisible.value = true } @@ -241,7 +251,7 @@ const handleSubmitEdit = () => { if (!valid) return submitLoading.value = true try { - const payload = { image_id: imageId.value, service_id: serviceId.value, image_name: formData.name, path: formData.path, os_type: formData.os_type, type: formData.type, description: formData.description || undefined, status: formData.status || undefined } + const payload = { image_id: imageId.value, service_id: serviceId.value, image_name: formData.name, path: formData.path, os_type: formData.os_type, type: formData.type, description: formData.description || undefined, status: formData.status || undefined, mode: formData.mode } Object.keys(payload).forEach(k => { if (payload[k] === undefined) delete payload[k] }) const res = await updateImage(payload) if (res?.data?.code === 200) { ElMessage.success('修改成功'); editDialogVisible.value = false; loadDetail() } diff --git a/src/views/virtualization/ImageManage.vue b/src/views/virtualization/ImageManage.vue index 9e3821d..6e6fbb7 100644 --- a/src/views/virtualization/ImageManage.vue +++ b/src/views/virtualization/ImageManage.vue @@ -54,6 +54,11 @@ {{ row.type === 'system' ? '系统' : '数据' }} + + + {{ row.mode === 'remote' ? '远端' : '本地' }} + + {{ statusLabel(row.status) }} @@ -109,6 +114,13 @@ + + + + + + 本地模式会下载镜像到主控;远端模式宿主机直接从远端URL下载 + @@ -148,10 +160,19 @@ {{ statusLabel(currentDetail.status) }} + + {{ currentDetail.mode === 'remote' ? '远端模式' : '本地模式' }} + {{ currentDetail.size ? formatSize(currentDetail.size) : '-' }} {{ currentDetail.path || '-' }} + + {{ currentDetail.url || '-' }} + + + {{ currentDetail.source || '-' }} + {{ currentDetail.description || '-' }} {{ formatTimestamp(currentDetail.created_at) }} {{ formatTimestamp(currentDetail.updated_at) }} @@ -291,7 +312,7 @@ const currentHostLabel = computed(() => { const formData = reactive({ image_id: undefined, name: '', path: '', os_type: 'linux', type: 'system', - description: '', status: '', size: 0, image_name: '' + description: '', status: '', size: 0, image_name: '', mode: 'local' }) const formRules = { @@ -400,7 +421,7 @@ const handleSearch = () => { queryParams.page = 1; loadList() } const handleAdd = () => { dialogType.value = 'add' - Object.assign(formData, { image_id: undefined, name: '', path: '', os_type: 'linux', type: 'system', description: '', status: '', size: 0 }) + Object.assign(formData, { image_id: undefined, name: '', path: '', os_type: 'linux', type: 'system', description: '', status: '', size: 0, mode: 'local' }) dialogVisible.value = true } @@ -409,7 +430,8 @@ const handleEdit = (row) => { Object.assign(formData, { image_id: row.id, name: row.name, image_name: row.name, path: row.path || '', os_type: row.os_type || 'linux', type: row.type || 'system', - description: row.description || '', status: row.status || '', size: row.size || 0 + description: row.description || '', status: row.status || '', size: row.size || 0, + mode: row.mode || 'local' }) dialogVisible.value = true } @@ -423,7 +445,8 @@ const handleSubmit = () => { if (dialogType.value === 'add') { res = await createImage({ service_id: serviceId.value, name: formData.name, path: formData.path, - os_type: formData.os_type, type: formData.type, description: formData.description || undefined + os_type: formData.os_type, type: formData.type, description: formData.description || undefined, + mode: formData.mode }) } else { const payload = { @@ -431,7 +454,8 @@ const handleSubmit = () => { image_name: formData.name, path: formData.path, os_type: formData.os_type, type: formData.type, description: formData.description || undefined, - status: formData.status || undefined, size: formData.size || undefined + status: formData.status || undefined, size: formData.size || undefined, + mode: formData.mode } // 清除 undefined Object.keys(payload).forEach(k => { if (payload[k] === undefined) delete payload[k] })