Skip to content

Commit

Permalink
优化数据显示
Browse files Browse the repository at this point in the history
  • Loading branch information
imsfc committed Sep 21, 2024
1 parent 3fc15fe commit a2023d4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
33 changes: 19 additions & 14 deletions src/components/ModularFactoryDrawerContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { computed, defineComponent, type PropType } from 'vue'
import { useI18n } from 'vue-i18n'
import { I18nT, useI18n } from 'vue-i18n'
import {
NButton,
NDataTable,
Expand Down Expand Up @@ -31,6 +31,12 @@ const renderItemQuantityPerMinute = ({

const item = getItemById(itemId)

const quantityPerMinuteCeil2 = new Decimal(quantityPerMinute)
.mul(100)
.ceil()
.div(100)
.toNumber()

return (
<NFlex align="center" wrap={false}>
<ItemImage
Expand All @@ -41,8 +47,10 @@ const renderItemQuantityPerMinute = ({
<NFlex size={2} vertical>
<div class="text-sm leading-3.5 truncate">{t(`items.${item.key}`)}</div>
<div class="text-xs leading-4 opacity-75 truncate">
{new Decimal(quantityPerMinute).mul(100).ceil().div(100).toNumber()}
{t(`perMinute`)}
<I18nT keypath="unitsPerMinute">
<b>{quantityPerMinuteCeil2}</b>
{t('itemUnitName', quantityPerMinuteCeil2)}
</I18nT>
</div>
</NFlex>
</NFlex>
Expand Down Expand Up @@ -104,11 +112,7 @@ function createColumns({
}}
min={0}
max={1000000}
>
{{
suffix: () => t('perMinute'),
}}
</NInputNumber>
/>
)
},
},
Expand Down Expand Up @@ -147,11 +151,10 @@ function createColumns({
{t(`buildings.${building.key}`)}
</div>
<div class="text-xs leading-4 opacity-75">
{buildingQuantityCeil}
<b>{buildingQuantityCeil}</b>
{buildingQuantityCeil !== buildingQuantityCeil2 && (
<>({buildingQuantityCeil2})</>
<> ({buildingQuantityCeil2})</>
)}
{t(`buildingUnits`)}
</div>
</NFlex>
</NFlex>
Expand All @@ -171,9 +174,11 @@ function createColumns({
return (
<NFlex vertical>
<div class="text-sm leading-3.5">
{new Decimal(assemblyLineComputed.averageTotalPowerUsage)
.ceil()
.toNumber()}
<b>
{new Decimal(assemblyLineComputed.averageTotalPowerUsage)
.ceil()
.toNumber()}
</b>
{' MW'}
</div>
{isArray(assemblyLineComputed.totalPowerUsage) && (
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ targetItem: Target Item
building: Building
targetItemSpeed: Target Item Speed
perMinute: /min
itemUnitName: unit | units
fluidUnitName:
unitsPerMinute: '{0} {1}/min'
seconds: s
buildingUnits: ' units'
4 changes: 3 additions & 1 deletion src/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ targetItem: 目标物品
building: 建筑
targetItemSpeed: 目标物品速率
perMinute: /分钟
itemUnitName:
fluidUnitName: 立方米
unitsPerMinute: '每分钟 {0} {1}'
seconds:
buildingUnits:

0 comments on commit a2023d4

Please sign in to comment.