perf: 优化置顶后数据请求

This commit is contained in:
kuaifan 2022-03-07 17:48:34 +08:00
parent 57567ebb1b
commit 2aa687a40b
4 changed files with 17 additions and 9 deletions

View File

@ -485,6 +485,9 @@ class DialogController extends AbstractController
}
$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(),
]);
}
}

View File

@ -1906,6 +1906,9 @@ class ProjectController extends AbstractController
}
$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(),
]);
}
}

View File

@ -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);
});

View File

@ -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);