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

@@ -27,7 +27,6 @@
</div>
</div>
</transition-group>
<!-- 空状态 -->
<div v-if="!loading && articleList.length === 0" class="empty-state-container">
<el-empty description="暂无文章" />
@@ -38,11 +37,10 @@
<script setup>
import { useRouter, useRoute } from 'vue-router'
import { ref, onMounted } from 'vue'
import { articleService } from '@/services'
import { formatDate, formatRelativeTime } from '@/utils/dateUtils'
import { formatContentPreview } from '@/utils/stringUtils'
import { ElMessage } from 'element-plus'
import { messageService, categoryAttributeService } from '@/services'
import { articleService, messageService, categoryAttributeService } from '@/services'
import { useGlobalStore } from '@/store/globalStore'
// 全局状态管理
@@ -74,8 +72,8 @@ const fetchArticles = async () => {
response = await articleService.getArticlesByAttributeId(attributeData.id)
} else if (pathSegment === 'aericletitle') {
// 按标题搜索文章
const titleData = globalStore.getValue('title')
response = await articleService.getArticlesByTitle(titleData.title)
const titleData = globalStore.getValue('articleserarch')
response = await articleService.getArticlesByTitle(titleData.name)
} else {
// 获取所有文章
console.log('获取所有文章列表')
@@ -87,7 +85,7 @@ const fetchArticles = async () => {
try {
// 获取留言数量
const messageResponse = await messageService.getMessagesByArticleId(article.articleid)
console.log(`文章ID: ${article.articleid}, 分类ID: ${article.attributeid}`)
// console.log(`文章ID: ${article.articleid}, 分类ID: ${article.attributeid}`)
// 获取分类名称
const categoryResponse = await categoryAttributeService.getAttributeById(article.attributeid)
@@ -113,7 +111,7 @@ const fetchArticles = async () => {
}
// 更新文章列表
console.log(response.data)
// console.log(response.data)
articleList.value = response.data || []
} catch (error) {
console.error('获取文章列表失败:', error)
@@ -128,18 +126,13 @@ const fetchArticles = async () => {
* @param {Object} article - 文章对象
*/
const handleArticleClick = (article) => {
console.log('文章点击:', article)
// 存储文章信息到全局状态
globalStore.setValue('articleInfo', {
id: article.articleId,
name: article.title || '未命名文章',
})
globalStore.setValue('articleInfo', article)
// 跳转到文章详情页
router.push({
path: '/article/:url',
query: { url: article.articleId }
path: '/article',
})
}
@@ -205,7 +198,6 @@ onMounted(() => {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 0.05);
}
/* 文章卡片悬停渐变效果 */
.article-card::before {
content: '';