fix: 详情页「返回首页」改为「返回」,保留前页筛选/分页状态
- 使用 router.back() 返回上一页,保留 URL 参数(分类筛选、页码等)
- 无历史记录时兜底跳转首页
- 图标改为 🔙
This commit is contained in:
@@ -35,8 +35,8 @@
|
||||
<button class="action-primary" @click="handleNext">
|
||||
<span>🎲</span> 再看一条
|
||||
</button>
|
||||
<button class="action-secondary" @click="$router.push('/')">
|
||||
<span>🏠</span> 返回首页
|
||||
<button class="action-secondary" @click="goBack">
|
||||
<span>🔙</span> 返回
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -117,6 +117,15 @@ const doDislike = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
// 优先返回上一页(保留筛选/分页状态),无历史则回首页
|
||||
if (window.history.length > 1) {
|
||||
router.back()
|
||||
} else {
|
||||
router.push('/')
|
||||
}
|
||||
}
|
||||
|
||||
const handleNext = async () => {
|
||||
try {
|
||||
const res = await getJokes({ page: 1, page_size: 50 })
|
||||
|
||||
Reference in New Issue
Block a user