| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <template>
- <el-row class="movie-list">
- <el-col :md="18">
- <el-scrollbar style="width: 100%; height: 80vh;">
- <el-row v-for="(item, index) in dataList" :key="index" class="movie-list">
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <span style="left: 0;margin-bottom: 0px;color: black;">
- <router-link style="text-decoration-line: none" target="_blank" :to="`/blog/post/${item.articleId}`">
- {{ item.title }}
- </router-link>
- </span>
- </div>
- <div class="text item">
- <el-row>
- <span v-html="item.summary" />
- </el-row>
- <el-row>
- <el-col style="padding: 1px" :md="2" :sm="6" :xs="6">
- <span style="left: 0;margin-bottom: 0px;color: black;">
- <router-link style="text-decoration-line: none" target="_blank" :to="`/blog/category/post?name=${item.category}`">
- <el-tag type="warning">
- {{ item.category }}
- </el-tag>
- </router-link>
- </span>
- </el-col>
- <el-col style="padding: 1px" :md="6" :sm="16" :xs="16">
- <span class="el-icon-watch" style="left: 0;margin-bottom: 0px;color: black;">
- {{ item.publishAt }}
- </span>
- </el-col>
- </el-row>
- </div>
- </el-card>
- </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-scrollbar>
- </el-col>
- <el-col :md="6">
- <el-row class="movie-list">
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <el-row>
- <span>热门</span>
- </el-row>
- </div>
- <div class="text item">
- <el-row />
- </div>
- </el-card>
- </el-row>
- </el-col>
- </el-row>
- </template>
- <script>
- import { getTagPost } from '@/api/blog'
- export default {
- name: 'TagPage',
- data() {
- return {
- queryInfo: {
- pn: 1,
- type: 'tag',
- name: ''
- },
- // 屏幕宽度, 为了控制分页条的大小
- screenWidth: document.body.clientWidth,
- currentPage: 1,
- pageSize: 10,
- totalSize: 0,
- dataList: []
- }
- },
- created() {
- const pageNumber = this.$route.query.pn
- if (pageNumber !== undefined && pageNumber !== null) {
- this.currentPage = parseInt(pageNumber)
- this.queryInfo.pn = parseInt(pageNumber)
- }
- const name = this.$route.query.name
- if (name !== undefined && name !== null) {
- this.queryInfo.name = name
- }
- const path = this.$route.path
- const arr = path.split('/')
- console.log(arr)
- if (arr.length !== 4) {
- return
- }
- if (arr[2] === 'tag') {
- this.queryInfo.type = 'tag'
- document.title = '包含标签 ' + this.queryInfo.name + ' 的文章'
- this.getData()
- } else if (arr[2] === 'category') {
- this.queryInfo.type = 'category'
- document.title = '包含分类 ' + this.queryInfo.name + ' 的文章'
- this.getData()
- }
- },
- mounted() {
- // 当窗口宽度改变时获取屏幕宽度
- window.onresize = () => {
- return () => {
- window.screenWidth = document.body.clientWidth
- this.screenWidth = window.screenWidth
- }
- }
- },
- methods: {
- handleCurrentChange(currentPage) {
- this.queryInfo.pn = currentPage
- this.$router.push({
- path: '/blog/tag',
- query: this.queryInfo
- })
- this.currentPage = currentPage
- this.getData(this.currentPage)
- // 回到顶部
- scrollTo(0, 0)
- },
- getData() {
- getTagPost(this.queryInfo).then(resp => {
- if (resp.code === 0) {
- const respData = resp.data
- this.dataList = respData.list
- this.totalSize = respData.totalSize
- } else {
- this.$message.error(resp.msg)
- }
- }).catch(error => {
- this.$message.error(error.message)
- })
- }
- }
- }
- </script>
- <style scoped>
- /*处于手机屏幕时*/
- @media screen and (max-width: 768px) {
- .movie-list {
- padding: 5px;
- }
- .coverImg {
- height: 120px !important;
- }
- }
- .movie-list {
- padding: 5px;
- }
- </style>
|