|
|
@ -48,7 +48,7 @@ |
|
|
|
</a-card> |
|
|
|
</a-badge-ribbon> |
|
|
|
</div> |
|
|
|
<div class="pagination"> |
|
|
|
<div class="pagination" v-if="blogstore.isPage"> |
|
|
|
<a-pagination v-model:current="current" v-if="dataLoaded" v-model:page-size="pageSizeRef" |
|
|
|
:page-size-options="pageSizeOptions" :total="total" show-size-changer @change="onShowSizeChange"> |
|
|
|
<template #buildOptionText="props"> |
|
|
@ -57,19 +57,23 @@ |
|
|
|
</template> |
|
|
|
</a-pagination> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="is-null" v-if="blogstore.isEmpty"> |
|
|
|
<a-card hoverable> |
|
|
|
<a-empty description="没有数据" /> |
|
|
|
</a-card> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang='ts'> |
|
|
|
import { onMounted, ref } from 'vue'; |
|
|
|
import iconComponents from '@/assets'; |
|
|
|
import { useContentStore } from "@/stores" |
|
|
|
import { blogStore } from "@/stores" |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import type { blogInterface } from '@/api/admin'; |
|
|
|
import { get,put } from "@/tools/request" |
|
|
|
import router from '@/router'; |
|
|
|
const store = useContentStore() |
|
|
|
const blogstore = blogStore() |
|
|
|
const randomColor = () => { |
|
|
|
const labelColor = ref(["processing", "success", "error", "warning", "magenta", "red", "volcano", "orange", "gold", "lime", "green", "cyan", "blue", "geekblue", "purple"]) |
|
|
|
return labelColor.value[Math.floor(Math.random() * labelColor.value.length)]; |
|
|
@ -104,18 +108,21 @@ const blogList = async (page: number, pageSize: number) => { |
|
|
|
readnum: items.readnum, |
|
|
|
readminite: Math.round(items.blogcontent.length/ 200), |
|
|
|
imglink: items.imglink || 'http://www.wuruilin.cn/personself/暂无图片.jpg', |
|
|
|
|
|
|
|
})) |
|
|
|
total.value = response.data.data.total; // 更新总数 |
|
|
|
if (response.data.data.total===0) { |
|
|
|
blogstore.isEmpty=true |
|
|
|
blogstore.isPage=false |
|
|
|
}else{ |
|
|
|
blogstore.isEmpty=false |
|
|
|
blogstore.isPage=true |
|
|
|
} |
|
|
|
pageSizeRef.value = pageSize; // 更新页大小,如果需要从接口返回页大小也可以改为 response.data.data.page_size |
|
|
|
dataLoaded.value = true |
|
|
|
} catch (error) { |
|
|
|
console.error('Failed to fetch data', error); |
|
|
|
} |
|
|
|
} |
|
|
|
const blogCount=async (id:any)=>{ |
|
|
|
await put(`/blogs/update/${id}/readnum`) |
|
|
|
} |
|
|
|
|
|
|
|
const readMore = (id: any) => { |
|
|
|
router.push(`/blog/${id}`) |
|
|
@ -154,6 +161,7 @@ onMounted(() => { |
|
|
|
.main .blog-content { |
|
|
|
display: flex; |
|
|
|
margin: 48px; |
|
|
|
width: 45%; |
|
|
|
} |
|
|
|
|
|
|
|
.main .blog-content>:first-child { |
|
|
|