|
|
@@ -10,7 +10,7 @@
|
|
|
<div class="text item">
|
|
|
<el-row>
|
|
|
<el-col :md="4">
|
|
|
- <router-link target="_blank" :to="`/news/${item.contentId}`">
|
|
|
+ <router-link target="_blank" :to="`/blog/post/${item.articleId}`">
|
|
|
<el-image
|
|
|
lazy
|
|
|
fit="cover"
|
|
|
@@ -20,7 +20,7 @@
|
|
|
</router-link>
|
|
|
</el-col>
|
|
|
<el-col :md="20">
|
|
|
- <router-link style="text-decoration-line: none" target="_blank" :to="`/news/${item.contentId}`">
|
|
|
+ <router-link style="text-decoration-line: none" target="_blank" :to="`/blog/post/${item.articleId}`">
|
|
|
<el-row>
|
|
|
<div style="padding: 14px">
|
|
|
<span style="left: 0;margin-bottom: 0px;color: black;">{{ item.title | ellipsis }}</span>
|
|
|
@@ -37,13 +37,17 @@
|
|
|
</div>
|
|
|
</el-card>
|
|
|
</el-row>
|
|
|
- <el-row>
|
|
|
- <div v-if="hasMore" style="display: flex; justify-content: center;">
|
|
|
- <el-button link type="plain" icon="el-icon-bottom" @click="loadMore">
|
|
|
- 加载更多
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </el-row>
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ :small="screenWidth <= 768"
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :page-size="pageSize"
|
|
|
+ :current-page="currentPage"
|
|
|
+ :total="totalSize"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ @prev-click="handleCurrentChange"
|
|
|
+ @next-click="handleCurrentChange"
|
|
|
+ />
|
|
|
</el-col>
|
|
|
<el-col :md="6">
|
|
|
<el-row class="movie-list">
|
|
|
@@ -64,7 +68,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getNewsList } from '@/api/blog'
|
|
|
+import {getBlogPostList } from '@/api/blog'
|
|
|
|
|
|
export default {
|
|
|
name: 'ArticleIndex',
|
|
|
@@ -86,17 +90,25 @@ export default {
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
+ queryInfo: {
|
|
|
+ pn: 1
|
|
|
+ },
|
|
|
// 屏幕宽度, 为了控制分页条的大小
|
|
|
screenWidth: document.body.clientWidth,
|
|
|
currentPage: 1,
|
|
|
- pageSize: 12,
|
|
|
+ pageSize: 10,
|
|
|
totalSize: 0,
|
|
|
- dataList: [],
|
|
|
- hasMore: true
|
|
|
+ dataList: []
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- document.title = 'News'
|
|
|
+ const pageNumber = this.$route.query.pn
|
|
|
+ if (pageNumber !== undefined && pageNumber !== null) {
|
|
|
+ this.currentPage = parseInt(pageNumber)
|
|
|
+ this.queryInfo.pn = parseInt(pageNumber)
|
|
|
+ }
|
|
|
+
|
|
|
+ document.title = 'MyBlog'
|
|
|
this.getArticlesWrapper(this.currentPage)
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -110,28 +122,28 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
handleCurrentChange(currentPage) {
|
|
|
+ this.queryInfo.pn = currentPage
|
|
|
+ this.$router.push({
|
|
|
+ path: '/blog',
|
|
|
+ query: this.queryInfo
|
|
|
+ })
|
|
|
this.currentPage = currentPage
|
|
|
this.getArticlesWrapper(this.currentPage)
|
|
|
// 回到顶部
|
|
|
scrollTo(0, 0)
|
|
|
},
|
|
|
getArticlesWrapper(page) {
|
|
|
- getNewsList(page).then(resp => {
|
|
|
+ getBlogPostList(page).then(resp => {
|
|
|
if (resp.code === 0) {
|
|
|
const respData = resp.data
|
|
|
- this.hasMore = respData.hasNext
|
|
|
- for (const item of respData.list) {
|
|
|
- this.dataList.push(item)
|
|
|
- }
|
|
|
+ this.dataList = respData.list
|
|
|
+ this.totalSize = respData.totalSize
|
|
|
+ } else {
|
|
|
+ this.$message.error(resp.msg)
|
|
|
}
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error(error.message)
|
|
|
})
|
|
|
- },
|
|
|
- loadMore() {
|
|
|
- this.currentPage = this.currentPage + 1
|
|
|
- this.getArticlesWrapper(this.currentPage)
|
|
|
- },
|
|
|
- refresh() {
|
|
|
- this.$message.info('暂未实现')
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -167,11 +179,4 @@ export default {
|
|
|
.clearfix:after {
|
|
|
clear: both;
|
|
|
}
|
|
|
-
|
|
|
-.not-result {
|
|
|
- padding-top: 100px;
|
|
|
- padding-bottom: 100px;
|
|
|
- text-align: center;
|
|
|
-}
|
|
|
-
|
|
|
</style>
|