diff --git a/client/src/pages/Blog.vue b/client/src/pages/Blog.vue
index 6bad25e..e9f9ada 100644
--- a/client/src/pages/Blog.vue
+++ b/client/src/pages/Blog.vue
@@ -226,8 +226,34 @@ const highlightText = (text: string | undefined) => {
return text.replace(regex, '$1')
}
-onMounted(() => {
- loadFilters()
+onMounted(async () => {
+ // 先加载筛选选项
+ await loadFilters()
+
+ // 从 sessionStorage 读取传递的参数(不在URL显示)
+ const categoryId = sessionStorage.getItem('blogFilterCategoryId')
+ const tagId = sessionStorage.getItem('blogFilterTagId')
+
+ // 如果存在参数,设置对应的选中值
+ if (categoryId) {
+ const id = Number(categoryId)
+ if (id > 0) {
+ selectedCategoryId.value = id
+ // 读取后清除,避免下次访问时仍然应用
+ sessionStorage.removeItem('blogFilterCategoryId')
+ }
+ }
+
+ if (tagId) {
+ const id = Number(tagId)
+ if (id > 0) {
+ selectedTagId.value = id
+ // 读取后清除,避免下次访问时仍然应用
+ sessionStorage.removeItem('blogFilterTagId')
+ }
+ }
+
+ // 应用筛选并获取文章列表
fetchBlogPosts()
refreshIcons()
})
diff --git a/client/src/pages/BlogDetail.vue b/client/src/pages/BlogDetail.vue
index df6a9bb..348fd67 100644
--- a/client/src/pages/BlogDetail.vue
+++ b/client/src/pages/BlogDetail.vue
@@ -60,7 +60,7 @@
分类
@@ -84,7 +84,7 @@
@@ -139,7 +139,7 @@
@@ -314,6 +314,18 @@ const router = useRouter()
const postId = route.params.id as string
const articleRef = ref(null)
+// 处理分类点击,使用 sessionStorage 传递参数(不在URL显示)
+const handleCategoryClick = (categoryId: number) => {
+ sessionStorage.setItem('blogFilterCategoryId', categoryId.toString())
+ router.push('/blog')
+}
+
+// 处理标签点击,使用 sessionStorage 传递参数(不在URL显示)
+const handleTagClick = (tagId: number) => {
+ sessionStorage.setItem('blogFilterTagId', tagId.toString())
+ router.push('/blog')
+}
+
// 目录相关状态
interface TocItem {
id: string