Authored by 陈峰

commit

... ... @@ -179,6 +179,7 @@ export default {
if (reload) {
this.noMore = false;
this.list = [];
this.items = [];
}
this.loadings.push('pending');
this.onFetch().then((res) => {
... ...
... ... @@ -2,6 +2,7 @@
<Article
ref="article"
type="article"
:thumbs="articleThumbList"
share
:on-fetch="onFetch">
</Article>
... ... @@ -12,7 +13,7 @@ import {get} from 'lodash';
import Article from './components/article/article';
import ArticleItem from './components/article/article-item';
import {createNamespacedHelpers} from 'vuex';
const {mapActions} = createNamespacedHelpers('article');
const {mapState, mapActions} = createNamespacedHelpers('article');
export default {
name: 'ArticleSharePage',
... ... @@ -31,6 +32,21 @@ export default {
this.init();
}
},
async serverPrefetch() {
const articleId = parseInt(this.id, 10);
if (!articleId) {
return;
}
return this.fetchArticleList({
articleId,
limit: 2,
thumb: true
});
},
computed: {
...mapState(['articleThumbList'])
},
methods: {
...mapActions(['fetchArticleList']),
init() {
... ...
... ... @@ -21,7 +21,7 @@ export default {
page: 1,
labelId: 0,
reload: true,
labelName: ''
labelName: '',
};
},
created() {
... ... @@ -32,6 +32,7 @@ export default {
if (+this.$route.params.labelId !== this.labelId) {
this.labelId = +this.$route.params.labelId;
this.labelName = this.$route.params.labelName;
this.reload = true;
this.init();
}
},
... ... @@ -67,10 +68,11 @@ export default {
articles: result.data.detailList
});
return new Promise(resolve => {
if (this.page === 2) {
if (this.reload) {
setTimeout(() => {
resolve(result.data.detailList);
}, 200);
this.reload = false;
} else {
resolve(result.data.detailList);
}
... ...
const MAX_WIDTH = 750;
export function getArticleImageSize({width, height, MIN_SCALE}) {
export function getArticleImageSize({width, height, MIN_SCALE = 0.75}) {
width = +width;
height = +height;
if (width > MAX_WIDTH) {
... ...