diff --git a/backend/app/dto/device.go b/backend/app/dto/device.go index 7aa283bd9..ca05cc5cb 100644 --- a/backend/app/dto/device.go +++ b/backend/app/dto/device.go @@ -12,6 +12,7 @@ type DeviceBaseInfo struct { SwapMemoryTotal uint64 `json:"swapMemoryTotal"` SwapMemoryAvailable uint64 `json:"swapMemoryAvailable"` SwapMemoryUsed uint64 `json:"swapMemoryUsed"` + MaxSize uint64 `json:"maxSize"` SwapDetails []SwapHelper `json:"swapDetails"` } diff --git a/backend/app/service/device.go b/backend/app/service/device.go index 0d4b00c73..60dd54230 100644 --- a/backend/app/service/device.go +++ b/backend/app/service/device.go @@ -59,6 +59,10 @@ func (u *DeviceService) LoadBaseInfo() (dto.DeviceBaseInfo, error) { if baseInfo.SwapMemoryTotal != 0 { baseInfo.SwapDetails = loadSwap() } + disks := loadDiskInfo() + for _, item := range disks { + baseInfo.MaxSize += item.Free + } return baseInfo, nil } diff --git a/frontend/src/api/interface/toolbox.ts b/frontend/src/api/interface/toolbox.ts index d27497445..f4ecc968c 100644 --- a/frontend/src/api/interface/toolbox.ts +++ b/frontend/src/api/interface/toolbox.ts @@ -11,6 +11,7 @@ export namespace Toolbox { swapMemoryTotal: number; swapMemoryAvailable: number; swapMemoryUsed: number; + maxSize: number; swapDetails: Array; } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 8f82c02d2..4fee8fba0 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -910,7 +910,8 @@ const message = { saveHelper: 'Please save the current settings first!', saveSwap: 'Saving the current configuration will adjust the Swap partition {0} size to {1}. Do you want to continue?', - saveSwapHelper: 'The minimum partition size is 40 KB. Please modify and try again!', + swapMin: 'The minimum partition size is 40 KB. Please modify and try again!', + swapMax: 'The maximum value for partition size is {0}. Please modify and try again!', swapOff: 'The minimum partition size is 40 KB. Setting it to 0 will disable the Swap partition.', }, device: { diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index f4e5c8a53..b1920891d 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -866,7 +866,8 @@ const message = { swapDeleteHelper: '此操作將移除 Swap 分區 {0},出於系統安全考慮,不會自動刪除該文件,如需刪除請手動操作!', saveHelper: '請先保存當前設置!', saveSwap: '儲存當前配置將調整 Swap 分區 {0} 大小到 {1},是否繼續?', - saveSwapHelper: '分區大小最小值為 40 KB,請修改後重試!', + swapMin: '分區大小最小值為 40 KB,請修改後重試!', + swapMax: '分區大小最大值為 {0},請修改後重試!', swapOff: '分區大小最小值為 40 KB,設置為 0 則關閉 Swap 分區。', }, device: { diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 6a6801372..8cab98514 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -867,7 +867,8 @@ const message = { swapDeleteHelper: '此操作将移除 Swap 分区 {0},出于系统安全考虑,不会自动删除该文件,如需删除请手动操作!', saveHelper: '请先保存当前设置!', saveSwap: '保存当前配置将调整 Swap 分区 {0} 大小到 {1},是否继续?', - saveSwapHelper: '分区大小最小值为 40 KB,请修改后重试!', + swapMin: '分区大小最小值为 40 KB,请修改后重试!', + swapMax: '分区大小最大值为 {0},请修改后重试!', swapOff: '分区大小最小值为 40 KB,设置成 0 则关闭 Swap 分区。', }, device: { diff --git a/frontend/src/views/toolbox/device/hosts/index.vue b/frontend/src/views/toolbox/device/hosts/index.vue index 812d98f27..972346626 100644 --- a/frontend/src/views/toolbox/device/hosts/index.vue +++ b/frontend/src/views/toolbox/device/hosts/index.vue @@ -120,12 +120,6 @@ const handleHostsDelete = (index: number) => { }; const onSave = async () => { - for (const item of form.hosts) { - if (item.ip === '' || item.host === '') { - MsgError(i18n.global.t('toolbox.device.hostHelper')); - return; - } - } loading.value = true; if (confShowType.value === 'base') { await updateDeviceHost(form.hosts) @@ -140,6 +134,12 @@ const onSave = async () => { }); return; } + for (const item of form.hosts) { + if (item.ip === '' || item.host === '') { + MsgError(i18n.global.t('toolbox.device.hostHelper')); + return; + } + } await updateDeviceByConf('Hosts', hostsConf.value) .then(() => { loading.value = false; diff --git a/frontend/src/views/toolbox/device/swap/index.vue b/frontend/src/views/toolbox/device/swap/index.vue index 7725f7331..b68fc419b 100644 --- a/frontend/src/views/toolbox/device/swap/index.vue +++ b/frontend/src/views/toolbox/device/swap/index.vue @@ -56,7 +56,7 @@