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

View File

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

View File

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