|
|
|
@ -1,54 +1,50 @@ |
|
|
|
|
<template> |
|
|
|
|
<div v-for="article in articles" :key="article.url" id="articles"> |
|
|
|
|
<div class="grid" :style="gridStyle()"> |
|
|
|
|
<div class="image-container"> |
|
|
|
|
<img |
|
|
|
|
:src="imageIfExists(article)" |
|
|
|
|
alt="" |
|
|
|
|
class="image" |
|
|
|
|
v-if="imageIfExists(article) !== null" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div v-for="article in articles" :key="article.url" id="articles"> |
|
|
|
|
<div class="grid" :style="gridStyle()"> |
|
|
|
|
<div class="image-container"> |
|
|
|
|
<img |
|
|
|
|
:src="imageIfExists(article)" |
|
|
|
|
alt="" |
|
|
|
|
class="image" |
|
|
|
|
v-if="imageIfExists(article) !== null" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<router-link |
|
|
|
|
:to="{ name: 'detail', params: { id: article.id } }" |
|
|
|
|
class="article-info" |
|
|
|
|
> |
|
|
|
|
<span v-if="article.category !== null" class="category"> |
|
|
|
|
{{ article.category.title }} |
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
<span v-for="tag in article.tags" v-bind:key="tag" class="tag"> |
|
|
|
|
{{ tag }} |
|
|
|
|
</span> |
|
|
|
|
<!-- 路由链接:to的两个参数分别是: 路由名称和传入的id --> |
|
|
|
|
<router-link |
|
|
|
|
:to="{ name: 'detail', params: { id: article.id } }" |
|
|
|
|
class="article-info" |
|
|
|
|
> |
|
|
|
|
<span v-if="article.category !== null" class="category"> |
|
|
|
|
{{ article.category.title }} |
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
<span |
|
|
|
|
v-for="tag in article.tags" |
|
|
|
|
v-bind:key="tag" |
|
|
|
|
class="tag" |
|
|
|
|
> |
|
|
|
|
{{ tag }} |
|
|
|
|
</span> |
|
|
|
|
<!-- 路由链接:to的两个参数分别是: 路由名称和传入的id --> |
|
|
|
|
<router-link |
|
|
|
|
:to="{ name: 'detail', params: { id: article.id } }" |
|
|
|
|
> |
|
|
|
|
<div class="article-title">{{ article.title }}</div> |
|
|
|
|
</router-link> |
|
|
|
|
|
|
|
|
|
<div> |
|
|
|
|
{{ formatted_time(article.created) }} |
|
|
|
|
</div> |
|
|
|
|
<div class="article-title">{{ article.title }}</div> |
|
|
|
|
</router-link> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<!-- 实现分页 --> |
|
|
|
|
<div id="paginator"> |
|
|
|
|
<span v-if="is_page_exists('previous')"> |
|
|
|
|
<router-link :to="get_path('previous')"> Prev </router-link> |
|
|
|
|
</span> |
|
|
|
|
<span class="current-page"> |
|
|
|
|
{{ get_page_param("current") }} |
|
|
|
|
</span> |
|
|
|
|
<span v-if="is_page_exists('next')"> |
|
|
|
|
<router-link :to="get_path('next')"> Next </router-link> |
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
<div> |
|
|
|
|
{{ formatted_time(article.created) }} |
|
|
|
|
</div> |
|
|
|
|
</router-link> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
<!-- 实现分页 --> |
|
|
|
|
<div id="paginator"> |
|
|
|
|
<span v-if="is_page_exists('previous')"> |
|
|
|
|
<router-link :to="get_path('previous')"> Prev </router-link> |
|
|
|
|
</span> |
|
|
|
|
<span class="current-page"> |
|
|
|
|
{{ get_page_param("current") }} |
|
|
|
|
</span> |
|
|
|
|
<span v-if="is_page_exists('next')"> |
|
|
|
|
<router-link :to="get_path('next')"> Next </router-link> |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
@ -157,7 +153,7 @@ export default { |
|
|
|
|
if (article.avatar) { |
|
|
|
|
return article.avatar.content; |
|
|
|
|
} else { |
|
|
|
|
// 默认头像 |
|
|
|
|
// 默认头像 |
|
|
|
|
return "http://127.0.0.1:6789/media/avatar/20221002/Blog.jpg"; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -200,7 +196,6 @@ export default { |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<style scoped> |
|
|
|
|
|
|
|
|
|
#articles { |
|
|
|
|
padding: 0.4rem; |
|
|
|
|
} |
|
|
|
@ -210,25 +205,23 @@ export default { |
|
|
|
|
border-radius: 10px; |
|
|
|
|
box-shadow: darkslategrey 0 0 12px; |
|
|
|
|
user-select: none; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
.image-container { |
|
|
|
|
width: 100%; |
|
|
|
|
display: grid; |
|
|
|
|
place-items: center; |
|
|
|
|
|
|
|
|
|
display: grid; |
|
|
|
|
place-items: center; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.article-info { |
|
|
|
|
width:90%; |
|
|
|
|
width: 90%; |
|
|
|
|
border-radius: 10px; |
|
|
|
|
background-color: lightgray; |
|
|
|
|
display: grid; |
|
|
|
|
place-items: start start; |
|
|
|
|
padding-left: 10px; |
|
|
|
|
user-select: none; |
|
|
|
|
position: relative; |
|
|
|
|
left: 20px; |
|
|
|
|
position: relative; |
|
|
|
|
left: 20px; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.article-info:hover { |
|
|
|
|