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,
},
}).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}) => {
$A.modalError(msg, 301);
$A.modalError(msg);
});
},

View File

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

View File

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