|
|
@@ -14,8 +14,8 @@
|
|
|
no-body>
|
|
|
<b-link :to="{ name: 'pages-blog-detail', params: { id: blog.id } }">
|
|
|
<b-img
|
|
|
- :src="blog.thumbnail"
|
|
|
- :alt="blog.thumbnail.slice(5)"
|
|
|
+ :src="getThumbnail(blog.thumbnail)"
|
|
|
+ :alt="getThumbnail(blog.thumbnail).slice(5)"
|
|
|
class="card-img-top" />
|
|
|
</b-link>
|
|
|
<b-card-body>
|
|
|
@@ -41,7 +41,7 @@
|
|
|
<b-link class="text-body">{{ formatName(blog.author_id) }}</b-link>
|
|
|
</small>
|
|
|
<span class="text-muted ml-75 mr-50">|</span>
|
|
|
- <small class="text-muted">{{ formatTime(blog.created_at) }}</small>
|
|
|
+ <small class="text-muted">{{ formatTime(blog.created_at, 'LLLL') }}</small>
|
|
|
</b-media-body>
|
|
|
</b-media>
|
|
|
<div class="my-1 py-25">
|
|
|
@@ -165,8 +165,8 @@
|
|
|
<b-media-aside class="mr-2">
|
|
|
<b-link :to="{ name: 'pages-blog-detail', params: { id: recentpost.id } }">
|
|
|
<b-img
|
|
|
- :src="recentpost.thumbnail"
|
|
|
- :alt="recentpost.thumbnail.slice(6)"
|
|
|
+ :src="getThumbnail(recentpost.thumbnail)"
|
|
|
+ :alt="getThumbnail(recentpost.thumbnail).slice(6)"
|
|
|
width="100"
|
|
|
rounded
|
|
|
height="70" />
|
|
|
@@ -181,7 +181,7 @@
|
|
|
</b-link>
|
|
|
</h6>
|
|
|
<span class="text-muted mb-0">
|
|
|
- {{ recentpost.createdTime }}
|
|
|
+ {{ formatTime(recentpost.created_at, 'll') }}
|
|
|
</span>
|
|
|
</b-media-body>
|
|
|
</b-media>
|
|
|
@@ -288,28 +288,31 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- useJwt.postData('/api/message/index', null).then(response => {
|
|
|
- this.blogList = response.data;
|
|
|
- }).catch(error => {
|
|
|
- console.log(error)
|
|
|
- });
|
|
|
- useJwt.postData('/api/message/user', null).then(response => {
|
|
|
- this.nameList = response.data;
|
|
|
- }).catch(error => {
|
|
|
- console.log(error)
|
|
|
- });
|
|
|
- useJwt.postData('/api/message/count', null).then(response => {
|
|
|
- this.commentList = response.data;
|
|
|
- }).catch(error => {
|
|
|
- console.log(error)
|
|
|
- });
|
|
|
- useJwt.postData('/api/message/recent', null).then(response => {
|
|
|
- this.blogSidebar = response.data;
|
|
|
- }).catch(error => {
|
|
|
- console.log(error)
|
|
|
- });
|
|
|
+ this.getAllData();
|
|
|
},
|
|
|
methods: {
|
|
|
+ getAllData() {
|
|
|
+ useJwt.postData('/api/message/index', null).then(response => {
|
|
|
+ this.blogList = response.data;
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ });
|
|
|
+ useJwt.postData('/api/message/user', null).then(response => {
|
|
|
+ this.nameList = response.data;
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ });
|
|
|
+ useJwt.postData('/api/message/count', null).then(response => {
|
|
|
+ this.commentList = response.data;
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ });
|
|
|
+ useJwt.postData('/api/message/recent', null).then(response => {
|
|
|
+ this.blogSidebar = response.data;
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ });
|
|
|
+ },
|
|
|
tagsColor(tag) {
|
|
|
if (tag === '台灣小吃') return 'light-success'
|
|
|
if (tag.includes('美食')) return 'light-info'
|
|
|
@@ -317,8 +320,8 @@ export default {
|
|
|
if (tag.includes('吃到飽')) return 'light-danger'
|
|
|
return 'light-primary'
|
|
|
},
|
|
|
- formatTime(value) {
|
|
|
- return moment(value).format('LLLL');
|
|
|
+ formatTime(value, format) {
|
|
|
+ return moment(value).format(format);
|
|
|
},
|
|
|
formatName(id) {
|
|
|
return this.nameList[id];
|
|
|
@@ -333,6 +336,9 @@ export default {
|
|
|
|
|
|
|
|
|
},
|
|
|
+ getThumbnail(img) {
|
|
|
+ return img.includes("http") ? img : "/images/" + img;
|
|
|
+ }
|
|
|
},
|
|
|
computed: {
|
|
|
blogLists() {
|
|
|
@@ -345,7 +351,8 @@ export default {
|
|
|
},
|
|
|
totalRows() {
|
|
|
return this.blogList.length;
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -353,4 +360,12 @@ export default {
|
|
|
|
|
|
<style lang="scss">
|
|
|
@import '~@resources/scss/vue/pages/page-blog.scss';
|
|
|
+
|
|
|
+.blog-recent-post-title {
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ display: -webkit-box;
|
|
|
+ -webkit-line-clamp: 2;
|
|
|
+ -webkit-box-orient: vertical;
|
|
|
+}
|
|
|
</style>
|