Skip to content

Commit

Permalink
fix: 修复 IPC 初始化失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyaser authored and Nyaser committed Nov 27, 2024
1 parent 6cc8abd commit a6db61d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ const createWindow = () => {

// 设置
function settings() {
// 应用设置
webContents.send('apply-settings')

new Notification({
title: app.getName(),
body: '功能开发中,敬请期待!',
}).show()

// 应用设置
webContents.send('apply-settings')
}

// 退出
Expand All @@ -77,6 +77,10 @@ const createWindow = () => {
label: '控制台',
click: devTools,
},
// {
// label: '一言',
// click: webContents.send.bind(null, 'hitokoto-change')
// },
{
label: '设置',
click: settings,
Expand Down
3 changes: 2 additions & 1 deletion preload.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ const { contextBridge, ipcRenderer } = require('electron');

contextBridge.exposeInMainWorld('electronAPI', {
getSettings: () => ipcRenderer.invoke('get-settings'),
applySettings: (callback) => ipcRenderer.on('apply-settings', (_event, arg) => callback(arg)),
applySettings: (callback) => ipcRenderer.on('apply-settings', (_event, _arg) => callback()),
// hitokotoChange: (callback) => ipcRenderer.on('hitokoto-change', (_event, _arg) => callback()),
});
2 changes: 2 additions & 0 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ window.onload = function () {
}

api.applySettings(ec.getAndApplySettings)

// api.hitokotoChange(ec.plugin.hitokoto.change.bind(ec.plugin.hitokoto))
}

0 comments on commit a6db61d

Please sign in to comment.