mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 19:52:10 +08:00
优化代码
This commit is contained in:
@@ -19,24 +19,22 @@ const call = (ipc, channel, param) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送异步消息(invoke/handle 模型)
|
* 发送异步消息(invoke/handle 模型)
|
||||||
* @param ipc
|
|
||||||
* @param channel
|
* @param channel
|
||||||
* @param param
|
* @param param
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
const invoke = (ipc, channel, param) => {
|
const invoke = (channel, param) => {
|
||||||
const message = ipc.invoke(channel, param);
|
const message = ipc.invoke(channel, param);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送同步消息(send/on 模型)
|
* 发送同步消息(send/on 模型)
|
||||||
* @param ipc
|
|
||||||
* @param channel
|
* @param channel
|
||||||
* @param param
|
* @param param
|
||||||
* @returns {Any}
|
* @returns {Any}
|
||||||
*/
|
*/
|
||||||
const sendSync = (ipc, channel, param) => {
|
const sendSync = (channel, param) => {
|
||||||
const message = ipc.sendSync(channel, param);
|
const message = ipc.sendSync(channel, param);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@@ -45,7 +43,7 @@ export default {
|
|||||||
install(Vue) {
|
install(Vue) {
|
||||||
Vue.prototype.$ipc = ipc // 全局注入ipc
|
Vue.prototype.$ipc = ipc // 全局注入ipc
|
||||||
Vue.prototype.$ipcCall = (channel, param) => call(ipc, channel, param)
|
Vue.prototype.$ipcCall = (channel, param) => call(ipc, channel, param)
|
||||||
Vue.prototype.$ipcInvoke = (channel, param) => invoke(ipc, channel, param)
|
Vue.prototype.$ipcInvoke = invoke
|
||||||
Vue.prototype.$ipcSendSync = (channel, param) => sendSync(ipc, channel, param)
|
Vue.prototype.$ipcSendSync = sendSync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user