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", { dispatch("call", {
url: 'project/lists', url: 'project/lists',
data: callData.get() data: callData.get()
}).then(({data, xhr}) => { }).then(({data}) => {
dispatch("saveProject", data.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; state.projectTotal = data.total_all;
// //
resolve(data) resolve(data)
@ -1853,12 +1853,12 @@ export default {
dispatch("call", { dispatch("call", {
url: 'project/task/lists', url: 'project/task/lists',
data: callData.get() data: callData.get()
}).then(({data, xhr}) => { }).then(({data}) => {
if (requestData.project_id) { if (requestData.project_id) {
state.projectLoad--; state.projectLoad--;
} }
dispatch("saveTask", data.data); 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) { if (data.next_page_url) {
requestData.page = data.current_page + 1 requestData.page = data.current_page + 1
@ -2757,9 +2757,9 @@ export default {
dispatch("call", { dispatch("call", {
url: 'dialog/lists', url: 'dialog/lists',
data: callData.get() data: callData.get()
}).then(({data, xhr}) => { }).then(({data}) => {
dispatch("saveDialog", data.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) { if (data.current_page === 1) {
dispatch("getDialogLatestMsgs", data.data.map(({id}) => id)) dispatch("getDialogLatestMsgs", data.data.map(({id}) => id))

View File

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