Skip to content

Commit

Permalink
1、修复标签文章列表、分类文章列表下无文章时 UI Bug
Browse files Browse the repository at this point in the history
2、标签文章列表右边栏添加【分类展示】
  • Loading branch information
weiwosuoai committed Jul 12, 2023
1 parent 8e023d2 commit e967db3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion weblog-vue3/src/pages/frontend/category-article-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{ categoryName }}
</div>
<!-- 文章列表 -->
<div class="el-card mb-3" v-if="articles.length > 0" v-for="(article, index) in articles" :key="index">
<div class="el-card mb-3" v-if="articles && articles.length > 0" v-for="(article, index) in articles" :key="index">
<el-row :gutter="20">
<el-col :span="10" :offset="0">
<a class="cursor-pointer" @click="goArticleDetail(article.id)">
Expand Down
28 changes: 27 additions & 1 deletion weblog-vue3/src/pages/frontend/tag-article-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{ tagName }}
</div>
<!-- 文章列表 -->
<div class="el-card mb-3" v-if="articles.length > 0" v-for="(article, index) in articles" :key="index">
<div class="el-card mb-3" v-if="articles && articles.length > 0" v-for="(article, index) in articles" :key="index">
<el-row :gutter="20">
<el-col :span="10" :offset="0">
<a class="cursor-pointer" @click="goArticleDetail(article.id)">
Expand Down Expand Up @@ -84,6 +84,21 @@
</el-col>
<el-col :span="7" :offset="0">
<UserInfoCard></UserInfoCard>

<!-- 文章分类 -->
<el-card shadow="none" class="mb-5">
<h2 class="font-bold mb-2">分类</h2>
<ul class="text-gray-500 ml-2">
<li class="flex items-center" v-for="(item, index) in categories" :key="index">
<a class="category-item" @click="goCatagoryArticleListPage(item.id, item.name)">
<el-icon class="mr-1">
<FolderOpened />
</el-icon>
{{ item.name }}
</a>
</li>
</ul>
</el-card>
</el-col>
</el-row>
</div>
Expand All @@ -98,6 +113,7 @@ import UserInfoCard from '@/components/UserInfoCard.vue'
import { useRouter, useRoute } from 'vue-router'
import { ref } from 'vue'
import { getTagArticles } from '@/api/frontend/tag'
import { getCategories } from '@/api/frontend/category'
const router = useRouter()
const route = useRoute()
Expand Down Expand Up @@ -135,6 +151,16 @@ const goCatagoryArticleListPage = (id, name) => {
router.push({ path: '/category/list', query: { id: id, name: name } })
}
// 获取分类
const categories = ref([])
getCategories().then((e) => {
console.log('获取分类数据')
console.log(e)
categories.value = e.data
})
</script>

<style scoped>
Expand Down

0 comments on commit e967db3

Please sign in to comment.