From 0b19b1ce7a77867f89f193755f9948595c4bc5f0 Mon Sep 17 00:00:00 2001 From: imsfc Date: Sat, 21 Sep 2024 04:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=20ItemRecipeSelect=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/items/index.ts | 4 +- src/components/ItemRecipeSelect.tsx | 76 ++++++++++++++++++----------- src/components/ItemSelect.tsx | 6 ++- src/locales/en.yml | 2 + src/locales/zh-CN.yml | 2 + 5 files changed, 58 insertions(+), 32 deletions(-) diff --git a/src/assets/items/index.ts b/src/assets/items/index.ts index 6a228a1..8f19e51 100644 --- a/src/assets/items/index.ts +++ b/src/assets/items/index.ts @@ -1,10 +1,10 @@ const images = import.meta.glob('./*.png', { - query: `?w=72;48;24&format=avif;webp;png`, + query: `?w=96;64;32&format=avif;webp;png`, import: 'default', eager: true, }) -const sizes = [72, 48, 24] as const +const sizes = [96, 64, 32] as const const formats = ['avif', 'webp', 'png'] as const export type Size = (typeof sizes)[number] diff --git a/src/components/ItemRecipeSelect.tsx b/src/components/ItemRecipeSelect.tsx index dc1a803..a5d0615 100644 --- a/src/components/ItemRecipeSelect.tsx +++ b/src/components/ItemRecipeSelect.tsx @@ -1,6 +1,11 @@ import { computed, defineComponent, watch, type PropType } from 'vue' import { useI18n } from 'vue-i18n' -import { NSelect, type SelectRenderLabel, type SelectRenderTag } from 'naive-ui' +import { + NFlex, + NSelect, + type SelectRenderLabel, + type SelectRenderTag, +} from 'naive-ui' import BuildingImage from '@/components/BuildingImage' import ItemImage from '@/components/ItemImage' @@ -11,19 +16,26 @@ const renderItem = (itemId: Id, quantity: number, perMinute: number) => { const { t } = useI18n() return ( -
+ -
- {t(`items.${itemId}`)} -
-
- {quantity}({perMinute}/min) -
-
+ +
+ {quantity}×{t(`items.${itemId}`)} +
+
+ {perMinute} + {t('perMinute')} +
+
+ ) } @@ -33,37 +45,45 @@ const renderLabel: SelectRenderLabel = (option) => { const recipe = getRecipeById(option.value as Id) return ( -
-
+ + -
+
{t(`buildings.${recipe.producedIn}`)}
-
-
-
{option.label}
-
-
+ + +
{option.label}
+ + {recipe.inputs.map(({ itemId, quantity, quantityPerMinute }) => renderItem(itemId, quantity, quantityPerMinute), )} -
-
-
-
{recipe.productionDuration}s
-
-
+ + +
+
+ {recipe.productionDuration} + {t('seconds')} +
+
+ {recipe.outputs.map(({ itemId, quantity, quantityPerMinute }) => renderItem(itemId, quantity, quantityPerMinute), )} -
-
-
-
+ + + + ) } diff --git a/src/components/ItemSelect.tsx b/src/components/ItemSelect.tsx index 0d7faff..199facc 100644 --- a/src/components/ItemSelect.tsx +++ b/src/components/ItemSelect.tsx @@ -11,10 +11,12 @@ const renderLabel: SelectRenderLabel = (option) => { -
{option.label}
+
{option.label}
) } diff --git a/src/locales/en.yml b/src/locales/en.yml index 1269970..38dfea9 100644 --- a/src/locales/en.yml +++ b/src/locales/en.yml @@ -33,3 +33,5 @@ recipe: Recipe targetItem: Target Item building: Building targetItemSpeed: Target Item Speed +perMinute: /min +seconds: s diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml index 66e53e3..60403bb 100644 --- a/src/locales/zh-CN.yml +++ b/src/locales/zh-CN.yml @@ -33,3 +33,5 @@ recipe: 配方 targetItem: 目标物品 building: 建筑 targetItemSpeed: 目标物品速率 +perMinute: /分钟 +seconds: 秒