fix: 详情页「返回首页」改为「返回」,保留前页筛选/分页状态

- 使用 router.back() 返回上一页,保留 URL 参数(分类筛选、页码等)
- 无历史记录时兜底跳转首页
- 图标改为 🔙
This commit is contained in:
bwstudio
2026-06-11 20:53:55 +08:00
parent 8571066931
commit 45137c2f4f
+11 -2
View File
@@ -35,8 +35,8 @@
<button class="action-primary" @click="handleNext">
<span>&#x1F3B2;</span> 再看一条
</button>
<button class="action-secondary" @click="$router.push('/')">
<span>&#x1F3E0;</span> 返回首页
<button class="action-secondary" @click="goBack">
<span>&#x1F519;</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 })