Skip to content

Commit

Permalink
perf: 优化置顶后数据请求
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Mar 7, 2022
1 parent 57567eb commit 2aa687a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
5 changes: 4 additions & 1 deletion app/Http/Controllers/Api/DialogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ public function top()
}
$dialogUser->top_at = $dialogUser->top_at ? null : Carbon::now();
$dialogUser->save();
return Base::retSuccess("success", $dialogId);
return Base::retSuccess("success", [
'id' => $dialogUser->dialog_id,
'top_at' => $dialogUser->top_at?->toDateTimeString(),
]);
}
}
5 changes: 4 additions & 1 deletion app/Http/Controllers/Api/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,9 @@ public function top()
}
$projectUser->top_at = $projectUser->top_at ? null : Carbon::now();
$projectUser->save();
return Base::retSuccess("success", $projectId);
return Base::retSuccess("success", [
'id' => $projectUser->project_id,
'top_at' => $projectUser->top_at?->toDateTimeString(),
]);
}
}
9 changes: 5 additions & 4 deletions resources/assets/js/pages/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -888,16 +888,17 @@ export default {
data: {
project_id: this.topOperateItem.id,
},
}).then(() => {
this.$store.dispatch("getProjects").then(() => {
}).then(({data}) => {
this.$store.dispatch("saveProject", data);
this.$nextTick(() => {
let active = this.$refs.projectWrapper.querySelector(".active")
if (active) {
$A.scrollToView(active, {
behavior: 'smooth',
behavior: 'instant',
scrollMode: 'if-needed',
});
}
}).catch(() => {});
});
}).catch(({msg}) => {
$A.modalError(msg);
});
Expand Down
7 changes: 4 additions & 3 deletions resources/assets/js/pages/manage/messenger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,10 @@ export default {
data: {
dialog_id: this.topOperateItem.id,
},
}).then(() => {
this.$store.dispatch("getDialogs").then(() => {
this.scrollIntoActive(true)
}).then(({data}) => {
this.$store.dispatch("saveDialog", data);
this.$nextTick(() => {
this.scrollIntoActive(false)
});
}).catch(({msg}) => {
$A.modalError(msg);
Expand Down

0 comments on commit 2aa687a

Please sign in to comment.