perf: 代码优化

This commit is contained in:
weifashi 2023-12-28 22:10:56 +08:00
parent 91d5bd80ff
commit 5aded9daa3
4 changed files with 18 additions and 11 deletions

View File

@ -2297,7 +2297,7 @@ class DialogController extends AbstractController
*/
public function toplist()
{
$user = User::auth();
User::auth();
//
$dialog_id = intval(Request::input('dialog_id'));
//

View File

@ -426,7 +426,6 @@ class WebSocketDialogMsg extends AbstractModel
}
}
$data['add'] = $res['data'];
$resData['tops'] = self::whereDialogId($dialog->id)->whereNotNull('top_at')->orderByDesc('top_at')->take(50)->get();
$dialog->pushMsg('update', $resData);
} else {
$this->top = $before;

View File

@ -3444,11 +3444,20 @@ export default {
}).then(({ data, msg }) => {
resolve(msg)
this.tagOrTodoOrTopSuccess(data)
this.$store.dialogTops = this.dialogMsgs.filter(item => item.dialog_id != this.dialogId)
const index = this.dialogMsgs.findIndex(({id}) => id == data.update?.id);
if (index > -1) {
const update = Object.assign({}, this.dialogMsgs[index], data.update)
this.$store.dispatch("saveDialogTop", update)
//
const dialogTops = this.dialogTops.filter(item => item.dialog_id == this.dialogId);
this.$store.dispatch("saveDialogTop", dialogTops.map(item => {
item.top = 0;
item.top_at = "";
return item;
}))
//
if (data.update?.top) {
const index = this.dialogMsgs.findIndex(({ id }) => id == data.update.id && data.update.top);
if (index > -1) {
const update = Object.assign({}, this.dialogMsgs[index], data.update)
this.$store.dispatch("saveDialogTop", update)
}
}
}).catch(({ msg }) => {
reject(msg);

View File

@ -2563,7 +2563,7 @@ export default {
dialog_id,
},
}).then(({data}) => {
if ($A.arrayLength(data) > 0) {
if ($A.isArray(data)) {
state.dialogTops = state.dialogTops.filter(item => item.dialog_id != dialog_id)
dispatch("saveDialogTop", data)
}
@ -3476,9 +3476,8 @@ export default {
dispatch("getDialogTodo", dialog_id)
}
// 更新置顶
if ($A.isArray(data.tops)) {
state.dialogTops = state.dialogTops.filter(item => item.dialog_id != data.dialog_id)
dispatch("saveDialogTop", data.tops)
if (typeof data.top !== "undefined") {
dispatch("getDialogTop", dialog_id)
}
return;
}