perf: 优化消息窗口显示

This commit is contained in:
kuaifan 2025-04-02 20:35:03 +08:00
parent 0f250dbafd
commit 38b50a8a84
3 changed files with 28 additions and 23 deletions

View File

@ -542,8 +542,8 @@ export default {
},
//
chatMybot(userid) {
this.$store.dispatch("openDialogUserid", userid).then(_ => {
this.mybotShow = false;
this.$store.dispatch("openDialogUserid", userid).then(route => {
route && (this.mybotShow = false)
}).catch(({msg}) => {
$A.modalError(msg || this.$L('打开会话失败'))
});
@ -635,8 +635,9 @@ export default {
}
})
if (dialogId) {
this.$store.dispatch("openDialog", dialogId)
this.aibotShow = false
this.$store.dispatch("openDialog", dialogId).then(route => {
route && (this.aibotShow = false)
})
return
}
//
@ -645,8 +646,8 @@ export default {
url: 'users/search/ai',
data: {type},
}).then(({data}) => {
this.$store.dispatch("openDialogUserid", data.userid).then(_ => {
this.aibotShow = false;
this.$store.dispatch("openDialogUserid", data.userid).then(route => {
route && (this.aibotShow = false)
}).catch(({ msg }) => {
$A.modalError(msg)
}).finally(_ => {

View File

@ -516,11 +516,17 @@ export default {
if (!/^\d+$/.test(userid)) {
return
}
this.$store.dispatch("openDialogUserid", userid).then(_ => {
if (this.$parent.$options.name === "DrawerOverlayView") {
this.$parent.onClose()
} else if (this.$parent.$options.name === "Modal") {
this.$parent.close()
this.$store.dispatch("openDialogUserid", userid).then(route => {
if (!route) {
return;
}
switch (this.$parent.$options.name) {
case "DrawerOverlayView":
this.$parent.onClose()
break;
case "Modal":
this.$parent.close()
break;
}
}).catch(({msg}) => {
$A.modalError(msg)

View File

@ -3057,7 +3057,7 @@ export default {
//
if (single_window) {
dispatch('openDialogNewWindow', dialog_id);
resolve()
resolve(false)
return
}
//
@ -3065,10 +3065,9 @@ export default {
state.dialogSearchMsgId = search_msg_id;
state.dialogMsgId = dialog_msg_id;
state.dialogId = dialog_id;
if (dialog_id > 0 && state.windowLandscape) {
$A.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}});
}
resolve()
const route = dialog_id > 0 && state.windowLandscape
route && $A.goForward({name: 'manage-messenger', params: {dialogAction: 'dialog'}});
resolve(route)
})
})
},
@ -3102,7 +3101,7 @@ export default {
* @param userid
*/
openDialogUserid({state, dispatch}, userid) {
return new Promise(function (resolve, reject) {
return new Promise(async (resolve, reject) => {
const dialog = state.cacheDialogs.find(item => {
if (item.type !== 'user' || !item.dialog_user) {
return false
@ -3110,9 +3109,8 @@ export default {
return item.dialog_user.userid === userid
});
if (dialog) {
dispatch("openDialog", dialog.id);
resolve(dialog);
return;
const route = await dispatch("openDialog", dialog.id);
return resolve(route);
}
dispatch("call", {
url: 'dialog/open/user',
@ -3120,10 +3118,10 @@ export default {
userid,
},
spinner: 600
}).then(({data}) => {
}).then(async ({data}) => {
dispatch("saveDialog", data);
dispatch("openDialog", data.id);
resolve(data);
const route = await dispatch("openDialog", data.id);
resolve(route);
}).catch(e => {
console.warn(e);
reject(e);