mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-07 09:57:37 +00:00
perf: 优化state数据结构
This commit is contained in:
parent
0c7adaf67a
commit
81e4220367
@ -253,7 +253,7 @@
|
||||
v-model="workReportShow"
|
||||
placement="right"
|
||||
:size="1200">
|
||||
<Report v-if="workReportShow" :reportType="reportTabs" :reportUnreadNumber="reportUnreadNumber" @on-read="getReportUnread" />
|
||||
<Report v-if="workReportShow" :reportType="reportTabs" @on-read="$store.dispatch('getReportUnread', 1000)" />
|
||||
</DrawerOverlay>
|
||||
|
||||
<!--查看所有团队-->
|
||||
@ -373,7 +373,6 @@ export default {
|
||||
notificationManage: null,
|
||||
|
||||
reportTabs: "my",
|
||||
reportUnreadNumber: 0,
|
||||
|
||||
operateStyles: {},
|
||||
operateVisible: false,
|
||||
@ -394,7 +393,7 @@ export default {
|
||||
activated() {
|
||||
this.$store.dispatch("getUserInfo").catch(_ => {})
|
||||
this.$store.dispatch("getTaskPriority").catch(_ => {})
|
||||
this.getReportUnread(0);
|
||||
this.$store.dispatch("getReportUnread", 0)
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
@ -432,6 +431,8 @@ export default {
|
||||
'cacheTaskBrowse',
|
||||
|
||||
'dialogIns',
|
||||
|
||||
'reportUnreadNumber',
|
||||
]),
|
||||
|
||||
...mapGetters(['dashboardTask']),
|
||||
@ -617,12 +618,12 @@ export default {
|
||||
|
||||
wsOpenNum(num) {
|
||||
if (num <= 1) return
|
||||
this.$store.dispatch("getBasicData", 600).then(this.getReportUnread)
|
||||
this.$store.dispatch("getBasicData", 600)
|
||||
},
|
||||
|
||||
workReportShow(show) {
|
||||
if (show) {
|
||||
this.getReportUnread(0);
|
||||
this.$store.dispatch("getReportUnread", 0)
|
||||
}
|
||||
},
|
||||
|
||||
@ -660,7 +661,7 @@ export default {
|
||||
switch (type) {
|
||||
case 'report':
|
||||
if (action == 'unreadUpdate') {
|
||||
this.getReportUnread()
|
||||
this.$store.dispatch("getReportUnread", 1000)
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -960,21 +961,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
getReportUnread(timeout) {
|
||||
this.reportUnreadTimeout && clearTimeout(this.reportUnreadTimeout)
|
||||
this.reportUnreadTimeout = setTimeout(() => {
|
||||
if (this.userId === 0) {
|
||||
this.reportUnreadNumber = 0;
|
||||
} else {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'report/unread',
|
||||
}).then(({data}) => {
|
||||
this.reportUnreadNumber = data.total || 0;
|
||||
}).catch(() => {});
|
||||
}
|
||||
}, typeof timeout === "number" ? timeout : 1000)
|
||||
},
|
||||
|
||||
handleLongpress(event, el) {
|
||||
const projectId = $A.getAttr(el, 'data-id')
|
||||
const projectItem = this.projectLists.find(item => item.id == projectId)
|
||||
|
||||
@ -1074,7 +1074,7 @@ export default {
|
||||
|
||||
getMsgs(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(_ => this.msgLoadIng++, 2000)
|
||||
setTimeout(_ => this.msgLoadIng++, 1200)
|
||||
this.$store.dispatch("getDialogMsgs", data)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
|
||||
@ -31,6 +31,7 @@ import ReportMy from "./ReportMy"
|
||||
import ReportReceive from "./ReportReceive"
|
||||
import ReportDetail from "./ReportDetail"
|
||||
import DrawerOverlay from "../../../components/DrawerOverlay";
|
||||
import {mapState} from "vuex";
|
||||
|
||||
export default {
|
||||
name: "Report",
|
||||
@ -40,10 +41,6 @@ export default {
|
||||
},
|
||||
|
||||
props: {
|
||||
reportUnreadNumber: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
reportType: {
|
||||
default: "my"
|
||||
}
|
||||
@ -71,6 +68,12 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState([
|
||||
'reportUnreadNumber'
|
||||
])
|
||||
},
|
||||
|
||||
methods: {
|
||||
tabRebder(num) {
|
||||
return h => {
|
||||
|
||||
37
resources/assets/js/store/actions.js
vendored
37
resources/assets/js/store/actions.js
vendored
@ -342,22 +342,18 @@ export default {
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param timeout
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
getBasicData({state, dispatch}, timeout) {
|
||||
if (typeof timeout === "number") {
|
||||
return new Promise(resolve => {
|
||||
window.__getBasicData && clearTimeout(window.__getBasicData)
|
||||
if (timeout > -1) {
|
||||
window.__getBasicData = setTimeout(() => {
|
||||
dispatch("getBasicData", null)
|
||||
resolve()
|
||||
}, timeout)
|
||||
}
|
||||
});
|
||||
window.__getBasicData && clearTimeout(window.__getBasicData)
|
||||
if (timeout > -1) {
|
||||
window.__getBasicData = setTimeout(dispatch("getBasicData", null), timeout)
|
||||
}
|
||||
return
|
||||
}
|
||||
dispatch("getProjects").catch(() => {});
|
||||
dispatch("getDialogs").catch(() => {});
|
||||
dispatch("getReportUnread", 1000);
|
||||
dispatch("getTaskForDashboard");
|
||||
//
|
||||
const allIds = Object.values(state.userAvatar).map(({userid}) => userid);
|
||||
@ -366,6 +362,27 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取未读工作报告数量
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param timeout
|
||||
*/
|
||||
getReportUnread({state, dispatch}, timeout) {
|
||||
window.__getReportUnread && clearTimeout(window.__getReportUnread)
|
||||
window.__getReportUnread = setTimeout(() => {
|
||||
if (state.userId === 0) {
|
||||
state.reportUnreadNumber = 0;
|
||||
} else {
|
||||
dispatch("call", {
|
||||
url: 'report/unread',
|
||||
}).then(({data}) => {
|
||||
state.reportUnreadNumber = data.total || 0;
|
||||
}).catch(_ => {});
|
||||
}
|
||||
}, typeof timeout === "number" ? timeout : 1000)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取/更新会员信息
|
||||
* @param dispatch
|
||||
|
||||
3
resources/assets/js/store/state.js
vendored
3
resources/assets/js/store/state.js
vendored
@ -150,4 +150,7 @@ export default {
|
||||
// 预览图片
|
||||
previewImageIndex: 0,
|
||||
previewImageList: [],
|
||||
|
||||
// 工作报告未读数量
|
||||
reportUnreadNumber: 0,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user