From 35aa3cc42da7dba2ed60e2f8a6c5405193a64696 Mon Sep 17 00:00:00 2001 From: MoeSnowyFox Date: Tue, 23 Sep 2025 00:02:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(plan):=20=E4=BC=98=E5=8C=96=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E9=A1=B5=E9=9D=A2=E7=BB=93=E6=9E=84=E4=B8=8E=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整 template 结构,将加载状态与主要内容分离,提升可读性 - 引入 optionsLoaded 控制选项加载时机,避免初始渲染阻塞 - 增加 onMounted 和 watch逻辑确保异步数据正确处理- 统一计划类型为 MaaPlanConfig,兼容旧类型 MaaPlan- 优化 PlanHeader 新建计划按钮交互,支持动态显示按钮文本- 改进 PlanSelector 中计划类型标签显示逻辑,仅在必要时展示 --- .../src/views/plan/components/PlanHeader.vue | 32 +++- .../views/plan/components/PlanSelector.vue | 36 ++++- frontend/src/views/plan/index.vue | 137 ++++++++---------- .../src/views/plan/tables/MaaPlanTable.vue | 56 ++++++- 4 files changed, 173 insertions(+), 88 deletions(-) diff --git a/frontend/src/views/plan/components/PlanHeader.vue b/frontend/src/views/plan/components/PlanHeader.vue index cca3358..dbce777 100644 --- a/frontend/src/views/plan/components/PlanHeader.vue +++ b/frontend/src/views/plan/components/PlanHeader.vue @@ -24,11 +24,11 @@ --> - + - 新建计划 + {{ getPlanButtonText }} @@ -54,6 +54,7 @@ @@ -131,4 +153,4 @@ const handleMenuClick = ({ key }: { key: string }) => { justify-content: center; } } - + \ No newline at end of file diff --git a/frontend/src/views/plan/components/PlanSelector.vue b/frontend/src/views/plan/components/PlanSelector.vue index a81a6bb..b610633 100644 --- a/frontend/src/views/plan/components/PlanSelector.vue +++ b/frontend/src/views/plan/components/PlanSelector.vue @@ -22,7 +22,12 @@ class="plan-button" > {{ plan.name }} - + {{ getPlanTypeLabel(plan.type) }} @@ -33,7 +38,6 @@ diff --git a/frontend/src/views/plan/index.vue b/frontend/src/views/plan/index.vue index 5b84e62..ac8fdd9 100644 --- a/frontend/src/views/plan/index.vue +++ b/frontend/src/views/plan/index.vue @@ -1,63 +1,66 @@ @@ -103,9 +106,11 @@ const tableData = ref>({}) const currentTableComponent = computed(() => { const currentPlan = planList.value.find(plan => plan.id === activePlanId.value) - const planType = currentPlan?.type || 'MaaPlan' + // 统一使用 MaaPlanConfig 作为默认类型 + const planType = + currentPlan?.type === 'MaaPlan' ? 'MaaPlanConfig' : currentPlan?.type || 'MaaPlanConfig' switch (planType) { - case 'MaaPlan': + case 'MaaPlanConfig': return MaaPlanTable default: return MaaPlanTable @@ -121,7 +126,7 @@ const debounce = any>(func: T, wait: number): T = }) as T } -const handleAddPlan = async (planType: string = 'MaaPlan') => { +const handleAddPlan = async (planType: string = 'MaaPlanConfig') => { try { const response = await createPlan(planType) const defaultName = getDefaultPlanName(planType) @@ -176,7 +181,7 @@ const saveInBackground = async (planId: string) => { const savePromise = (async () => { try { const currentPlan = planList.value.find(plan => plan.id === planId) - const planType = currentPlan?.type || 'MaaPlan' + const planType = currentPlan?.type || 'MaaPlanConfig' // Start from existing tableData, then overwrite Info explicitly const planData: Record = { ...(tableData.value || {}) } @@ -287,7 +292,7 @@ const initPlans = async () => { planList.value = response.index.map((item: any) => { const planId = item.uid const planData = response.data[planId] - const planType = planData?.Info?.Type || 'MaaPlan' + const planType = item.type === 'MaaPlan' ? 'MaaPlanConfig' : item.type || 'MaaPlanConfig' const planName = planData?.Info?.Name || getDefaultPlanName(planType) return { id: planId, name: planName, type: planType } }) @@ -306,28 +311,10 @@ const initPlans = async () => { } } -const savePlanData = async (planId?: string) => { - const targetPlanId = planId || activePlanId.value - if (!targetPlanId) return - - try { - const currentPlan = planList.value.find(plan => plan.id === targetPlanId) - const planType = currentPlan?.type || 'MaaPlan' - - const planData: Record = { ...(tableData.value || {}) } - planData.Info = { Mode: currentMode.value, Name: currentPlanName.value, Type: planType } - - await updatePlan(targetPlanId, planData) - } catch (error) { - console.error('保存计划数据失败:', error) - throw error - } -} - const getDefaultPlanName = (planType: string) => ( ({ - MaaPlan: '新 MAA 计划表', + MaaPlanConfig: '新 MAA 计划表', GeneralPlan: '新通用计划表', CustomPlan: '新自定义计划表', }) as Record @@ -335,7 +322,7 @@ const getDefaultPlanName = (planType: string) => const getPlanTypeLabel = (planType: string) => ( ({ - MaaPlan: 'MAA计划表', + MaaPlanConfig: 'MAA计划表', GeneralPlan: '通用计划表', CustomPlan: '自定义计划表', }) as Record diff --git a/frontend/src/views/plan/tables/MaaPlanTable.vue b/frontend/src/views/plan/tables/MaaPlanTable.vue index 1401524..12e6847 100644 --- a/frontend/src/views/plan/tables/MaaPlanTable.vue +++ b/frontend/src/views/plan/tables/MaaPlanTable.vue @@ -178,7 +178,7 @@