mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +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) => {
|
||||
msg.reqId = reqId++;
|
||||
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') {
|
||||
fileChangedListeners[msg.path] = msg.listener;
|
||||
delete msg.listener;
|
||||
}
|
||||
|
||||
ipcRenderer.send('rendererReq', msg);
|
||||
},
|
||||
registerMsgListener: function (action, callback) {
|
||||
ipcRenderer.on(action, function (event, args) {
|
||||
callback(args);
|
||||
});
|
||||
},
|
||||
|
||||
sendMessage: function (action, args) {
|
||||
ipcRenderer.send(action, args);
|
||||
},
|
||||
sendAsync: function (action, args) {
|
||||
return ipcRenderer.invoke(action, args)
|
||||
},
|
||||
|
||||
listener: function (action, callback) {
|
||||
ipcRenderer.on(action, function (event, args) {
|
||||
callback(args);
|
||||
});
|
||||
},
|
||||
listenOnce: function (action, callback) {
|
||||
ipcRenderer.once(action, function (event, 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}
|
||||
*/
|
||||
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 => {
|
||||
if (window.webContents.id !== event.sender.id) {
|
||||
window.webContents.send('syncDispatch', args)
|
||||
window.webContents.send(channel, payload)
|
||||
}
|
||||
})
|
||||
event.returnValue = "ok"
|
||||
|
||||
@ -440,13 +440,13 @@ export default {
|
||||
this.$store.dispatch("openWebTabWindow", url)
|
||||
return true
|
||||
}
|
||||
this.$Electron.registerMsgListener('browserWindowBlur', _ => {
|
||||
this.$Electron.listener('browserWindowBlur', _ => {
|
||||
this.$store.state.windowActive = false;
|
||||
})
|
||||
this.$Electron.registerMsgListener('browserWindowFocus', _ => {
|
||||
this.$Electron.listener('browserWindowFocus', _ => {
|
||||
this.$store.state.windowActive = true;
|
||||
})
|
||||
this.$Electron.registerMsgListener('systemThemeChanged', _ => {
|
||||
this.$Electron.listener('systemThemeChanged', _ => {
|
||||
this.autoTheme()
|
||||
})
|
||||
$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__;
|
||||
return false
|
||||
}
|
||||
$A.Electron?.sendMessage('syncDispatch', {
|
||||
dispatchId,
|
||||
action,
|
||||
data,
|
||||
$A.Electron?.sendMessage('broadcastCommand', {
|
||||
channel: 'syncDispatch',
|
||||
payload: {
|
||||
dispatchId,
|
||||
action,
|
||||
data,
|
||||
}
|
||||
});
|
||||
return true
|
||||
};
|
||||
$A.Electron?.registerMsgListener('syncDispatch', async ({dispatchId: targetId, action, data}) => {
|
||||
$A.Electron?.listener('syncDispatch', async ({dispatchId: targetId, action, data}) => {
|
||||
if (dispatchId === targetId) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ export default {
|
||||
//
|
||||
if (this.$Electron) {
|
||||
emitter.on('updateNotification', this.onUpdateShow);
|
||||
this.$Electron.registerMsgListener('updateDownloaded', info => {
|
||||
this.$Electron.listener('updateDownloaded', info => {
|
||||
this.$store.state.clientNewVersion = info.version
|
||||
this.updateVersion = info.version;
|
||||
this.updateNote = info.releaseNotes || this.$L('没有更新描述。');
|
||||
|
||||
@ -1208,12 +1208,12 @@ export default {
|
||||
}
|
||||
//
|
||||
if (this.$Electron) {
|
||||
this.$Electron.registerMsgListener('clickNotification', target => {
|
||||
this.$Electron.listener('clickNotification', target => {
|
||||
console.log("[Notification] B Click", target);
|
||||
this.$Electron.sendMessage('mainWindowActive')
|
||||
this.notificationClick(target)
|
||||
})
|
||||
this.$Electron.registerMsgListener('replyNotification', target => {
|
||||
this.$Electron.listener('replyNotification', target => {
|
||||
console.log("[Notification] B Reply", target);
|
||||
this.notificationReply(target)
|
||||
})
|
||||
|
||||
@ -35,12 +35,12 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
saveSuccess(data) {
|
||||
this.detail = data;
|
||||
saveSuccess(payload) {
|
||||
this.detail = payload;
|
||||
if (this.$isSubElectron) {
|
||||
$A.Electron.sendMessage('sendForwardMain', {
|
||||
$A.Electron.sendMessage('broadcastCommand', {
|
||||
channel: 'reportSaveSuccess',
|
||||
data,
|
||||
payload,
|
||||
});
|
||||
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,
|
||||
getters,
|
||||
mutations,
|
||||
actions,
|
||||
actions
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user