From 7f27542057999b833eb1685a066a07d3ca88d035 Mon Sep 17 00:00:00 2001 From: zhouwentao Date: Fri, 2 Jan 2026 21:59:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E6=8A=A5=E5=BF=97=E6=84=BF?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project_doing.md | 11 +++++++++++ src/pages/simulate.vue | 30 ++++++++++++++++++++---------- src/service/api/major.ts | 5 ++++- task_detail.md | 14 +++++++++++++- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/project_doing.md b/project_doing.md index ce20ada..142ffaa 100644 --- a/project_doing.md +++ b/project_doing.md @@ -12,3 +12,14 @@ - Updated `src/pages/simulate.vue` to fetch and display data in Panel A using the new API. - Implemented infinite scroll and filtering by probability. - Mapped API response fields to the UI table. + +### [Task 7] Update Major List API Response Structure +- **Time**: 2026-01-02 +- **Goal**: Adapt to the updated API response structure and implement dynamic tab counting. +- **Scope**: + - `src/service/api/major.ts` (Update interface) + - `src/pages/simulate.vue` (Update logic) +- **Result**: + - Updated `UserMajorListResponse` to support `{ list: { items: [], probCount: {} } }` structure. + - Added 'stable' (较稳妥) tab to `simulate.vue`. + - Implemented dynamic update of tab counts using `probCount` from API response. diff --git a/src/pages/simulate.vue b/src/pages/simulate.vue index 8ccc7ae..1aac946 100644 --- a/src/pages/simulate.vue +++ b/src/pages/simulate.vue @@ -86,13 +86,13 @@ const volunteerTabs = [ { key: '专科', label: '专科', count: 2, max: 64 }, ] -const currentTab = ref('all') -const tabs = [ - { key: 'all', label: '全部', count: 157 }, - { key: 'hard', label: '难录取', count: 145 }, - { key: 'risky', label: '可冲击', count: 11 }, +const currentTab = ref('stable') +const tabs = ref([ { key: 'safe', label: '可保底', count: 1 }, -] + { key: 'stable', label: '较稳妥', count: 11 }, + { key: 'risky', label: '可冲击', count: 11 }, + { key: 'hard', label: '难录取', count: 145 }, +]) const oldYears = ref(['2025','2024','2023']) // Panel A 列表数据 @@ -153,6 +153,7 @@ async function loadMore(reset = false) { let probability: string | undefined if (currentTab.value === 'hard') probability = '难录取' if (currentTab.value === 'risky') probability = '可冲击' + if (currentTab.value === 'stable') probability = '较稳妥' if (currentTab.value === 'safe') probability = '可保底' const res = await getUserMajorList({ @@ -160,12 +161,21 @@ async function loadMore(reset = false) { size: size.value, probability }) - - if (res && res.list) { - schools.value.push(...res.list) + console.warn(res) + if (res && res.list && res.list.items) { + schools.value.push(...res.list.items) total.value = res.total - if (schools.value.length >= res.total || res.list.length < size.value) { + // 更新 Tabs 计数 + if (res.list.probCount) { + tabs.value.forEach(tab => { + if (tab.key && res.list.probCount[tab.key] !== undefined) { + tab.count = res.list.probCount[tab.key] + } + }) + } + + if (schools.value.length >= res.total || res.list.items.length < size.value) { isFinished.value = true } else { page.value++ diff --git a/src/service/api/major.ts b/src/service/api/major.ts index a909329..f6bbafe 100644 --- a/src/service/api/major.ts +++ b/src/service/api/major.ts @@ -47,7 +47,10 @@ export interface MajorItem { } export interface UserMajorListResponse { - list: MajorItem[] + list: { + items: MajorItem[] + probCount: Record + } total: number page: number size: number diff --git a/task_detail.md b/task_detail.md index 169dbb5..d77987d 100644 --- a/task_detail.md +++ b/task_detail.md @@ -1,6 +1,6 @@ # Task Detail -## Session 2026-01-02 +## Session 2026-01-02 (1) - **Execution Reason**: User requested to encapsulate the "User Recommended Major List API" and integrate it into the `simulate.vue` page (Panel A). - **Execution Process**: @@ -14,3 +14,15 @@ - Updated the template to bind correct fields from `MajorItem` (e.g., `schoolName`, `enrollProbability`, `historyMajorEnrollMap`). 4. Updated project documentation (`project_index.md`, `project_codebase.md`, `project_task.md`, `project_doing.md`). - **Execution Result**: Successfully integrated the recommended major list API. Panel A in `simulate.vue` now displays real data structure (mapped from API) and supports loading more data. + +## Session 2026-01-02 (2) + +- **Execution Reason**: User updated the API response structure (`list` -> `list.items`) and requested dynamic tab counts from `list.probCount`. +- **Execution Process**: + 1. Updated `src/service/api/major.ts`: Modified `UserMajorListResponse` to include nested `items` and `probCount`. + 2. Updated `src/pages/simulate.vue`: + - Updated `tabs` definition to include 'stable' (较稳妥) and made it reactive. + - Updated `loadMore` function to access data from `res.list.items`. + - Added logic to update `tabs[].count` using `res.list.probCount`. + - Added 'stable' case to filter logic. +- **Execution Result**: The application now correctly handles the new API structure and dynamically updates the tab counts based on backend data.