perf: 优化仪表盘任务更新规则

This commit is contained in:
kuaifan 2025-01-15 15:41:38 +08:00
parent a07913181a
commit 440b633bad
2 changed files with 9 additions and 9 deletions

View File

@ -1354,9 +1354,9 @@ export default {
dispatch("call", {
url: 'project/lists',
data: callData.get()
}).then(({data, xhr}) => {
}).then(({data}) => {
dispatch("saveProject", data.data);
callData.save(data, xhr.timeData.serverDate).then(ids => dispatch("forgetProject", ids))
callData.save(data).then(ids => dispatch("forgetProject", ids))
state.projectTotal = data.total_all;
//
resolve(data)
@ -1853,12 +1853,12 @@ export default {
dispatch("call", {
url: 'project/task/lists',
data: callData.get()
}).then(({data, xhr}) => {
}).then(({data}) => {
if (requestData.project_id) {
state.projectLoad--;
}
dispatch("saveTask", data.data);
callData.save(data, xhr.timeData.serverDate).then(ids => dispatch("forgetTask", ids))
callData.save(data).then(ids => dispatch("forgetTask", ids))
//
if (data.next_page_url) {
requestData.page = data.current_page + 1
@ -2757,9 +2757,9 @@ export default {
dispatch("call", {
url: 'dialog/lists',
data: callData.get()
}).then(({data, xhr}) => {
}).then(({data}) => {
dispatch("saveDialog", data.data);
callData.save(data, xhr.timeData.serverDate).then(ids => dispatch("forgetDialog", ids))
callData.save(data).then(ids => dispatch("forgetDialog", ids))
//
if (data.current_page === 1) {
dispatch("getDialogLatestMsgs", data.data.map(({id}) => id))

View File

@ -14,6 +14,7 @@ function __callData(key, requestData, state) {
'timerange',
])).toString())
const callData = state.callAt.find(item => item.key === callKey) || {}
callData.__last = $A.dayjs().unix()
if (typeof callData.key === "undefined") {
callData.key = callKey
callData.updated = 0
@ -34,16 +35,15 @@ function __callData(key, requestData, state) {
* @param total
* @param current_page
* @param deleted_id
* @param serverDate
* @returns {Promise<unknown>}
*/
this.save = ({total, current_page, deleted_id}, serverDate = undefined) => {
this.save = ({total, current_page, deleted_id}) => {
return new Promise(async resolve => {
if (current_page !== 1) {
return
}
let hasUpdate = false
const time = $A.dayjs(serverDate).unix()
const time = callData.__last || $A.dayjs().unix()
if (total > 0) {
callData.updated = time
hasUpdate = true