hookehuyr

refactor(首页): 拆分 viewMore 函数为独立跳转函数

- 新增 5 个独立函数:viewMoreCeremony、viewMoreThreeAltars、viewMoreMasters、viewMoreStudents、viewMoreVolunteers
- 三坛大戒参考法会流程,跳转新闻详情页
- 移除 viewMore 分发函数,模板直接调用独立函数
- 提升代码可维护性和可读性

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
...@@ -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,42 +481,49 @@ watch(currentStep, () => { ...@@ -481,42 +481,49 @@ 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 '法会流程':
488 - // 暂时使用 articles[0]['id'] 作为 id 跳转到新闻详情页
489 - if (!item.articles.length) {
490 showToast('暂无相关新闻') 487 showToast('暂无相关新闻')
491 return 488 return
492 } 489 }
493 router.push({ name: 'NewsDetail', params: { id: item.articles[0]['id'] } }) 490 router.push({ name: 'NewsDetail', params: { id: item.articles[0]['id'] } })
494 - break 491 +}
495 - case '临坛十师': 492 +
496 - // 跳转到临坛十师页面的逻辑 493 +// 三坛大戒 - 参考法会流程,跳转新闻详情页
494 +const viewMoreThreeAltars = (item) => {
495 + if (!item.articles?.length) {
496 + showToast('暂无相关新闻')
497 + return
498 + }
499 + router.push({ name: 'NewsDetail', params: { id: item.articles[0]['id'] } })
500 +}
501 +
502 +// 临坛十师 - 外部链接或内部页面
503 +const viewMoreMasters = (item) => {
497 if (item?.category_link) { 504 if (item?.category_link) {
498 - location.href = item?.category_link; 505 + location.href = item?.category_link
499 } else { 506 } else {
500 router.push(`/masters?pid=${item.id}`) 507 router.push(`/masters?pid=${item.id}`)
501 } 508 }
502 - break 509 +}
503 - case '戒子': 510 +
504 - // 跳转到戒子页面的逻辑 511 +// 戒子 - 外部链接或内部页面
512 +const viewMoreStudents = (item) => {
505 if (item?.category_link) { 513 if (item?.category_link) {
506 - location.href = location.origin + location.pathname + '#/' + item?.category_link; 514 + location.href = location.origin + location.pathname + '#/' + item?.category_link
507 } else { 515 } else {
508 router.push(`/students?i=${item.id}`) 516 router.push(`/students?i=${item.id}`)
509 } 517 }
510 - break 518 +}
511 - case '义工': 519 +
512 - // 跳转到义工页面的逻辑 520 +// 义工 - 外部链接或内部页面
521 +const viewMoreVolunteers = (item) => {
513 if (item?.category_link) { 522 if (item?.category_link) {
514 - location.href = location.origin + location.pathname + '#/' + item?.category_link; 523 + location.href = location.origin + location.pathname + '#/' + item?.category_link
515 } else { 524 } else {
516 router.push(`/volunteers?i=${item.id}`) 525 router.push(`/volunteers?i=${item.id}`)
517 } 526 }
518 - break
519 - }
520 } 527 }
521 528
522 // 新闻轮播相关逻辑 529 // 新闻轮播相关逻辑
......