refactor(首页): 拆分 viewMore 函数为独立跳转函数
- 新增 5 个独立函数:viewMoreCeremony、viewMoreThreeAltars、viewMoreMasters、viewMoreStudents、viewMoreVolunteers - 三坛大戒参考法会流程,跳转新闻详情页 - 移除 viewMore 分发函数,模板直接调用独立函数 - 提升代码可维护性和可读性 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Showing
1 changed file
with
45 additions
and
38 deletions
| ... | @@ -90,7 +90,7 @@ | ... | @@ -90,7 +90,7 @@ |
| 90 | <div class="decorative-line" :style="decorativeLineStyle"></div> | 90 | <div class="decorative-line" :style="decorativeLineStyle"></div> |
| 91 | 91 | ||
| 92 | <!-- 查看更多按钮 --> | 92 | <!-- 查看更多按钮 --> |
| 93 | - <div class="more-button" @click="viewMore('法会流程', currentStep)"> | 93 | + <div class="more-button" @click="viewMoreCeremony(currentStep)"> |
| 94 | <span class="more-text">查看更多</span> | 94 | <span class="more-text">查看更多</span> |
| 95 | </div> | 95 | </div> |
| 96 | </div> | 96 | </div> |
| ... | @@ -113,7 +113,7 @@ | ... | @@ -113,7 +113,7 @@ |
| 113 | <div class="vertical-overlay"></div> | 113 | <div class="vertical-overlay"></div> |
| 114 | <div class="vertical-text"> | 114 | <div class="vertical-text"> |
| 115 | <h3 class="vertical-title">{{ item.name }}</h3> | 115 | <h3 class="vertical-title">{{ item.name }}</h3> |
| 116 | - <div class="vertical-more-btn" @click="viewMore(item.name, item)"> | 116 | + <div class="vertical-more-btn" @click="viewMoreThreeAltars(item)"> |
| 117 | <span class="more-text">查看更多</span> | 117 | <span class="more-text">查看更多</span> |
| 118 | </div> | 118 | </div> |
| 119 | </div> | 119 | </div> |
| ... | @@ -137,7 +137,7 @@ | ... | @@ -137,7 +137,7 @@ |
| 137 | <div class="column-overlay"></div> | 137 | <div class="column-overlay"></div> |
| 138 | <div class="column-text"> | 138 | <div class="column-text"> |
| 139 | <h3 class="column-title">{{ item.name }}</h3> | 139 | <h3 class="column-title">{{ item.name }}</h3> |
| 140 | - <div class="more-button" @click="viewMore(item.name, item)"> | 140 | + <div class="more-button" @click="viewMoreMasters(item)"> |
| 141 | <span class="more-text">查看更多</span> | 141 | <span class="more-text">查看更多</span> |
| 142 | </div> | 142 | </div> |
| 143 | </div> | 143 | </div> |
| ... | @@ -481,41 +481,48 @@ watch(currentStep, () => { | ... | @@ -481,41 +481,48 @@ watch(currentStep, () => { |
| 481 | calculateLinePosition() | 481 | calculateLinePosition() |
| 482 | }, { deep: true }) | 482 | }, { deep: true }) |
| 483 | 483 | ||
| 484 | -// 查看更多按钮点击事件 | 484 | +// 法会流程 - 跳转新闻详情页 |
| 485 | -const viewMore = (type, item) => { | 485 | +const viewMoreCeremony = (item) => { |
| 486 | - switch (type) { | 486 | + if (!item.articles?.length) { |
| 487 | - case '法会流程': | 487 | + showToast('暂无相关新闻') |
| 488 | - // 暂时使用 articles[0]['id'] 作为 id 跳转到新闻详情页 | 488 | + return |
| 489 | - if (!item.articles.length) { | 489 | + } |
| 490 | - showToast('暂无相关新闻') | 490 | + router.push({ name: 'NewsDetail', params: { id: item.articles[0]['id'] } }) |
| 491 | - return | 491 | +} |
| 492 | - } | 492 | + |
| 493 | - router.push({ name: 'NewsDetail', params: { id: item.articles[0]['id'] } }) | 493 | +// 三坛大戒 - 参考法会流程,跳转新闻详情页 |
| 494 | - break | 494 | +const viewMoreThreeAltars = (item) => { |
| 495 | - case '临坛十师': | 495 | + if (!item.articles?.length) { |
| 496 | - // 跳转到临坛十师页面的逻辑 | 496 | + showToast('暂无相关新闻') |
| 497 | - if (item?.category_link) { | 497 | + return |
| 498 | - location.href = item?.category_link; | 498 | + } |
| 499 | - } else { | 499 | + router.push({ name: 'NewsDetail', params: { id: item.articles[0]['id'] } }) |
| 500 | - router.push(`/masters?pid=${item.id}`) | 500 | +} |
| 501 | - } | 501 | + |
| 502 | - break | 502 | +// 临坛十师 - 外部链接或内部页面 |
| 503 | - case '戒子': | 503 | +const viewMoreMasters = (item) => { |
| 504 | - // 跳转到戒子页面的逻辑 | 504 | + if (item?.category_link) { |
| 505 | - if (item?.category_link) { | 505 | + location.href = item?.category_link |
| 506 | - location.href = location.origin + location.pathname + '#/' + item?.category_link; | 506 | + } else { |
| 507 | - } else { | 507 | + router.push(`/masters?pid=${item.id}`) |
| 508 | - router.push(`/students?i=${item.id}`) | 508 | + } |
| 509 | - } | 509 | +} |
| 510 | - break | 510 | + |
| 511 | - case '义工': | 511 | +// 戒子 - 外部链接或内部页面 |
| 512 | - // 跳转到义工页面的逻辑 | 512 | +const viewMoreStudents = (item) => { |
| 513 | - if (item?.category_link) { | 513 | + if (item?.category_link) { |
| 514 | - location.href = location.origin + location.pathname + '#/' + item?.category_link; | 514 | + location.href = location.origin + location.pathname + '#/' + item?.category_link |
| 515 | - } else { | 515 | + } else { |
| 516 | - router.push(`/volunteers?i=${item.id}`) | 516 | + router.push(`/students?i=${item.id}`) |
| 517 | - } | 517 | + } |
| 518 | - break | 518 | +} |
| 519 | + | ||
| 520 | +// 义工 - 外部链接或内部页面 | ||
| 521 | +const viewMoreVolunteers = (item) => { | ||
| 522 | + if (item?.category_link) { | ||
| 523 | + location.href = location.origin + location.pathname + '#/' + item?.category_link | ||
| 524 | + } else { | ||
| 525 | + router.push(`/volunteers?i=${item.id}`) | ||
| 519 | } | 526 | } |
| 520 | } | 527 | } |
| 521 | 528 | ... | ... |
-
Please register or login to post a comment