feat: 添加登录功能与文章编辑功能

refactor: 重构API服务与全局状态管理

style: 优化UI样式与布局

fix: 修复文章列表与详情页的显示问题

docs: 更新类型定义与注释

chore: 更新依赖包与配置文件
This commit is contained in:
qingfeng1121
2025-10-30 19:00:59 +08:00
parent 85bf3214cc
commit 6d90b5842f
27 changed files with 2400 additions and 304 deletions

View File

@@ -1,4 +1,4 @@
import apiService from './apiService'
import api from './apiService'
/**
* 分类服务
@@ -6,49 +6,53 @@ import apiService from './apiService'
class CategoryService {
/**
* 获取所有分类
* @returns {Promise}
* @returns {Promise<import('../types').ApiResponse<import('../types').Category[]>>}
*/
getAllCategories() {
return apiService.get('/categories')
return api.get('/categories')
}
/**
* 获取指定分类
* @param {number} id - 分类ID
* @returns {Promise}
* @param {number} typeid - 分类ID
* @returns {Promise<import('../types').ApiResponse<import('../types').Category>>}
*/
getCategory(id) {
return apiService.get(`/categories/${id}`)
getCategory(typeid) {
return api.get(`/categories/${typeid}`)
}
/**
* 创建新分类
* @param {Object} categoryData - 分类数据
* @returns {Promise}
* @param {import('../types').CategoryDto} categoryData - 分类数据
* @returns {Promise<import('../types').ApiResponse<import('../types').Category>>}
*/
createCategory(categoryData) {
return apiService.post('/categories', categoryData)
return api.post('/categories', categoryData)
}
/**
* 更新分类
* @param {number} id - 分类ID
* @param {Object} categoryData - 分类数据
* @returns {Promise}
* @param {number} typeid - 分类ID
* @param {import('../types').CategoryDto} categoryData - 分类数据
* @returns {Promise<import('../types').ApiResponse<import('../types').Category>>}
*/
updateCategory(id, categoryData) {
return apiService.put(`/categories/${id}`, categoryData)
updateCategory(typeid, categoryData) {
return api.put(`/categories/${typeid}`, categoryData)
}
/**
* 删除分类
* @param {number} id - 分类ID
* @returns {Promise}
* @param {number} typeid - 分类ID
* @returns {Promise<import('../types').ApiResponse<boolean>>}
*/
deleteCategory(id) {
return apiService.delete(`/categories/${id}`)
deleteCategory(typeid) {
return api.delete(`/categories/${typeid}`)
}
}
// 导出分类服务实例
export default new CategoryService()
// 创建并导出服务实例
const categoryService = new CategoryService()
export default categoryService
// 导出服务类供特殊场景使用
export { CategoryService }