From 47b9b250329f8a564327f00bf22130fe8305d406 Mon Sep 17 00:00:00 2001 From: xiaomai Date: Thu, 30 Apr 2026 14:31:25 +0800 Subject: [PATCH] feat(ui): separate items and recipes into distinct views Extract recipe list from ItemsList into a dedicated RecipeList view Update navigation menu and routing for the new recipes page --- frontend/src/App.vue | 3 +- frontend/src/router/index.ts | 2 + frontend/src/views/ItemsList.vue | 43 ++++---------- frontend/src/views/RecipeDetail.vue | 2 +- frontend/src/views/RecipeList.vue | 87 +++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 35 deletions(-) create mode 100644 frontend/src/views/RecipeList.vue diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 8a0e36e..0f2806b 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -7,7 +7,8 @@ import { api, getAuthToken, onAuthTokenChange, setAuthToken, type AuthUser } fro const navItems = [ { label: 'Pokemon', to: '/pokemon' }, { label: '栖息地', to: '/habitats' }, - { label: '物品 / 材料单', to: '/items' }, + { label: '物品', to: '/items' }, + { label: '材料单', to: '/recipes' }, { label: '管理', to: '/admin' } ]; diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index cb765ec..1cde678 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -5,6 +5,7 @@ import HabitatList from '../views/HabitatList.vue'; import HabitatDetail from '../views/HabitatDetail.vue'; import ItemsList from '../views/ItemsList.vue'; import ItemDetail from '../views/ItemDetail.vue'; +import RecipeList from '../views/RecipeList.vue'; import RecipeDetail from '../views/RecipeDetail.vue'; import AdminView from '../views/AdminView.vue'; import LoginView from '../views/LoginView.vue'; @@ -22,6 +23,7 @@ export const router = createRouter({ { path: '/habitats/:id', component: HabitatDetail }, { path: '/items', component: ItemsList }, { path: '/items/:id', component: ItemDetail }, + { path: '/recipes', component: RecipeList }, { path: '/recipes/:id', component: RecipeDetail }, { path: '/admin', component: AdminView }, { path: '/login', component: LoginView }, diff --git a/frontend/src/views/ItemsList.vue b/frontend/src/views/ItemsList.vue index b48e7a2..567ecde 100644 --- a/frontend/src/views/ItemsList.vue +++ b/frontend/src/views/ItemsList.vue @@ -8,22 +8,16 @@ import PageHeader from '../components/PageHeader.vue'; import Skeleton from '../components/Skeleton.vue'; import Tabs, { type TabOption } from '../components/Tabs.vue'; import TagsSelect from '../components/TagsSelect.vue'; -import { api, type Item, type Options, type Recipe } from '../services/api'; +import { api, type Item, type Options } from '../services/api'; -const tab = ref<'items' | 'recipes'>('items'); const options = ref(null); const items = ref([]); -const recipes = ref([]); const loading = ref(true); const search = ref(''); const categoryId = ref(''); const usageId = ref(''); const tagIds = ref([]); -const itemTypeTabs: TabOption[] = [ - { value: 'items', label: '物品' }, - { value: 'recipes', label: '材料单' } -]; const categorySkeletonWidths = ['64px', '92px', '78px', '104px', '86px']; const filterSkeletonWidths = ['52px', '48px', '48px']; const skeletonCardCount = 6; @@ -40,17 +34,9 @@ const itemQuery = computed(() => ({ tagIds: tagIds.value.join(',') })); -const recipeQuery = computed(() => ({ - categoryId: categoryId.value -})); - async function loadItems() { loading.value = true; - if (tab.value === 'items') { - items.value = await api.items(itemQuery.value); - } else { - recipes.value = await api.recipes(recipeQuery.value); - } + items.value = await api.items(itemQuery.value); loading.value = false; } @@ -59,17 +45,15 @@ onMounted(async () => { await loadItems(); }); -watch([tab, itemQuery, recipeQuery], loadItems); +watch(itemQuery, loadItems); diff --git a/frontend/src/views/RecipeDetail.vue b/frontend/src/views/RecipeDetail.vue index df5e97c..3b8e22a 100644 --- a/frontend/src/views/RecipeDetail.vue +++ b/frontend/src/views/RecipeDetail.vue @@ -50,7 +50,7 @@ onMounted(async () => { diff --git a/frontend/src/views/RecipeList.vue b/frontend/src/views/RecipeList.vue new file mode 100644 index 0000000..fdaf8e7 --- /dev/null +++ b/frontend/src/views/RecipeList.vue @@ -0,0 +1,87 @@ + + +