chore: test Mapi-process active send message to Renderer-process.
This commit is contained in:
parent
7f6df58801
commit
c7118b75e6
|
@ -29,6 +29,11 @@ async function mainWin() {
|
||||||
win.maximize()
|
win.maximize()
|
||||||
win.webContents.openDevTools()
|
win.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test active push message to Renderer-process.
|
||||||
|
setInterval(() => {
|
||||||
|
win?.webContents.send('main-process-message', (new Date).toLocaleString())
|
||||||
|
}, 999)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(mainWin)
|
app.whenReady().then(mainWin)
|
||||||
|
|
|
@ -17,6 +17,11 @@ ReactDOM.render(
|
||||||
|
|
||||||
console.log('contextBridge ->', window.bridge)
|
console.log('contextBridge ->', window.bridge)
|
||||||
|
|
||||||
|
// Use ipcRenderer.on
|
||||||
|
window.bridge.ipcRenderer.on('main-process-message', (_event, ...args) => {
|
||||||
|
console.log('[Receive Main-process message]:', ...args)
|
||||||
|
})
|
||||||
|
|
||||||
// Use 'electron-store'
|
// Use 'electron-store'
|
||||||
const store = {
|
const store = {
|
||||||
async get(key: string) {
|
async get(key: string) {
|
||||||
|
@ -40,7 +45,6 @@ const store = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await store.set('Date.now', Date.now())
|
await store.set('Date.now', Date.now())
|
||||||
console.log('electron-store ->', 'Date.now:', await store.get('Date.now'))
|
console.log('electron-store ->', 'Date.now:', await store.get('Date.now'))
|
||||||
|
|
Loading…
Reference in New Issue