|
@@ -6,12 +6,12 @@ const { ipcRenderer: ipc } = window.require && window.require('electron') || {}
|
|
|
* @param param
|
|
* @param param
|
|
|
* @returns {Promise<unknown>}
|
|
* @returns {Promise<unknown>}
|
|
|
*/
|
|
*/
|
|
|
-const callMain = (ipc, channel, param) => {
|
|
|
|
|
|
|
+const call = (ipc, channel, param) => {
|
|
|
return new Promise((resolve) => {
|
|
return new Promise((resolve) => {
|
|
|
// 声明渲染进程函数, 用于主进程函数回调, 返回数据
|
|
// 声明渲染进程函数, 用于主进程函数回调, 返回数据
|
|
|
// 调用主进程函数
|
|
// 调用主进程函数
|
|
|
ipc.once(channel, (event, result) => {
|
|
ipc.once(channel, (event, result) => {
|
|
|
- console.log('[ipcRenderer] [callMain] result:', result)
|
|
|
|
|
|
|
+ console.log('[ipcRenderer] [call] result:', result)
|
|
|
resolve(result)
|
|
resolve(result)
|
|
|
})
|
|
})
|
|
|
ipc.send(channel, param)
|
|
ipc.send(channel, param)
|
|
@@ -21,6 +21,6 @@ const callMain = (ipc, channel, param) => {
|
|
|
export default {
|
|
export default {
|
|
|
install(Vue) {
|
|
install(Vue) {
|
|
|
Vue.prototype.$ipc = ipc // 全局注入ipc
|
|
Vue.prototype.$ipc = ipc // 全局注入ipc
|
|
|
- Vue.prototype.$ipcCallMain = (channel, param) => callMain(ipc, channel, param) // 全局注入调用主进程函数的方法
|
|
|
|
|
|
|
+ Vue.prototype.$ipcCall = (channel, param) => call(ipc, channel, param) // 全局注入调用主进程函数的方法
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|