Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix(post): (#607) 发布动态后跳转到最新动态列表并刷新
Browse files Browse the repository at this point in the history
(cherry picked from commit 7e185b9)
  • Loading branch information
mutoe committed Nov 8, 2018
1 parent a407be9 commit f846a74
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
13 changes: 9 additions & 4 deletions src/page/feed/FeedList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,23 @@ export default {
this.$store.dispatch("feed/getAdvertise");
this.onRefresh(noop);
},
activated() {
if (this.$route.query.refresh) {
this.onRefresh();
}
},
methods: {
async onRefresh(callback) {
async onRefresh() {
const type = this.feedType.replace(/^\S/, s => s.toUpperCase());
const action = `feed/get${type}Feeds`;
const data = await this.$store.dispatch(action, { refresh: true });
callback(data.length < 15);
this.$refs.loadmore.afterRefresh(data.length < 15);
},
async onLoadMore(callback) {
async onLoadMore() {
const type = this.feedType.replace(/^\S/, s => s.toUpperCase());
const action = `feed/get${type}Feeds`;
const data = await this.$store.dispatch(action, { after: this.after });
callback(data.length < 15);
this.$refs.loadmore.afterLoadMore(data.length < 15);
}
}
};
Expand Down
8 changes: 2 additions & 6 deletions src/page/post/PostImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,8 @@ export default {
validateStatus: s => s === 201
}
)
.then(({ data: { id, message = ["发布成功"] } }) => {
if (id && id > 0) {
this.$Message.success(message);
}
this.loading = false;
this.goBack();
.then(() => {
this.$router.replace("/feeds?type=new&refresh=1");
})
.catch(err => {
this.$Message.error(err.response.data);
Expand Down
9 changes: 3 additions & 6 deletions src/page/post/PostText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,10 @@ export default {
new Date().valueOf() + "" + this.$store.state.CURRENTUSER.id,
amount: this.amount
},
{
validateStatus: s => s === 201
}
{ validateStatus: s => s === 201 }
)
.then(({ data }) => {
this.$Message.success(data);
this.$router.push("/feeds?type=new");
.then(() => {
this.$router.replace("/feeds?type=new&refresh=1");
})
.catch(err => {
this.$Message.error(err.response.data);
Expand Down

0 comments on commit f846a74

Please sign in to comment.