fix: 桌面端已知bug

This commit is contained in:
kuaifan 2023-02-26 10:10:28 +08:00
parent 23cf984123
commit 50b0542e28
5 changed files with 24 additions and 14 deletions

View File

@ -6,6 +6,7 @@ const {
let reqId = 1; let reqId = 1;
let reqInfo = {}; let reqInfo = {};
let fileChangedListeners = {}; let fileChangedListeners = {};
let onlyChangedListeners = {};
ipcRenderer.on('mainResp', (event, resp) => { ipcRenderer.on('mainResp', (event, resp) => {
let callbacks = reqInfo[resp.reqId]; let callbacks = reqInfo[resp.reqId];
@ -50,14 +51,21 @@ contextBridge.exposeInMainWorld(
sendMessage: function (action, args) { sendMessage: function (action, args) {
ipcRenderer.send(action, args); ipcRenderer.send(action, args);
}, },
sendSyncMessage: function (action, args) {
ipcRenderer.sendSync(action, args)
},
listenOnce: function (action, callback) { listenOnce: function (action, callback) {
ipcRenderer.once(action, function (event, args) { ipcRenderer.once(action, function (event, args) {
callback(args); callback(args);
}); });
},
listenerOnly: function (action, callback) {
if (typeof onlyChangedListeners[action] === "function") {
ipcRenderer.removeListener(action, onlyChangedListeners[action])
delete onlyChangedListeners[action]
} }
onlyChangedListeners[action] = (event, args) => {
callback(args)
}
ipcRenderer.on(action, onlyChangedListeners[action])
},
} }
); );

View File

@ -26,13 +26,13 @@
"url": "https://github.com/kuaifan/dootask.git" "url": "https://github.com/kuaifan/dootask.git"
}, },
"devDependencies": { "devDependencies": {
"@electron-forge/cli": "^6.0.4", "@electron-forge/cli": "^6.0.5",
"@electron-forge/maker-deb": "^6.0.4", "@electron-forge/maker-deb": "^6.0.5",
"@electron-forge/maker-rpm": "^6.0.4", "@electron-forge/maker-rpm": "^6.0.5",
"@electron-forge/maker-squirrel": "^6.0.4", "@electron-forge/maker-squirrel": "^6.0.5",
"@electron-forge/maker-zip": "^6.0.4", "@electron-forge/maker-zip": "^6.0.5",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"electron": "^23.0.0", "electron": "^23.1.1",
"electron-builder": "^23.6.0", "electron-builder": "^23.6.0",
"electron-notarize": "^1.2.2", "electron-notarize": "^1.2.2",
"form-data": "^4.0.0", "form-data": "^4.0.0",

View File

@ -60,8 +60,7 @@ export default {
this.reportTabs = this.reportType; this.reportTabs = this.reportType;
// //
if (this.$isMainElectron) { if (this.$isMainElectron) {
this.$Electron.removeMsgListener('reportSaveSuccess') this.$Electron.listenerOnly('reportSaveSuccess', ({data, msg}) => {
this.$Electron.registerMsgListener('reportSaveSuccess', ({data, msg}) => {
$A.messageSuccess(msg) $A.messageSuccess(msg)
this.saveSuccess(data) this.saveSuccess(data)
}) })

View File

@ -1429,7 +1429,7 @@ export default {
resizeDialog() { resizeDialog() {
return new Promise(resolve => { return new Promise(resolve => {
this.$Electron.sendSyncMessage('windowSize', { this.$Electron.sendMessage('windowSize', {
width: Math.max(1100, this.windowWidth), width: Math.max(1100, this.windowWidth),
height: Math.max(720, this.windowHeight), height: Math.max(720, this.windowHeight),
minWidth: 800, minWidth: 800,

View File

@ -636,6 +636,9 @@ export default {
state.cacheProjects = []; state.cacheProjects = [];
state.cacheColumns = []; state.cacheColumns = [];
state.cacheTasks = []; state.cacheTasks = [];
state.dialogUpdatedAt = null;
state.dialogDeletedAt = null;
state.projectDeletedAt = null;
// localStorage // localStorage
const languageType = window.localStorage.getItem("__language:type__"); const languageType = window.localStorage.getItem("__language:type__");
@ -2563,7 +2566,7 @@ export default {
const resData = result.data; const resData = result.data;
if ($A.isJson(resData.dialog)) { if ($A.isJson(resData.dialog)) {
const dialogData = Object.assign(resData.dialog, {user_ms: $A.TimeM(resData.dialog.user_at)}) const dialogData = Object.assign(resData.dialog, {user_ms: $A.TimeM(resData.dialog.user_at)})
setTimeout(_ => dispatch("saveDialog", dialogData), 300) // 延迟更新对话详情是因为等消息处理完 setTimeout(_ => dispatch("saveDialog", dialogData), 600) // 延迟更新对话详情是因为等消息处理完
// //
const ids = resData.list.map(({id}) => id) const ids = resData.list.map(({id}) => id)
state.dialogMsgs = state.dialogMsgs.filter(item => { state.dialogMsgs = state.dialogMsgs.filter(item => {