mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 13:22:49 +00:00
perf: 优化数据
This commit is contained in:
parent
4c282962b3
commit
65ced28004
13
electron/electron.js
vendored
13
electron/electron.js
vendored
@ -1271,6 +1271,19 @@ ipcMain.on('sendForwardMain', (event, args) => {
|
|||||||
event.returnValue = "ok"
|
event.returnValue = "ok"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 窗口数据同步
|
||||||
|
* @param args {type, payload}
|
||||||
|
*/
|
||||||
|
ipcMain.on('syncStore', (event, args) => {
|
||||||
|
BrowserWindow.getAllWindows().forEach(window => {
|
||||||
|
if (window.webContents.id !== event.sender.id) {
|
||||||
|
window.webContents.send('syncStore', args)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
event.returnValue = "ok"
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置Dock标记(window闪烁、macos标记)
|
* 设置Dock标记(window闪烁、macos标记)
|
||||||
* @param args
|
* @param args
|
||||||
|
|||||||
12
resources/assets/js/app.js
vendored
12
resources/assets/js/app.js
vendored
@ -206,12 +206,14 @@ if (isElectron) {
|
|||||||
|
|
||||||
// 子窗口给主窗口发送指令相关
|
// 子窗口给主窗口发送指令相关
|
||||||
$A.execMainDispatch = (action, data) => {
|
$A.execMainDispatch = (action, data) => {
|
||||||
if ($A.isSubElectron) {
|
if (!$A.isSubElectron) {
|
||||||
$A.Electron.sendMessage('sendForwardMain', {
|
return false
|
||||||
channel: 'dispatch',
|
|
||||||
data: {action, data},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
$A.Electron.sendMessage('sendForwardMain', {
|
||||||
|
channel: 'dispatch',
|
||||||
|
data: {action, data},
|
||||||
|
});
|
||||||
|
return true
|
||||||
};
|
};
|
||||||
|
|
||||||
window.execMainCacheData = {}
|
window.execMainCacheData = {}
|
||||||
|
|||||||
@ -1282,8 +1282,8 @@ export default {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.$store.dispatch("saveDialogMsg", data);
|
this.$store.dispatch("saveDialogMsg", data);
|
||||||
this.$store.dispatch("increaseTaskMsgNum", data);
|
this.$store.dispatch("increaseTaskMsgNum", data.dialog_id);
|
||||||
this.$store.dispatch("increaseMsgReplyNum", data);
|
this.$store.dispatch("increaseMsgReplyNum", data.reply_id);
|
||||||
this.$store.dispatch("updateDialogLastMsg", data);
|
this.$store.dispatch("updateDialogLastMsg", data);
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg)
|
$A.modalError(msg)
|
||||||
|
|||||||
@ -2321,8 +2321,8 @@ export default {
|
|||||||
})
|
})
|
||||||
this.$store.dispatch("saveDialogMsg", data);
|
this.$store.dispatch("saveDialogMsg", data);
|
||||||
if (!isUpdate) {
|
if (!isUpdate) {
|
||||||
this.$store.dispatch("increaseTaskMsgNum", data);
|
this.$store.dispatch("increaseTaskMsgNum", data.dialog_id);
|
||||||
this.$store.dispatch("increaseMsgReplyNum", data);
|
this.$store.dispatch("increaseMsgReplyNum", data.reply_id);
|
||||||
this.$store.dispatch("updateDialogLastMsg", data);
|
this.$store.dispatch("updateDialogLastMsg", data);
|
||||||
}
|
}
|
||||||
this.cancelQuote();
|
this.cancelQuote();
|
||||||
|
|||||||
@ -776,8 +776,8 @@ export default {
|
|||||||
if (!this.taskId) {
|
if (!this.taskId) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
let content = this.taskContents.find(({task_id}) => task_id == this.taskId)
|
const content = this.taskContents.find(({task_id}) => task_id == this.taskId)
|
||||||
return content ? content.content : ''
|
return content?.content || ''
|
||||||
},
|
},
|
||||||
|
|
||||||
fileList() {
|
fileList() {
|
||||||
|
|||||||
312
resources/assets/js/store/actions.js
vendored
312
resources/assets/js/store/actions.js
vendored
@ -464,8 +464,7 @@ export default {
|
|||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
filePos({state, dispatch}, params) {
|
filePos({state, dispatch}, params) {
|
||||||
if ($A.isSubElectron) {
|
if ($A.execMainDispatch("filePos", params)) {
|
||||||
$A.execMainDispatch("filePos", params)
|
|
||||||
$A.Electron.sendMessage('mainWindowActive');
|
$A.Electron.sendMessage('mainWindowActive');
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -478,13 +477,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换面板变量
|
* 切换面板变量
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param data
|
* @param data
|
||||||
* @param data|{key, project_id}
|
* @param data|{key, project_id}
|
||||||
*/
|
*/
|
||||||
toggleProjectParameter({state}, data) {
|
toggleProjectParameter({commit, state}, data) {
|
||||||
$A.execMainDispatch("toggleProjectParameter", data)
|
|
||||||
//
|
|
||||||
let key = data;
|
let key = data;
|
||||||
let value = null;
|
let value = null;
|
||||||
let project_id = state.projectId;
|
let project_id = state.projectId;
|
||||||
@ -496,16 +494,14 @@ export default {
|
|||||||
if (project_id) {
|
if (project_id) {
|
||||||
let index = state.cacheProjectParameter.findIndex(item => item.project_id == project_id)
|
let index = state.cacheProjectParameter.findIndex(item => item.project_id == project_id)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
state.cacheProjectParameter.push($A.projectParameterTemplate(project_id));
|
commit("project/parameter/push", $A.projectParameterTemplate(project_id))
|
||||||
index = state.cacheProjectParameter.findIndex(item => item.project_id == project_id)
|
index = state.cacheProjectParameter.findIndex(item => item.project_id == project_id)
|
||||||
}
|
}
|
||||||
const cache = state.cacheProjectParameter[index];
|
const cache = state.cacheProjectParameter[index];
|
||||||
if (!$A.isJson(key)) {
|
if (!$A.isJson(key)) {
|
||||||
key = {[key]: value || !cache[key]};
|
key = {[key]: value || !cache[key]};
|
||||||
}
|
}
|
||||||
state.cacheProjectParameter.splice(index, 1, Object.assign(cache, key))
|
commit("project/parameter/splice", {index, data: Object.assign(cache, key)})
|
||||||
//
|
|
||||||
$A.IDBSave("cacheProjectParameter", state.cacheProjectParameter);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -758,7 +754,6 @@ export default {
|
|||||||
let temp = state.cacheUserBasic.find(({userid}) => userid == item.userid);
|
let temp = state.cacheUserBasic.find(({userid}) => userid == item.userid);
|
||||||
if (temp && time - temp._time <= 30) {
|
if (temp && time - temp._time <= 30) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
state.cacheUserActive = Object.assign(temp, {__:Math.random()});
|
|
||||||
emitter.emit('userActive', {type: 'cache', data: temp});
|
emitter.emit('userActive', {type: 'cache', data: temp});
|
||||||
}, timeout += 5);
|
}, timeout += 5);
|
||||||
return false;
|
return false;
|
||||||
@ -832,8 +827,6 @@ export default {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveUserBasic({commit, state}, data) {
|
saveUserBasic({commit, state}, data) {
|
||||||
$A.execMainDispatch("saveUserBasic", data)
|
|
||||||
//
|
|
||||||
const index = state.cacheUserBasic.findIndex(({userid}) => userid == data.userid);
|
const index = state.cacheUserBasic.findIndex(({userid}) => userid == data.userid);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
data = Object.assign({}, state.cacheUserBasic[index], data)
|
data = Object.assign({}, state.cacheUserBasic[index], data)
|
||||||
@ -841,7 +834,6 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
commit("user/push", data)
|
commit("user/push", data)
|
||||||
}
|
}
|
||||||
state.cacheUserActive = Object.assign(data, {__:Math.random()});
|
|
||||||
emitter.emit('userActive', {type: 'cache', data});
|
emitter.emit('userActive', {type: 'cache', data});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1108,8 +1100,7 @@ export default {
|
|||||||
* Electron 页面卸载触发
|
* Electron 页面卸载触发
|
||||||
*/
|
*/
|
||||||
onBeforeUnload() {
|
onBeforeUnload() {
|
||||||
if ($A.isSubElectron && dialogDraftState.subTemp) {
|
if (dialogDraftState.subTemp && $A.execMainDispatch("saveDialogDraft", dialogDraftState.subTemp)) {
|
||||||
$A.execMainDispatch("saveDialogDraft", dialogDraftState.subTemp)
|
|
||||||
dialogDraftState.subTemp = null;
|
dialogDraftState.subTemp = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1223,13 +1214,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存文件数据
|
* 保存文件数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveFile({state, dispatch}, data) {
|
saveFile({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveFile", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((file) => {
|
data.forEach((file) => {
|
||||||
dispatch("saveFile", file);
|
dispatch("saveFile", file);
|
||||||
@ -1238,32 +1228,29 @@ export default {
|
|||||||
let base = {_load: false, _edit: false};
|
let base = {_load: false, _edit: false};
|
||||||
const index = state.fileLists.findIndex(({id}) => id == data.id);
|
const index = state.fileLists.findIndex(({id}) => id == data.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.fileLists.splice(index, 1, Object.assign(base, state.fileLists[index], data));
|
commit("file/splice", {index, data: Object.assign(base, state.fileLists[index], data)})
|
||||||
} else {
|
} else {
|
||||||
state.fileLists.push(Object.assign(base, data))
|
commit("file/push", Object.assign(base, data))
|
||||||
}
|
}
|
||||||
$A.IDBSave("fileLists", state.fileLists, 600)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忘记文件数据
|
* 忘记文件数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param file_id
|
* @param file_id
|
||||||
*/
|
*/
|
||||||
forgetFile({state, dispatch}, file_id) {
|
forgetFile({commit, state, dispatch}, file_id) {
|
||||||
$A.execMainDispatch("forgetFile", file_id)
|
|
||||||
//
|
|
||||||
const ids = $A.isArray(file_id) ? file_id : [file_id];
|
const ids = $A.isArray(file_id) ? file_id : [file_id];
|
||||||
ids.some(id => {
|
ids.some(id => {
|
||||||
state.fileLists = state.fileLists.filter(file => file.id != id);
|
commit("file/save", state.fileLists.filter(file => file.id != id))
|
||||||
state.fileLists.some(file => {
|
state.fileLists.some(file => {
|
||||||
if (file.pid == id) {
|
if (file.pid == id) {
|
||||||
dispatch("forgetFile", file.id);
|
dispatch("forgetFile", file.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$A.IDBSave("fileLists", state.fileLists, 600)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1274,25 +1261,23 @@ export default {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
packProgress({state, dispatch}, data) {
|
packProgress({state, dispatch}, data) {
|
||||||
$A.execMainDispatch("packProgress", data)
|
|
||||||
//
|
|
||||||
const index = state.filePackLists.findIndex(({name}) => name == data.name);
|
const index = state.filePackLists.findIndex(({name}) => name == data.name);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.filePackLists[index].progress = data.progress;
|
state.filePackLists[index].progress = data.progress;
|
||||||
} else {
|
} else {
|
||||||
state.filePackLists.push(data);
|
state.filePackLists.push(data);
|
||||||
$A.IDBSave("filePackLists", state.filePackLists, 600)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件
|
* 获取文件
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param pid
|
* @param pid
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
getFiles({state, dispatch}, pid) {
|
getFiles({commit, state, dispatch}, pid) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'file/lists',
|
url: 'file/lists',
|
||||||
@ -1301,8 +1286,7 @@ export default {
|
|||||||
},
|
},
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
const ids = result.data.map(({id}) => id)
|
const ids = result.data.map(({id}) => id)
|
||||||
state.fileLists = state.fileLists.filter((item) => item.pid != pid || ids.includes(item.id));
|
commit("file/save", state.fileLists.filter((item) => item.pid != pid || ids.includes(item.id)));
|
||||||
$A.IDBSave("fileLists", state.fileLists, 600)
|
|
||||||
//
|
//
|
||||||
dispatch("saveFile", result.data);
|
dispatch("saveFile", result.data);
|
||||||
resolve(result)
|
resolve(result)
|
||||||
@ -1344,13 +1328,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存项目数据
|
* 保存项目数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveProject({state, dispatch}, data) {
|
saveProject({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveProject", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((project) => {
|
data.forEach((project) => {
|
||||||
dispatch("saveProject", project)
|
dispatch("saveProject", project)
|
||||||
@ -1362,12 +1345,12 @@ export default {
|
|||||||
}
|
}
|
||||||
const index = state.cacheProjects.findIndex(({id}) => id == data.id);
|
const index = state.cacheProjects.findIndex(({id}) => id == data.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.cacheProjects.splice(index, 1, Object.assign({}, state.cacheProjects[index], data));
|
commit("project/splice", {index, data: Object.assign({}, state.cacheProjects[index], data)})
|
||||||
} else {
|
} else {
|
||||||
if (typeof data.project_user === "undefined") {
|
if (typeof data.project_user === "undefined") {
|
||||||
data.project_user = []
|
data.project_user = []
|
||||||
}
|
}
|
||||||
state.cacheProjects.push(data);
|
commit("project/push", data)
|
||||||
state.projectTotal++
|
state.projectTotal++
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -1382,27 +1365,24 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//
|
|
||||||
$A.IDBSave("cacheProjects", state.cacheProjects);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忘记项目数据
|
* 忘记项目数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param project_id
|
* @param project_id
|
||||||
*/
|
*/
|
||||||
forgetProject({state, dispatch}, project_id) {
|
forgetProject({commit, state, dispatch}, project_id) {
|
||||||
$A.execMainDispatch("forgetProject", project_id)
|
|
||||||
//
|
|
||||||
const ids = $A.isArray(project_id) ? project_id : [project_id];
|
const ids = $A.isArray(project_id) ? project_id : [project_id];
|
||||||
ids.some(id => {
|
ids.some(id => {
|
||||||
const index = state.cacheProjects.findIndex(project => project.id == id);
|
const index = state.cacheProjects.findIndex(project => project.id == id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
dispatch("forgetTask", state.cacheTasks.filter(item => item.project_id == project_id).map(item => item.id))
|
dispatch("forgetTask", state.cacheTasks.filter(item => item.project_id == project_id).map(item => item.id))
|
||||||
dispatch("forgetColumn", state.cacheColumns.filter(item => item.project_id == project_id).map(item => item.id))
|
dispatch("forgetColumn", state.cacheColumns.filter(item => item.project_id == project_id).map(item => item.id))
|
||||||
state.cacheProjects.splice(index, 1);
|
commit("project/splice", {index})
|
||||||
state.projectTotal = Math.max(0, state.projectTotal - 1)
|
state.projectTotal = Math.max(0, state.projectTotal - 1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -1419,8 +1399,6 @@ export default {
|
|||||||
$A.goForward({name: 'manage-dashboard'});
|
$A.goForward({name: 'manage-dashboard'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
$A.IDBSave("cacheProjects", state.cacheProjects);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1597,13 +1575,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存列表数据
|
* 保存列表数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveColumn({state, dispatch}, data) {
|
saveColumn({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveColumn", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((column) => {
|
data.forEach((column) => {
|
||||||
dispatch("saveColumn", column)
|
dispatch("saveColumn", column)
|
||||||
@ -1611,24 +1588,21 @@ export default {
|
|||||||
} else if ($A.isJson(data)) {
|
} else if ($A.isJson(data)) {
|
||||||
const index = state.cacheColumns.findIndex(({id}) => id == data.id);
|
const index = state.cacheColumns.findIndex(({id}) => id == data.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.cacheColumns.splice(index, 1, Object.assign({}, state.cacheColumns[index], data));
|
commit("project/column/splice", {index, data: Object.assign({}, state.cacheColumns[index], data)})
|
||||||
} else {
|
} else {
|
||||||
state.cacheColumns.push(data);
|
commit("project/column/push", data)
|
||||||
}
|
}
|
||||||
//
|
|
||||||
$A.IDBSave("cacheColumns", state.cacheColumns);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忘记列表数据
|
* 忘记列表数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param column_id
|
* @param column_id
|
||||||
*/
|
*/
|
||||||
forgetColumn({state, dispatch}, column_id) {
|
forgetColumn({commit, state, dispatch}, column_id) {
|
||||||
$A.execMainDispatch("forgetColumn", column_id)
|
|
||||||
//
|
|
||||||
const ids = $A.isArray(column_id) ? column_id : [column_id];
|
const ids = $A.isArray(column_id) ? column_id : [column_id];
|
||||||
const project_ids = [];
|
const project_ids = [];
|
||||||
ids.some(id => {
|
ids.some(id => {
|
||||||
@ -1636,22 +1610,21 @@ export default {
|
|||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
dispatch("forgetTask", state.cacheTasks.filter(item => item.column_id == column_id).map(item => item.id))
|
dispatch("forgetTask", state.cacheTasks.filter(item => item.column_id == column_id).map(item => item.id))
|
||||||
project_ids.push(state.cacheColumns[index].project_id)
|
project_ids.push(state.cacheColumns[index].project_id)
|
||||||
state.cacheColumns.splice(index, 1);
|
commit("project/column/splice", {index})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Array.from(new Set(project_ids)).some(id => dispatch("getProjectOne", id).catch(() => {}))
|
Array.from(new Set(project_ids)).some(id => dispatch("getProjectOne", id).catch(() => {}))
|
||||||
//
|
|
||||||
$A.IDBSave("cacheColumns", state.cacheColumns);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取列表
|
* 获取列表
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param project_id
|
* @param project_id
|
||||||
* @returns {Promise<unknown>}
|
* @returns {Promise<unknown>}
|
||||||
*/
|
*/
|
||||||
getColumns({state, dispatch}, project_id) {
|
getColumns({commit, state, dispatch}, project_id) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
if (state.userId === 0) {
|
if (state.userId === 0) {
|
||||||
state.cacheColumns = [];
|
state.cacheColumns = [];
|
||||||
@ -1668,7 +1641,7 @@ export default {
|
|||||||
state.projectLoad--;
|
state.projectLoad--;
|
||||||
//
|
//
|
||||||
const ids = data.data.map(({id}) => id)
|
const ids = data.data.map(({id}) => id)
|
||||||
state.cacheColumns = state.cacheColumns.filter((item) => item.project_id != project_id || ids.includes(item.id));
|
commit("project/column/save", state.cacheColumns.filter((item) => item.project_id != project_id || ids.includes(item.id)))
|
||||||
//
|
//
|
||||||
dispatch("saveColumn", data.data);
|
dispatch("saveColumn", data.data);
|
||||||
resolve(data.data)
|
resolve(data.data)
|
||||||
@ -1732,8 +1705,6 @@ export default {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveTask({commit, state, dispatch}, data) {
|
saveTask({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveTask", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((task) => {
|
data.forEach((task) => {
|
||||||
dispatch("saveTask", task)
|
dispatch("saveTask", task)
|
||||||
@ -1804,8 +1775,6 @@ export default {
|
|||||||
* @param task_id
|
* @param task_id
|
||||||
*/
|
*/
|
||||||
forgetTask({commit, state, dispatch}, task_id) {
|
forgetTask({commit, state, dispatch}, task_id) {
|
||||||
$A.execMainDispatch("forgetTask", task_id)
|
|
||||||
//
|
|
||||||
const ids = ($A.isArray(task_id) ? task_id : [task_id]).filter(id => id != state.taskArchiveView);
|
const ids = ($A.isArray(task_id) ? task_id : [task_id]).filter(id => id != state.taskArchiveView);
|
||||||
const parent_ids = [];
|
const parent_ids = [];
|
||||||
const project_ids = [];
|
const project_ids = [];
|
||||||
@ -1863,56 +1832,45 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 增加任务消息数量
|
* 增加任务消息数量
|
||||||
* @param state
|
* @param state
|
||||||
* @param data {id, dialog_id}
|
* @param commit
|
||||||
|
* @param dialog_id
|
||||||
*/
|
*/
|
||||||
increaseTaskMsgNum({state}, data) {
|
increaseTaskMsgNum({state, commit}, dialog_id) {
|
||||||
$A.execMainDispatch("increaseTaskMsgNum", data)
|
const index = state.cacheTasks.findIndex(item => item.dialog_id === dialog_id);
|
||||||
//
|
if (index !== -1) {
|
||||||
if ($A.execMainCacheJudge(`increaseTaskMsgNum:${data.id}`)) {
|
const data = $A.cloneJSON(state.cacheTasks[index])
|
||||||
return
|
data.msg_num++;
|
||||||
}
|
commit("task/splice", {index, data})
|
||||||
//
|
|
||||||
if (data.dialog_id) {
|
|
||||||
const task = state.cacheTasks.find(({dialog_id}) => dialog_id === data.dialog_id);
|
|
||||||
if (task) task.msg_num++;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增回复数量
|
* 新增回复数量
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param commit
|
||||||
* @param data {id, reply_id}
|
* @param reply_id
|
||||||
*/
|
*/
|
||||||
increaseMsgReplyNum({state, dispatch}, data) {
|
increaseMsgReplyNum({state, commit}, reply_id) {
|
||||||
$A.execMainDispatch("increaseMsgReplyNum", data)
|
const index = state.dialogMsgs.findIndex(m => m.id == reply_id)
|
||||||
//
|
if (index !== -1) {
|
||||||
if ($A.execMainCacheJudge(`increaseMsgReplyNum:${data.id}`)) {
|
const data = $A.cloneJSON(state.dialogMsgs[index])
|
||||||
return
|
data.reply_num--
|
||||||
}
|
commit("message/splice", {index, data})
|
||||||
//
|
|
||||||
if (data.reply_id > 0) {
|
|
||||||
const msg = state.dialogMsgs.find(({id}) => id == data.reply_id)
|
|
||||||
if (msg) msg.reply_num++;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 减少回复数量
|
* 减少回复数量
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param commit
|
||||||
* @param data {id, reply_id}
|
* @param reply_id
|
||||||
*/
|
*/
|
||||||
decrementMsgReplyNum({state, dispatch}, data) {
|
decrementMsgReplyNum({state, commit}, reply_id) {
|
||||||
$A.execMainDispatch("decrementMsgReplyNum", data)
|
const index = state.dialogMsgs.findIndex(m => m.id == reply_id)
|
||||||
//
|
if (index !== -1) {
|
||||||
if ($A.execMainCacheJudge(`decrementMsgReplyNum:${data.id}`)) {
|
const data = $A.cloneJSON(state.dialogMsgs[index])
|
||||||
return
|
data.reply_num--
|
||||||
}
|
commit("message/splice", {index, data})
|
||||||
//
|
|
||||||
if (data.reply_id > 0) {
|
|
||||||
const msg = state.dialogMsgs.find(({id}) => id == data.reply_id)
|
|
||||||
if (msg) msg.reply_num--;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2172,13 +2130,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新任务详情
|
* 更新任务详情
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveTaskContent({state, dispatch}, data) {
|
saveTaskContent({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveTaskContent", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
dispatch("saveTaskContent", item)
|
dispatch("saveTaskContent", item)
|
||||||
@ -2186,9 +2143,9 @@ export default {
|
|||||||
} else if ($A.isJson(data)) {
|
} else if ($A.isJson(data)) {
|
||||||
const index = state.taskContents.findIndex(({task_id}) => task_id == data.task_id);
|
const index = state.taskContents.findIndex(({task_id}) => task_id == data.task_id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.taskContents.splice(index, 1, Object.assign({}, state.taskContents[index], data));
|
commit("task/content/splice", {index, data: Object.assign({}, state.taskContents[index], data)})
|
||||||
} else {
|
} else {
|
||||||
state.taskContents.push(data);
|
commit("task/content/push", data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2706,8 +2663,6 @@ export default {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveDialog({commit, state, dispatch}, data) {
|
saveDialog({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveDialog", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((dialog) => {
|
data.forEach((dialog) => {
|
||||||
dispatch("saveDialog", dialog)
|
dispatch("saveDialog", dialog)
|
||||||
@ -2761,8 +2716,6 @@ export default {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
updateDialogLastMsg({state, dispatch}, data) {
|
updateDialogLastMsg({state, dispatch}, data) {
|
||||||
$A.execMainDispatch("updateDialogLastMsg", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((msg) => {
|
data.forEach((msg) => {
|
||||||
dispatch("updateDialogLastMsg", msg)
|
dispatch("updateDialogLastMsg", msg)
|
||||||
@ -2943,11 +2896,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会话待办
|
* 获取会话待办
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param dialog_id
|
* @param dialog_id
|
||||||
*/
|
*/
|
||||||
getDialogTodo({state, dispatch}, dialog_id) {
|
getDialogTodo({commit, state, dispatch}, dialog_id) {
|
||||||
dispatch("call", {
|
dispatch("call", {
|
||||||
url: 'dialog/todo',
|
url: 'dialog/todo',
|
||||||
data: {
|
data: {
|
||||||
@ -2960,7 +2914,7 @@ export default {
|
|||||||
id: dialog_id,
|
id: dialog_id,
|
||||||
todo_num: $A.arrayLength(data)
|
todo_num: $A.arrayLength(data)
|
||||||
});
|
});
|
||||||
state.dialogTodos = state.dialogTodos.filter(item => item.dialog_id != dialog_id)
|
commit("dialog/todo/save", state.dialogTodos.filter(item => item.dialog_id != dialog_id))
|
||||||
}
|
}
|
||||||
dispatch("saveDialogTodo", data)
|
dispatch("saveDialogTodo", data)
|
||||||
} else {
|
} else {
|
||||||
@ -3075,8 +3029,6 @@ export default {
|
|||||||
* @param dialog_id
|
* @param dialog_id
|
||||||
*/
|
*/
|
||||||
forgetDialog({commit, state, dispatch}, dialog_id) {
|
forgetDialog({commit, state, dispatch}, dialog_id) {
|
||||||
$A.execMainDispatch("forgetDialog", dialog_id)
|
|
||||||
//
|
|
||||||
const ids = $A.isArray(dialog_id) ? dialog_id : [dialog_id];
|
const ids = $A.isArray(dialog_id) ? dialog_id : [dialog_id];
|
||||||
ids.some(id => {
|
ids.some(id => {
|
||||||
const index = state.cacheDialogs.findIndex(dialog => dialog.id == id);
|
const index = state.cacheDialogs.findIndex(dialog => dialog.id == id);
|
||||||
@ -3098,19 +3050,17 @@ export default {
|
|||||||
* @param data {uid, dialog_id}
|
* @param data {uid, dialog_id}
|
||||||
*/
|
*/
|
||||||
saveInDialog({commit, state, dispatch}, data) {
|
saveInDialog({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveInDialog", data)
|
|
||||||
//
|
|
||||||
const index = state.dialogIns.findIndex(item => item.uid == data.uid);
|
const index = state.dialogIns.findIndex(item => item.uid == data.uid);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogIns.splice(index, 1, Object.assign({}, state.dialogIns[index], data));
|
commit("dialog/in/splice", {index, data: Object.assign({}, state.dialogIns[index], data)});
|
||||||
} else {
|
} else {
|
||||||
state.dialogIns.push(data);
|
commit("dialog/in/push", data);
|
||||||
}
|
}
|
||||||
// 会话消息总数量大于5000时只保留最近打开的50个会话
|
// 会话消息总数量大于5000时只保留最近打开的50个会话
|
||||||
const msg_max = 5000
|
const msg_max = 5000
|
||||||
const retain_num = 500
|
const retain_num = 500
|
||||||
state.dialogHistory = state.dialogHistory.filter(id => id != data.dialog_id)
|
commit('dialog/history/save', state.dialogHistory.filter(id => id != data.dialog_id))
|
||||||
state.dialogHistory.push(data.dialog_id)
|
commit('dialog/history/push', data.dialog_id)
|
||||||
if (state.dialogMsgs.length > msg_max && state.dialogHistory.length > retain_num) {
|
if (state.dialogMsgs.length > msg_max && state.dialogHistory.length > retain_num) {
|
||||||
const historys = state.dialogHistory.slice().reverse()
|
const historys = state.dialogHistory.slice().reverse()
|
||||||
const newIds = []
|
const newIds = []
|
||||||
@ -3125,22 +3075,20 @@ export default {
|
|||||||
if (delIds.length > 0) {
|
if (delIds.length > 0) {
|
||||||
commit("message/save", state.dialogMsgs.filter(item => !delIds.includes(item.dialog_id)))
|
commit("message/save", state.dialogMsgs.filter(item => !delIds.includes(item.dialog_id)))
|
||||||
}
|
}
|
||||||
state.dialogHistory = newIds
|
commit('dialog/history/save', newIds)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 忘记正在会话
|
* 忘记正在会话
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param commit
|
||||||
* @param uid
|
* @param uid
|
||||||
*/
|
*/
|
||||||
forgetInDialog({state, dispatch}, uid) {
|
forgetInDialog({state, commit}, uid) {
|
||||||
$A.execMainDispatch("forgetInDialog", uid)
|
|
||||||
//
|
|
||||||
const index = state.dialogIns.findIndex(item => item.uid == uid);
|
const index = state.dialogIns.findIndex(item => item.uid == uid);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogIns.splice(index, 1);
|
commit("dialog/in/splice", {index})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -3155,7 +3103,6 @@ export default {
|
|||||||
if (!/^\d+$/.test(dialog_id)) {
|
if (!/^\d+$/.test(dialog_id)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$A.execMainDispatch("closeDialog", dialog_id)
|
|
||||||
|
|
||||||
// 更新草稿标签
|
// 更新草稿标签
|
||||||
commit('draft/tag', dialog_id)
|
commit('draft/tag', dialog_id)
|
||||||
@ -3170,13 +3117,12 @@ export default {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存待办数据
|
* 保存待办数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveDialogTodo({state, dispatch}, data) {
|
saveDialogTodo({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveDialogTodo", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
dispatch("saveDialogTodo", item)
|
dispatch("saveDialogTodo", item)
|
||||||
@ -3184,9 +3130,9 @@ export default {
|
|||||||
} else if ($A.isJson(data)) {
|
} else if ($A.isJson(data)) {
|
||||||
const index = state.dialogTodos.findIndex(item => item.id == data.id);
|
const index = state.dialogTodos.findIndex(item => item.id == data.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogTodos.splice(index, 1, Object.assign({}, state.dialogTodos[index], data));
|
commit('dialog/todo/splice', {index, data: Object.assign({}, state.dialogTodos[index], data)});
|
||||||
} else {
|
} else {
|
||||||
state.dialogTodos.push(data);
|
commit('dialog/todo/push', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3194,38 +3140,35 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 忘记待办数据
|
* 忘记待办数据
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param commit
|
||||||
* @param msg_id
|
* @param msg_id
|
||||||
*/
|
*/
|
||||||
forgetDialogTodoForMsgId({state, dispatch}, msg_id) {
|
forgetDialogTodoForMsgId({state, commit}, msg_id) {
|
||||||
$A.execMainDispatch("forgetDialogTodoForMsgId", msg_id)
|
|
||||||
//
|
|
||||||
const index = state.dialogTodos.findIndex(item => item.msg_id == msg_id);
|
const index = state.dialogTodos.findIndex(item => item.msg_id == msg_id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogTodos.splice(index, 1);
|
commit('dialog/todo/splice', {index})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存置顶数据
|
* 保存置顶数据
|
||||||
|
* @param commit
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param dispatch
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveDialogMsgTop({state, dispatch}, data) {
|
saveDialogMsgTop({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveDialogMsgTop", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
dispatch("saveDialogMsgTop", item)
|
dispatch("saveDialogMsgTop", item)
|
||||||
});
|
});
|
||||||
} else if ($A.isJson(data)) {
|
} else if ($A.isJson(data)) {
|
||||||
state.dialogMsgTops = state.dialogMsgTops.filter(item => item.dialog_id != data.dialog_id)
|
commit('dialog/msg/top/save', state.dialogMsgTops.filter(item => item.dialog_id != data.dialog_id))
|
||||||
const index = state.dialogMsgTops.findIndex(item => item.id == data.id);
|
const index = state.dialogMsgTops.findIndex(item => item.id == data.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogMsgTops.splice(index, 1, Object.assign({}, state.dialogMsgTops[index], data));
|
commit('dialog/msg/top/splice', {index, data: Object.assign({}, state.dialogMsgTops[index], data)});
|
||||||
} else {
|
} else {
|
||||||
state.dialogMsgTops.push(data);
|
commit('dialog/msg/top/push', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3233,15 +3176,13 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 忘记消息置顶数据
|
* 忘记消息置顶数据
|
||||||
* @param state
|
* @param state
|
||||||
* @param dispatch
|
* @param commit
|
||||||
* @param msg_id
|
* @param msg_id
|
||||||
*/
|
*/
|
||||||
forgetDialogMsgTopForMsgId({state, dispatch}, msg_id) {
|
forgetDialogMsgTopForMsgId({state, commit}, msg_id) {
|
||||||
$A.execMainDispatch("forgetDialogMsgTopForMsgId", msg_id)
|
|
||||||
//
|
|
||||||
const index = state.dialogMsgTops.findIndex(item => item.msg_id == msg_id);
|
const index = state.dialogMsgTops.findIndex(item => item.msg_id == msg_id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
state.dialogMsgTops.splice(index, 1);
|
commit('dialog/msg/top/splice', {index})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -3301,48 +3242,47 @@ export default {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
saveDialogMsg({commit, state, dispatch}, data) {
|
saveDialogMsg({commit, state, dispatch}, data) {
|
||||||
$A.execMainDispatch("saveDialogMsg", data)
|
|
||||||
//
|
|
||||||
if ($A.isArray(data)) {
|
if ($A.isArray(data)) {
|
||||||
data.forEach((msg) => {
|
data.forEach((msg) => {
|
||||||
dispatch("saveDialogMsg", msg)
|
dispatch("saveDialogMsg", msg)
|
||||||
});
|
});
|
||||||
} else if ($A.isJson(data)) {
|
return
|
||||||
if (data.type == "notice") {
|
}
|
||||||
data.estimateSize = 42;
|
//
|
||||||
|
if (data.type == "notice") {
|
||||||
|
data.estimateSize = 42;
|
||||||
|
}
|
||||||
|
const index = state.dialogMsgs.findIndex(({id}) => id == data.id);
|
||||||
|
if (index > -1) {
|
||||||
|
const original = state.dialogMsgs[index]
|
||||||
|
if (original.read_at) {
|
||||||
|
delete data.read_at
|
||||||
}
|
}
|
||||||
const index = state.dialogMsgs.findIndex(({id}) => id == data.id);
|
data = Object.assign({}, original, data)
|
||||||
if (index > -1) {
|
commit("message/splice", {index, data})
|
||||||
const original = state.dialogMsgs[index]
|
} else {
|
||||||
if (original.read_at) {
|
commit("message/push", data)
|
||||||
delete data.read_at
|
}
|
||||||
|
//
|
||||||
|
const dialog = state.cacheDialogs.find(({id}) => id == data.dialog_id);
|
||||||
|
if (dialog) {
|
||||||
|
let isUpdate = false
|
||||||
|
if (!data.read_at
|
||||||
|
&& data.userid != state.userId
|
||||||
|
&& !state.dialogIns.find(({dialog_id}) => dialog_id == dialog.id)) {
|
||||||
|
if (dialog.unread_one) {
|
||||||
|
dialog.unread_one = Math.min(dialog.unread_one, data.id)
|
||||||
|
} else {
|
||||||
|
dialog.unread_one = data.id
|
||||||
}
|
}
|
||||||
data = Object.assign({}, original, data)
|
isUpdate = true
|
||||||
commit("message/splice", {index, data})
|
|
||||||
} else {
|
|
||||||
commit("message/push", data)
|
|
||||||
}
|
}
|
||||||
//
|
if (dialog.last_msg && dialog.last_msg.id == data.id) {
|
||||||
const dialog = state.cacheDialogs.find(({id}) => id == data.dialog_id);
|
dialog.last_msg = Object.assign({}, dialog.last_msg, data)
|
||||||
if (dialog) {
|
isUpdate = true
|
||||||
let isUpdate = false
|
}
|
||||||
if (!data.read_at
|
if (isUpdate) {
|
||||||
&& data.userid != state.userId
|
dispatch("saveDialog", dialog)
|
||||||
&& !state.dialogIns.find(({dialog_id}) => dialog_id == dialog.id)) {
|
|
||||||
if (dialog.unread_one) {
|
|
||||||
dialog.unread_one = Math.min(dialog.unread_one, data.id)
|
|
||||||
} else {
|
|
||||||
dialog.unread_one = data.id
|
|
||||||
}
|
|
||||||
isUpdate = true
|
|
||||||
}
|
|
||||||
if (dialog.last_msg && dialog.last_msg.id == data.id) {
|
|
||||||
dialog.last_msg = Object.assign({}, dialog.last_msg, data)
|
|
||||||
isUpdate = true
|
|
||||||
}
|
|
||||||
if (isUpdate) {
|
|
||||||
dispatch("saveDialog", dialog)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -3355,14 +3295,12 @@ export default {
|
|||||||
* @param msg_id
|
* @param msg_id
|
||||||
*/
|
*/
|
||||||
forgetDialogMsg({commit, state, dispatch}, msg_id) {
|
forgetDialogMsg({commit, state, dispatch}, msg_id) {
|
||||||
$A.execMainDispatch("forgetDialogMsg", msg_id)
|
|
||||||
//
|
|
||||||
const ids = $A.isArray(msg_id) ? msg_id : [msg_id];
|
const ids = $A.isArray(msg_id) ? msg_id : [msg_id];
|
||||||
ids.some(id => {
|
ids.some(id => {
|
||||||
const index = state.dialogMsgs.findIndex(item => item.id == id);
|
const index = state.dialogMsgs.findIndex(item => item.id == id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
const msgData = state.dialogMsgs[index]
|
const msgData = state.dialogMsgs[index]
|
||||||
dispatch("decrementMsgReplyNum", msgData);
|
dispatch("decrementMsgReplyNum", msgData.reply_id);
|
||||||
dispatch("audioStop", $A.getObject(msgData, 'msg.path'));
|
dispatch("audioStop", $A.getObject(msgData, 'msg.path'));
|
||||||
commit("message/splice", {index})
|
commit("message/splice", {index})
|
||||||
}
|
}
|
||||||
@ -3432,7 +3370,7 @@ export default {
|
|||||||
dispatch("saveDialog", resData.dialog)
|
dispatch("saveDialog", resData.dialog)
|
||||||
}
|
}
|
||||||
if ($A.isArray(resData.todo)) {
|
if ($A.isArray(resData.todo)) {
|
||||||
state.dialogTodos = state.dialogTodos.filter(item => item.dialog_id != data.dialog_id)
|
commit("dialog/todo/save", state.dialogTodos.filter(item => item.dialog_id != data.dialog_id))
|
||||||
dispatch("saveDialogTodo", resData.todo)
|
dispatch("saveDialogTodo", resData.todo)
|
||||||
}
|
}
|
||||||
if ($A.isJson(resData.top)) {
|
if ($A.isJson(resData.top)) {
|
||||||
@ -4034,9 +3972,9 @@ export default {
|
|||||||
const isChat = mode === "chat" || $A.isSubElectron;
|
const isChat = mode === "chat" || $A.isSubElectron;
|
||||||
if (!state.dialogMsgs.find(({id}) => id == data.id)) {
|
if (!state.dialogMsgs.find(({id}) => id == data.id)) {
|
||||||
// 新增任务消息数量
|
// 新增任务消息数量
|
||||||
dispatch("increaseTaskMsgNum", data);
|
dispatch("increaseTaskMsgNum", data.dialog_id);
|
||||||
// 新增回复数量
|
// 新增回复数量
|
||||||
dispatch("increaseMsgReplyNum", data);
|
dispatch("increaseMsgReplyNum", data.reply_id);
|
||||||
//
|
//
|
||||||
if (!isChat) {
|
if (!isChat) {
|
||||||
if (data.userid !== state.userId) {
|
if (data.userid !== state.userId) {
|
||||||
|
|||||||
4
resources/assets/js/store/index.js
vendored
4
resources/assets/js/store/index.js
vendored
@ -5,6 +5,7 @@ import state from './state'
|
|||||||
import getters from './getters'
|
import getters from './getters'
|
||||||
import actions from './actions'
|
import actions from './actions'
|
||||||
import mutations from './mutations'
|
import mutations from './mutations'
|
||||||
|
import plugins from './plugins'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
@ -12,5 +13,6 @@ export default new Vuex.Store({
|
|||||||
state,
|
state,
|
||||||
getters,
|
getters,
|
||||||
mutations,
|
mutations,
|
||||||
actions
|
actions,
|
||||||
|
plugins,
|
||||||
})
|
})
|
||||||
|
|||||||
139
resources/assets/js/store/mutations.js
vendored
139
resources/assets/js/store/mutations.js
vendored
@ -54,6 +54,19 @@ export default {
|
|||||||
$A.IDBSave("cacheTasks", state.cacheTasks, 600)
|
$A.IDBSave("cacheTasks", state.cacheTasks, 600)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// taskContents
|
||||||
|
'task/content/push': function(state, data) {
|
||||||
|
state.taskContents.push(data)
|
||||||
|
},
|
||||||
|
|
||||||
|
'task/content/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.taskContents.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.taskContents.splice(index, count, data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 对话管理
|
// 对话管理
|
||||||
'dialog/push': function(state, data) {
|
'dialog/push': function(state, data) {
|
||||||
state.cacheDialogs.push(data)
|
state.cacheDialogs.push(data)
|
||||||
@ -69,6 +82,132 @@ export default {
|
|||||||
$A.IDBSave("cacheDialogs", state.cacheDialogs, 600)
|
$A.IDBSave("cacheDialogs", state.cacheDialogs, 600)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// dialogIns
|
||||||
|
'dialog/in/push': function(state, data) {
|
||||||
|
state.dialogIns.push(data)
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog/in/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.dialogIns.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.dialogIns.splice(index, count, data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// dialogHistory
|
||||||
|
'dialog/history/push': function(state, data) {
|
||||||
|
state.dialogHistory.push(data)
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog/history/save': function(state, data) {
|
||||||
|
state.dialogHistory = data
|
||||||
|
},
|
||||||
|
|
||||||
|
// dialogMsgTops
|
||||||
|
'dialog/msg/top/push': function(state, data) {
|
||||||
|
state.dialogMsgTops.push(data)
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog/msg/top/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.dialogMsgTops.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.dialogMsgTops.splice(index, count, data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog/msg/top/save': function(state, data) {
|
||||||
|
state.dialogMsgTops = data
|
||||||
|
},
|
||||||
|
|
||||||
|
// dialogTodos
|
||||||
|
'dialog/todo/push': function(state, data) {
|
||||||
|
state.dialogTodos.push(data)
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog/todo/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.dialogTodos.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.dialogTodos.splice(index, count, data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'dialog/todo/save': function(state, data) {
|
||||||
|
state.dialogTodos = data
|
||||||
|
},
|
||||||
|
|
||||||
|
// 项目管理
|
||||||
|
'project/push': function(state, data) {
|
||||||
|
state.cacheProjects.push(data)
|
||||||
|
$A.IDBSave("cacheProjects", state.cacheProjects);
|
||||||
|
},
|
||||||
|
|
||||||
|
'project/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.cacheProjects.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.cacheProjects.splice(index, count, data)
|
||||||
|
}
|
||||||
|
$A.IDBSave("cacheProjects", state.cacheProjects);
|
||||||
|
},
|
||||||
|
|
||||||
|
// cacheColumns
|
||||||
|
'project/column/push': function(state, data) {
|
||||||
|
state.cacheColumns.push(data)
|
||||||
|
$A.IDBSave("cacheColumns", state.cacheColumns);
|
||||||
|
},
|
||||||
|
|
||||||
|
'project/column/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.cacheColumns.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.cacheColumns.splice(index, count, data)
|
||||||
|
}
|
||||||
|
$A.IDBSave("cacheColumns", state.cacheColumns);
|
||||||
|
},
|
||||||
|
|
||||||
|
'project/column/save': function(state, data) {
|
||||||
|
state.cacheColumns = data
|
||||||
|
$A.IDBSave("cacheColumns", state.cacheColumns);
|
||||||
|
},
|
||||||
|
|
||||||
|
// cacheProjectParameter
|
||||||
|
'project/parameter/push': function(state, data) {
|
||||||
|
state.cacheProjectParameter.push(data)
|
||||||
|
$A.IDBSave("cacheProjectParameter", state.cacheProjectParameter);
|
||||||
|
},
|
||||||
|
|
||||||
|
'project/parameter/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.cacheProjectParameter.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.cacheProjectParameter.splice(index, count, data)
|
||||||
|
}
|
||||||
|
$A.IDBSave("cacheProjectParameter", state.cacheProjectParameter);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 文件管理
|
||||||
|
'file/push': function(state, data) {
|
||||||
|
state.fileLists.push(data)
|
||||||
|
$A.IDBSave("fileLists", state.fileLists, 600)
|
||||||
|
},
|
||||||
|
|
||||||
|
'file/splice': function(state, {index, data, count = 1}) {
|
||||||
|
if (typeof data === "undefined") {
|
||||||
|
state.fileLists.splice(index, count)
|
||||||
|
} else {
|
||||||
|
state.fileLists.splice(index, count, data)
|
||||||
|
}
|
||||||
|
$A.IDBSave("fileLists", state.fileLists, 600)
|
||||||
|
},
|
||||||
|
|
||||||
|
'file/save': function(state, data) {
|
||||||
|
state.fileLists = data
|
||||||
|
$A.IDBSave("fileLists", state.fileLists, 600)
|
||||||
|
},
|
||||||
|
|
||||||
// 草稿管理
|
// 草稿管理
|
||||||
'draft/set': function(state, {id, content}) {
|
'draft/set': function(state, {id, content}) {
|
||||||
const index = state.dialogDrafts.findIndex(item => item.id === id)
|
const index = state.dialogDrafts.findIndex(item => item.id === id)
|
||||||
|
|||||||
40
resources/assets/js/store/plugins.js
vendored
Normal file
40
resources/assets/js/store/plugins.js
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* electron 同步插件
|
||||||
|
* @param store
|
||||||
|
*/
|
||||||
|
const createElectronSyncPlugin = (store) => {
|
||||||
|
const {electron} = window
|
||||||
|
|
||||||
|
if (!electron) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const sourceId = $A.randomString(6) + "_" + Date.now().toString()
|
||||||
|
|
||||||
|
let isSyncing = false
|
||||||
|
electron.registerMsgListener('syncStore', ({type, payload, sourceId: targetId}) => {
|
||||||
|
if (sourceId === targetId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isSyncing = true
|
||||||
|
try {
|
||||||
|
store.commit(type, payload)
|
||||||
|
} finally {
|
||||||
|
isSyncing = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
store.subscribe((mutation) => {
|
||||||
|
if (isSyncing) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
electron.sendMessage('syncStore', {
|
||||||
|
type: mutation.type,
|
||||||
|
payload: mutation.payload,
|
||||||
|
sourceId
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default [createElectronSyncPlugin]
|
||||||
3
resources/assets/js/store/state.js
vendored
3
resources/assets/js/store/state.js
vendored
@ -7,7 +7,7 @@ export default {
|
|||||||
clientId: "",
|
clientId: "",
|
||||||
|
|
||||||
// 缓存版本号(如果想升级后清除客户端缓存则修改此参数值)
|
// 缓存版本号(如果想升级后清除客户端缓存则修改此参数值)
|
||||||
cacheVersion: "v14",
|
cacheVersion: "v15",
|
||||||
|
|
||||||
// 窗口是否激活
|
// 窗口是否激活
|
||||||
windowActive: true,
|
windowActive: true,
|
||||||
@ -71,7 +71,6 @@ export default {
|
|||||||
touchBackInProgress: false,
|
touchBackInProgress: false,
|
||||||
|
|
||||||
// User
|
// User
|
||||||
cacheUserActive: {},
|
|
||||||
cacheUserWait: [],
|
cacheUserWait: [],
|
||||||
cacheUserBasic: [],
|
cacheUserBasic: [],
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user