diff --git a/frontend/src/views/app-store/installed/detail/index.vue b/frontend/src/views/app-store/installed/detail/index.vue index df4d029d8..e88ebacbb 100644 --- a/frontend/src/views/app-store/installed/detail/index.vue +++ b/frontend/src/views/app-store/installed/detail/index.vue @@ -103,19 +103,27 @@ - {{ $t('container.limitHelper') }} + + {{ $t('container.limitHelper', [limits.cpu]) }}{{ $t('commons.units.core') }} + - {{ $t('container.limitHelper') }} + + {{ $t('container.limitHelper', [limits.memory]) }}{{ paramModel.memoryUnit }}B + @@ -147,6 +155,8 @@ import { Rules, checkNumberRange } from '@/global/form-rules'; import { MsgError, MsgSuccess } from '@/utils/message'; import { getLabel, splitHttp, checkIpV4V6, checkDomain } from '@/utils/util'; import i18n from '@/lang'; +import { loadResourceLimit } from '@/api/modules/container'; +import { Container } from '@/api/interface/container'; interface ParamProps { id: Number; @@ -190,6 +200,11 @@ const webUI = reactive({ protocol: 'http://', domain: '', }); +const limits = ref({ + cpu: null as number, + memory: null as number, +}); +const oldMemory = ref(0); function checkWebUI() { if (webUI.domain !== '') { @@ -237,6 +252,7 @@ const editParam = () => { paramModel.params[param.key] = param.value; }); edit.value = !edit.value; + loadLimit(); }; const changeAllowPort = () => { @@ -381,6 +397,21 @@ const showCopyButton = (key: string) => { return false; }; +const loadLimit = async () => { + const res = await loadResourceLimit(); + limits.value = res.data; + limits.value.memory = Number((limits.value.memory / 1024 / 1024).toFixed(2)); + oldMemory.value = limits.value.memory; +}; + +const changeUnit = () => { + if (paramModel.memoryUnit == 'M') { + limits.value.memory = oldMemory.value; + } else { + limits.value.memory = Number((oldMemory.value / 1024).toFixed(2)); + } +}; + defineExpose({ acceptParams });