优化博客访问量显示
This commit is contained in:
9
tonecn/src/lib/formateTimes.ts
Normal file
9
tonecn/src/lib/formateTimes.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
function formateTimes(times: number) {
|
||||
if (times < 10000)// 一万以内直接显示
|
||||
return times;
|
||||
if (times < 10000 * 10000)// 一亿以内加上 万
|
||||
return (times / 10000).toFixed(1) + '万'
|
||||
return (times / 10000 / 10000).toFixed(1) + '亿'
|
||||
}
|
||||
|
||||
export { formateTimes };
|
||||
@@ -2,6 +2,7 @@
|
||||
import { request } from '@/lib/request';
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { timestampToString } from '../lib/timestampToString'
|
||||
import { formateTimes } from '@/lib/formateTimes';
|
||||
const loadStatus = ref(0);
|
||||
const blogList = reactive([]);
|
||||
|
||||
@@ -30,7 +31,8 @@ onMounted(async () => {
|
||||
<div class="blog-container" v-for="item of blogList">
|
||||
<a class="title" :href="`/blogContent/${item.uuid}`" target="_blank">{{ item.title }}</a>
|
||||
<div class="description">{{ item.description }}</div>
|
||||
<div class="publish-time">{{ timestampToString(+item.publish_time) }} ---- {{item.visit_count}}次访问</div>
|
||||
<div class="publish-time">{{ timestampToString(+item.publish_time) }} ——
|
||||
{{ formateTimes(item.visit_count) }} 次访问</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user