perf: 项目、消息对话置顶后要滚动到可以看到它的位置

This commit is contained in:
kuaifan 2022-03-07 01:35:12 +08:00
parent b0b7c63561
commit 41ceb9bd82
3 changed files with 31 additions and 17 deletions

View File

@ -889,9 +889,17 @@ export default {
project_id: this.topOperateItem.id, project_id: this.topOperateItem.id,
}, },
}).then(() => { }).then(() => {
this.$store.dispatch("getProjects").catch(() => {}); this.$store.dispatch("getProjects").then(() => {
let active = this.$refs.projectWrapper.querySelector(".active")
if (active) {
$A.scrollToView(active, {
behavior: 'smooth',
scrollMode: 'if-needed',
});
}
}).catch(() => {});
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg);
}); });
}, },

View File

@ -470,11 +470,11 @@ export default {
dialog_id: this.topOperateItem.id, dialog_id: this.topOperateItem.id,
}, },
}).then(() => { }).then(() => {
this.$store.dispatch("getDialogs"); this.$store.dispatch("getDialogs").then(() => {
this.$Modal.remove(); this.scrollIntoActive(true)
});
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg);
this.$Modal.remove();
}); });
} }
} }

View File

@ -205,7 +205,7 @@ export default {
*/ */
getBasicData({dispatch}) { getBasicData({dispatch}) {
dispatch("getProjects").catch(() => {}); dispatch("getProjects").catch(() => {});
dispatch("getDialogs"); dispatch("getDialogs").catch(() => {});
dispatch("getTaskForDashboard"); dispatch("getTaskForDashboard");
}, },
@ -1813,18 +1813,24 @@ export default {
* 获取会话列表 * 获取会话列表
* @param state * @param state
* @param dispatch * @param dispatch
* @returns {Promise<unknown>}
*/ */
getDialogs({state, dispatch}) { getDialogs({state, dispatch}) {
if (state.userId === 0) { return new Promise(function (resolve, reject) {
state.cacheDialogs = []; if (state.userId === 0) {
return; state.cacheDialogs = [];
} reject({msg: 'Parameter error'});
dispatch("call", { return;
url: 'dialog/lists', }
}).then(result => { dispatch("call", {
dispatch("saveDialog", result.data.data); url: 'dialog/lists',
}).catch(e => { }).then(result => {
console.warn(e); dispatch("saveDialog", result.data.data);
resolve(result)
}).catch(e => {
console.warn(e);
reject(e)
});
}); });
}, },