Skip to content

Commit

Permalink
perf: 项目、消息对话置顶后要滚动到可以看到它的位置
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Mar 6, 2022
1 parent b0b7c63 commit 41ceb9b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
12 changes: 10 additions & 2 deletions resources/assets/js/pages/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
},
Expand Down
8 changes: 4 additions & 4 deletions resources/assets/js/pages/manage/messenger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down
28 changes: 17 additions & 11 deletions resources/assets/js/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default {
*/
getBasicData({dispatch}) {
dispatch("getProjects").catch(() => {});
dispatch("getDialogs");
dispatch("getDialogs").catch(() => {});
dispatch("getTaskForDashboard");
},

Expand Down Expand Up @@ -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)
});
});
},

Expand Down

0 comments on commit 41ceb9b

Please sign in to comment.