Skip to content

Commit aa4e4f5

Browse files
committed
fix(resoure-quota): 单位转换
1 parent c8fbcaa commit aa4e4f5

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

web/dashboard/src/components/ko-configuration/ko-resource-quota.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888

8989
<script>
9090
import KoFormItem from "@/components/ko-form-item"
91+
import { cpuUnitConvert, memeryUnitConvert } from "@/utils/unitConvert"
9192
9293
export default {
9394
name: "KoLimitRange",
@@ -104,10 +105,22 @@ export default {
104105
if (newVal.hard) {
105106
for (const key in newVal.hard) {
106107
if (Object.prototype.hasOwnProperty.call(newVal.hard, key)) {
107-
data.push({
108-
key: key,
109-
value: newVal.hard[key].replace("Gi", "").replace("Mi", "").replace("m", ""),
110-
})
108+
if (key.indexOf(".cpu") !== -1) {
109+
data.push({
110+
key: key,
111+
value: cpuUnitConvert(newVal.hard[key]),
112+
})
113+
} else if (key.indexOf(".memory") !== -1 || key.indexOf(".storage") !== -1) {
114+
data.push({
115+
key: key,
116+
value: memeryUnitConvert(newVal.hard[key]),
117+
})
118+
} else {
119+
data.push({
120+
key: key,
121+
value: newVal.hard[key],
122+
})
123+
}
111124
}
112125
}
113126
}

0 commit comments

Comments
 (0)