|
|
@@ -0,0 +1,169 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-row v-if="totalSize !== 0" class="movie-list">
|
|
|
+ <el-col :md="12">
|
|
|
+ <div v-for="(item, index) in dataList" :key="index" class="infinite-list-wrapper" style="overflow:auto" :md="6" :sm="12" :xs="12">
|
|
|
+ <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <el-card class="box-card">
|
|
|
+ <el-row>
|
|
|
+ <el-col :md="20">
|
|
|
+ <el-row>
|
|
|
+ <div style="padding: 14px">
|
|
|
+ <span style="left: 0;margin-bottom: 0px;color: black;">{{ item.excerpt }}</span>
|
|
|
+ </div>
|
|
|
+ </el-row>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-card>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="12">
|
|
|
+ <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
+ <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>
|
|
|
+ <el-row v-else class="not-result">
|
|
|
+ <el-col :span="12" :offset="6">
|
|
|
+ <img src="@/assets/img/icon/not-result.png">
|
|
|
+ <div>没有文章数据</div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getArticles } from '@/api/article'
|
|
|
+import SocketInstance from '@/utils/ws/socket-instance'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'ArticleStream',
|
|
|
+ filters: {
|
|
|
+ ellipsis(value) {
|
|
|
+ if (!value) return ''
|
|
|
+ const max = 50
|
|
|
+ if (value.length > max) {
|
|
|
+ return value.slice(0, max) + '...'
|
|
|
+ }
|
|
|
+ return value
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 屏幕宽度, 为了控制分页条的大小
|
|
|
+ screenWidth: document.body.clientWidth,
|
|
|
+ currentPage: 1,
|
|
|
+ pageSize: 12,
|
|
|
+ totalSize: 0,
|
|
|
+ dataList: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ document.title = '文章主页'
|
|
|
+
|
|
|
+ this.getArticlesWrapper(this.currentPage)
|
|
|
+ SocketInstance.connect()
|
|
|
+ /* if (window.Notification.permission === 'granted') {
|
|
|
+ this.sendNotification()
|
|
|
+ } else if (window.Notification.permission !== 'denied') {
|
|
|
+ window.Notification.requestPermission(function(permission) {
|
|
|
+ this.sendNotification()
|
|
|
+ })
|
|
|
+ }*/
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ // 当窗口宽度改变时获取屏幕宽度
|
|
|
+ window.onresize = () => {
|
|
|
+ return () => {
|
|
|
+ window.screenWidth = document.body.clientWidth
|
|
|
+ this.screenWidth = window.screenWidth
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ sendNotification() {
|
|
|
+ new Notification('通知标题:', {
|
|
|
+ body: '通知内容',
|
|
|
+ icon: 'https://pic1.zhuanstatic.com/zhuanzh/50b6ffe4-c7e3-4317-bc59-b2ec4931f325.png'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleCurrentChange(currentPage) {
|
|
|
+ this.currentPage = currentPage
|
|
|
+ this.getArticlesWrapper(this.currentPage)
|
|
|
+ // 回到顶部
|
|
|
+ scrollTo(0, 0)
|
|
|
+ },
|
|
|
+ getArticlesWrapper(page) {
|
|
|
+ getArticles(page).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data
|
|
|
+ this.dataList = respData.list
|
|
|
+ this.totalSize = respData.totalSize
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ refresh() {
|
|
|
+ this.$notify({
|
|
|
+ message: '接口未实现',
|
|
|
+ type: 'info',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+/*处于手机屏幕时*/
|
|
|
+@media screen and (max-width: 768px) {
|
|
|
+ .movie-list {
|
|
|
+ padding-top: 8px;
|
|
|
+ padding-left: 0.5%;
|
|
|
+ padding-right: 0.5%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .coverImg {
|
|
|
+ height: 120px !important;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.movie-list {
|
|
|
+ padding-top: 15px;
|
|
|
+ padding-left: 6%;
|
|
|
+ padding-right: 6%;
|
|
|
+}
|
|
|
+
|
|
|
+.coverImg {
|
|
|
+ width: 100%;
|
|
|
+ height: 120px;
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+
|
|
|
+.clearfix:before,
|
|
|
+.clearfix:after {
|
|
|
+ display: table;
|
|
|
+ content: "";
|
|
|
+}
|
|
|
+
|
|
|
+.clearfix:after {
|
|
|
+ clear: both;
|
|
|
+}
|
|
|
+
|
|
|
+.not-result {
|
|
|
+ padding-top: 100px;
|
|
|
+ padding-bottom: 100px;
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+
|
|
|
+</style>
|