fix(plan):优化计划列表映射和保存逻辑

移除 planList 映射中未使用的 index 参数,简化代码逻辑。
调整 watch 回调执行时机,使用 flush: 'post' 确保在 DOM 更新后执行,并移除不必要的 nextTick 等待,直接调用防抖保存函数。
This commit is contained in:
MoeSnowyFox
2025-09-22 22:41:39 +08:00
parent 22ebe7e51b
commit 4114e4ffc0

View File

@@ -284,7 +284,7 @@ const initPlans = async () => {
try { try {
const response = await getPlans() const response = await getPlans()
if (response.index && response.index.length > 0) { if (response.index && response.index.length > 0) {
planList.value = response.index.map((item: any, index: number) => { planList.value = response.index.map((item: any) => {
const planId = item.uid const planId = item.uid
const planData = response.data[planId] const planData = response.data[planId]
const planType = planData?.Info?.Type || 'MaaPlan' const planType = planData?.Info?.Type || 'MaaPlan'
@@ -343,10 +343,11 @@ const getPlanTypeLabel = (planType: string) =>
watch( watch(
() => [currentPlanName.value, currentMode.value], () => [currentPlanName.value, currentMode.value],
async () => { () => {
await nextTick() // await nextTick()
await debouncedSave() debouncedSave() // 直接调用即可,无需等待
} },
{ flush: 'post' }
) )
watch( watch(