mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
perf: 优化数据
This commit is contained in:
parent
8bbe9c97e9
commit
8d24be914d
16
electron/electron-preload.js
vendored
16
electron/electron-preload.js
vendored
@ -33,27 +33,25 @@ contextBridge.exposeInMainWorld(
|
|||||||
request: (msg, callback, error) => {
|
request: (msg, callback, error) => {
|
||||||
msg.reqId = reqId++;
|
msg.reqId = reqId++;
|
||||||
reqInfo[msg.reqId] = {callback: callback, error: error};
|
reqInfo[msg.reqId] = {callback: callback, error: error};
|
||||||
|
|
||||||
//TODO Maybe a special function for this better than this hack?
|
|
||||||
//File watch special case where the callback is called multiple times
|
|
||||||
if (msg.action == 'watchFile') {
|
if (msg.action == 'watchFile') {
|
||||||
fileChangedListeners[msg.path] = msg.listener;
|
fileChangedListeners[msg.path] = msg.listener;
|
||||||
delete msg.listener;
|
delete msg.listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcRenderer.send('rendererReq', msg);
|
ipcRenderer.send('rendererReq', msg);
|
||||||
},
|
},
|
||||||
registerMsgListener: function (action, callback) {
|
|
||||||
ipcRenderer.on(action, function (event, args) {
|
|
||||||
callback(args);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
sendMessage: function (action, args) {
|
sendMessage: function (action, args) {
|
||||||
ipcRenderer.send(action, args);
|
ipcRenderer.send(action, args);
|
||||||
},
|
},
|
||||||
sendAsync: function (action, args) {
|
sendAsync: function (action, args) {
|
||||||
return ipcRenderer.invoke(action, args)
|
return ipcRenderer.invoke(action, args)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
listener: function (action, callback) {
|
||||||
|
ipcRenderer.on(action, function (event, args) {
|
||||||
|
callback(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);
|
||||||
|
|||||||
19
electron/electron.js
vendored
19
electron/electron.js
vendored
@ -1261,24 +1261,15 @@ ipcMain.on('windowMax', (event) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 给主窗口发送信息
|
* 给所有窗口广播指令(除了本身)
|
||||||
* @param args {channel, data}
|
|
||||||
*/
|
|
||||||
ipcMain.on('sendForwardMain', (event, args) => {
|
|
||||||
if (mainWindow) {
|
|
||||||
mainWindow.webContents.send(args.channel, args.data)
|
|
||||||
}
|
|
||||||
event.returnValue = "ok"
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 窗口同步执行派遣
|
|
||||||
* @param args {type, payload}
|
* @param args {type, payload}
|
||||||
*/
|
*/
|
||||||
ipcMain.on('syncDispatch', (event, args) => {
|
ipcMain.on('broadcastCommand', (event, args) => {
|
||||||
|
const channel = args.channel || args.command
|
||||||
|
const payload = args.payload || args.data
|
||||||
BrowserWindow.getAllWindows().forEach(window => {
|
BrowserWindow.getAllWindows().forEach(window => {
|
||||||
if (window.webContents.id !== event.sender.id) {
|
if (window.webContents.id !== event.sender.id) {
|
||||||
window.webContents.send('syncDispatch', args)
|
window.webContents.send(channel, payload)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
event.returnValue = "ok"
|
event.returnValue = "ok"
|
||||||
|
|||||||
@ -440,13 +440,13 @@ export default {
|
|||||||
this.$store.dispatch("openWebTabWindow", url)
|
this.$store.dispatch("openWebTabWindow", url)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
this.$Electron.registerMsgListener('browserWindowBlur', _ => {
|
this.$Electron.listener('browserWindowBlur', _ => {
|
||||||
this.$store.state.windowActive = false;
|
this.$store.state.windowActive = false;
|
||||||
})
|
})
|
||||||
this.$Electron.registerMsgListener('browserWindowFocus', _ => {
|
this.$Electron.listener('browserWindowFocus', _ => {
|
||||||
this.$store.state.windowActive = true;
|
this.$store.state.windowActive = true;
|
||||||
})
|
})
|
||||||
this.$Electron.registerMsgListener('systemThemeChanged', _ => {
|
this.$Electron.listener('systemThemeChanged', _ => {
|
||||||
this.autoTheme()
|
this.autoTheme()
|
||||||
})
|
})
|
||||||
$A.bindScreenshotKey(this.$store.state.cacheKeyboard);
|
$A.bindScreenshotKey(this.$store.state.cacheKeyboard);
|
||||||
|
|||||||
13
resources/assets/js/app.js
vendored
13
resources/assets/js/app.js
vendored
@ -217,14 +217,17 @@ $A.syncDispatch = (action, data) => {
|
|||||||
delete data.__sync__;
|
delete data.__sync__;
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
$A.Electron?.sendMessage('syncDispatch', {
|
$A.Electron?.sendMessage('broadcastCommand', {
|
||||||
dispatchId,
|
channel: 'syncDispatch',
|
||||||
action,
|
payload: {
|
||||||
data,
|
dispatchId,
|
||||||
|
action,
|
||||||
|
data,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true
|
return true
|
||||||
};
|
};
|
||||||
$A.Electron?.registerMsgListener('syncDispatch', async ({dispatchId: targetId, action, data}) => {
|
$A.Electron?.listener('syncDispatch', async ({dispatchId: targetId, action, data}) => {
|
||||||
if (dispatchId === targetId) {
|
if (dispatchId === targetId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export default {
|
|||||||
//
|
//
|
||||||
if (this.$Electron) {
|
if (this.$Electron) {
|
||||||
emitter.on('updateNotification', this.onUpdateShow);
|
emitter.on('updateNotification', this.onUpdateShow);
|
||||||
this.$Electron.registerMsgListener('updateDownloaded', info => {
|
this.$Electron.listener('updateDownloaded', info => {
|
||||||
this.$store.state.clientNewVersion = info.version
|
this.$store.state.clientNewVersion = info.version
|
||||||
this.updateVersion = info.version;
|
this.updateVersion = info.version;
|
||||||
this.updateNote = info.releaseNotes || this.$L('没有更新描述。');
|
this.updateNote = info.releaseNotes || this.$L('没有更新描述。');
|
||||||
|
|||||||
@ -1208,12 +1208,12 @@ export default {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (this.$Electron) {
|
if (this.$Electron) {
|
||||||
this.$Electron.registerMsgListener('clickNotification', target => {
|
this.$Electron.listener('clickNotification', target => {
|
||||||
console.log("[Notification] B Click", target);
|
console.log("[Notification] B Click", target);
|
||||||
this.$Electron.sendMessage('mainWindowActive')
|
this.$Electron.sendMessage('mainWindowActive')
|
||||||
this.notificationClick(target)
|
this.notificationClick(target)
|
||||||
})
|
})
|
||||||
this.$Electron.registerMsgListener('replyNotification', target => {
|
this.$Electron.listener('replyNotification', target => {
|
||||||
console.log("[Notification] B Reply", target);
|
console.log("[Notification] B Reply", target);
|
||||||
this.notificationReply(target)
|
this.notificationReply(target)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -35,12 +35,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
saveSuccess(data) {
|
saveSuccess(payload) {
|
||||||
this.detail = data;
|
this.detail = payload;
|
||||||
if (this.$isSubElectron) {
|
if (this.$isSubElectron) {
|
||||||
$A.Electron.sendMessage('sendForwardMain', {
|
$A.Electron.sendMessage('broadcastCommand', {
|
||||||
channel: 'reportSaveSuccess',
|
channel: 'reportSaveSuccess',
|
||||||
data,
|
payload,
|
||||||
});
|
});
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|||||||
2
resources/assets/js/store/index.js
vendored
2
resources/assets/js/store/index.js
vendored
@ -12,5 +12,5 @@ export default new Vuex.Store({
|
|||||||
state,
|
state,
|
||||||
getters,
|
getters,
|
||||||
mutations,
|
mutations,
|
||||||
actions,
|
actions
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user