内容纲要

用来从 Render 进程发送消息到 Main 进程。

export const messageBus = new Vue({
  methods: {
    newContentToRender(newContent) {
      ipcRenderer.send('newContentToRender', newContent);
    },
    saveCurrentFile() {  }
  }
});

ipcRenderer.on('newContentToPreview', (event, url2preview) => {
  console.log(`ipcRenderer.on newContentToPreview ${util.inspect(event)} ${url2preview}`);
  messageBus.$emit('newContentToPreview', url2preview);
});

ipcRenderer.on('newFile2Edit', (event) => {
  console.log(`ipcRenderer.on newFile2Edit ${util.inspect(event)}`);
  messageBus.$emit('newFile2Edit');
});

ipcRenderer.on('editorDoUndo', (event) => {
  console.log(`ipcRenderer.on editorDoUndo ${util.inspect(event)}`);
  messageBus.$emit('editorDoUndo');
});

ipcRenderer.on('editorDoRedo', (event) => {
  console.log(`ipcRenderer.on editorDoRedo ${util.inspect(event)}`);
  messageBus.$emit('editorDoRedo');
});

ipcRenderer.on('editorSelectAll', (event) => {
  console.log(`ipcRenderer.on editorSelectAll ${util.inspect(event)}`);
  messageBus.$emit('editorSelectAll');
});

ipcRenderer.on('openNewFile', (event, file2open) => {
  console.log(`ipcRenderer.on openNewFile  ${util.inspect(file2open)}`);
  messageBus.$emit('openNewFile', file2open);
});

ipcRenderer.on('saveCurrentFile', (event) => {
  console.log(`ipcRenderer.on saveCurrentFile ${util.inspect(event)}`);
  messageBus.$emit('saveCurrentFile');
});

参考

发表评论

电子邮件地址不会被公开。 必填项已用*标注