feat: 实现文章搜索功能并优化留言系统

- 添加文章标题搜索功能,支持通过路由参数搜索
- 重构留言板组件,优化留言嵌套结构和交互
- 新增评论演示页面展示嵌套留言功能
- 调整主布局样式和导航菜单路由
- 修复留言板样式问题和数据字段不一致问题
This commit is contained in:
qingfeng1121
2025-10-16 16:11:58 +08:00
parent ed09611d02
commit 266310dea3
9 changed files with 501 additions and 33 deletions

View File

@@ -47,17 +47,31 @@ import { ElMessage } from 'element-plus'
const router = useRouter()
const route = useRoute()
// 响应式状态
const datas = ref([])
const loading = ref(false)
/**
* 获取文章列表
*/
const fetchArticles = async () => {
try {
try {
loading.value = true
const res = await articleService.getAllArticles()
let res = {} // 使用let而不是const
// 使用route对象获取参数而不是检查pathname
if (route.params.type ) {
console.log('根据type获取文章列表成功')
res = await articleService.getAllArticlesByType(route.params.type)
} else if (route.params.title) {
res = await articleService.getAllArticlesByTitle(route.params.title)
console.log('根据title获取文章列表成功')
} else {
res = await articleService.getAllArticles()
console.log('获取所有文章列表成功')
}
datas.value = res.data || []
console.log('获取文章列表成功:', datas.value)
} catch (error) {
@@ -65,10 +79,10 @@ const fetchArticles = async () => {
ElMessage.error('获取文章列表失败,请稍后重试')
} finally {
loading.value = false
console.log('文章列表加载完成')
}
}
/**
* 处理文章点击事件
* @param {Object} article - 文章对象