feat: 重构前端项目结构并添加新功能

重构项目目录结构,将组件和服务模块化
添加Element Plus UI库并集成到项目中
实现文章、留言和分类的类型定义
新增工具函数模块包括日期格式化和字符串处理
重写路由配置并添加全局路由守卫
优化页面布局和响应式设计
新增服务层封装API请求
完善文章详情页和相关文章推荐功能
This commit is contained in:
qingfeng1121
2025-10-12 14:24:20 +08:00
parent 07d3159b08
commit b8362e7835
22 changed files with 2673 additions and 453 deletions

View File

@@ -0,0 +1,75 @@
// 文章相关API服务
import apiService from './apiService'
/**
* 文章服务类
*/
class ArticleService {
/**
* 获取所有文章
* @param {Object} params - 查询参数
* @returns {Promise}
*/
getAllArticles(params = {}) {
return apiService.get('/articles', { params })
}
/**
* 获取单篇文章
* @param {number} id - 文章ID
* @returns {Promise}
*/
getArticleById(id) {
return apiService.get(`/articles/${id}`)
}
/**
* 获取热门文章
* @returns {Promise}
*/
getPopularArticles() {
return apiService.get('/articles/popular')
}
/**
* 创建文章
* @param {Object} articleData - 文章数据
* @returns {Promise}
*/
createArticle(articleData) {
return apiService.post('/articles', articleData)
}
/**
* 更新文章
* @param {number} id - 文章ID
* @param {Object} articleData - 文章数据
* @returns {Promise}
*/
updateArticle(id, articleData) {
return apiService.put(`/articles/${id}`, articleData)
}
/**
* 删除文章
* @param {number} id - 文章ID
* @returns {Promise}
*/
deleteArticle(id) {
return apiService.delete(`/articles/${id}`)
}
/**
* 增加文章浏览量
* @param {number} id - 文章ID
* @returns {Promise}
*/
incrementArticleViews(id) {
return apiService.post(`/articles/${id}/views`)
}
}
// 导出文章服务实例
export default new ArticleService()