From 53d91fb3f8548474e9d308aabd0a2b99b54011fb Mon Sep 17 00:00:00 2001 From: MoeSnowyFox Date: Tue, 23 Sep 2025 23:33:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor(plan):=E4=BC=98=E5=8C=96=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E7=B1=BB=E5=9E=8B=E6=A0=87=E7=AD=BE=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=B9=B6=E7=AE=80=E5=8C=96=20API=20=E8=B0=83?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除 `shouldShowPlanTypeTag` 方法中不必要的 `plan` 参数,因为其判断逻辑仅依赖于计划列表长度。同时简化 `usePlanApi.ts` 中的请求返回逻辑,避免多余的变量赋值。此外,统一了 API 模块的导入路径为 `@/api`,以提高路径一致性与可维护性。 --- frontend/src/composables/usePlanApi.ts | 7 +++---- frontend/src/views/plan/components/PlanSelector.vue | 9 ++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/frontend/src/composables/usePlanApi.ts b/frontend/src/composables/usePlanApi.ts index f67a406..ebbf177 100644 --- a/frontend/src/composables/usePlanApi.ts +++ b/frontend/src/composables/usePlanApi.ts @@ -1,7 +1,7 @@ import { ref } from 'vue' import { message } from 'ant-design-vue' -import type { PlanCreateIn, PlanDeleteIn, PlanGetIn, PlanReorderIn, PlanUpdateIn } from '../api' -import { Service } from '../api' +import type { PlanCreateIn, PlanDeleteIn, PlanGetIn, PlanReorderIn, PlanUpdateIn } from '@/api' +import { Service } from '@/api' export function usePlanApi() { const loading = ref(false) @@ -11,8 +11,7 @@ export function usePlanApi() { loading.value = true try { const params: PlanGetIn = planId ? { planId } : {} - const response = await Service.getPlanApiPlanGetPost(params) - return response + return await Service.getPlanApiPlanGetPost(params) } catch (error) { console.error('获取计划失败:', error) message.error('获取计划失败') diff --git a/frontend/src/views/plan/components/PlanSelector.vue b/frontend/src/views/plan/components/PlanSelector.vue index 744046e..e2a642c 100644 --- a/frontend/src/views/plan/components/PlanSelector.vue +++ b/frontend/src/views/plan/components/PlanSelector.vue @@ -22,12 +22,7 @@ class="plan-button" > {{ plan.name }} - + {{ getPlanTypeLabel(plan.type) }} @@ -72,7 +67,7 @@ const handlePlanClick = debounce((planId: string) => { // 判断是否需要显示计划类型标签 // 当所有计划的类型都相同时不显示标签,否则显示非默认类型的标签 -const shouldShowPlanTypeTag = (plan: Plan) => { +const shouldShowPlanTypeTag = () => { // 如果只有一个计划或没有计划,不显示类型标签 if (props.planList.length <= 1) { return false