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