From faa9f8b308c288f6a8679238ea4d2d765c9d47d7 Mon Sep 17 00:00:00 2001 From: life Date: Sun, 22 May 2016 15:15:27 +0800 Subject: [PATCH] ipc new api, loadURL, image.toDataURL --- node_modules/nedb_proxy.js | 2 +- node_modules/pdf_main.js | 6 +++--- public/js/app/page.js | 12 ++++++------ public/js/common.js | 12 ++++++------ public/plugins/export_pdf/plugin.js | 3 ++- public/tinymce/plugins/paste/plugin.js | 4 +++- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/node_modules/nedb_proxy.js b/node_modules/nedb_proxy.js index d54b1451..2733ad57 100644 --- a/node_modules/nedb_proxy.js +++ b/node_modules/nedb_proxy.js @@ -81,7 +81,7 @@ DBProxy.prototype.remove = function (params, callback) { }; // m = {token: , err : , ret: } -ipc.on('db-exec-ret', function(m) { +ipc.on('db-exec-ret', function(event, m) { var token = m.token; var callback = token2Callback[token]; // console.log('clent 接收到消息'); diff --git a/node_modules/pdf_main.js b/node_modules/pdf_main.js index 6eaa9bd8..f24d4087 100644 --- a/node_modules/pdf_main.js +++ b/node_modules/pdf_main.js @@ -10,12 +10,12 @@ var exportPdf = { }); // 写入html, 然后加载这个html - win.loadUrl('file://' + htmlPath); + win.loadURL('file://' + htmlPath); win.webContents.on('did-finish-load', function() { console.log('load ok'); setTimeout(function() { - win.printToPDF({ + win.webContents.printToPDF({ printBackground: true, landscape: false, pageSize: 'A4' @@ -45,7 +45,7 @@ var exportPdf = { ipc.on('export-pdf', function(event, args) { // event.sender.send(); - console.log(args); + // console.log(args); me.export(args.htmlPath, args.targetPdfPath, args.isMarkdown, function (ok) { // console.log('导出pdf'); diff --git a/public/js/app/page.js b/public/js/app/page.js index 7ad14e32..23c68c59 100644 --- a/public/js/app/page.js +++ b/public/js/app/page.js @@ -1435,15 +1435,15 @@ function initPage(initedCallback) { // var ipc = require('ipc'); const {ipcRenderer} = require('electron'); ipc = ipcRenderer; - ipc.on('focusWindow', function(arg) { + ipc.on('focusWindow', function(event, arg) { $('body').removeClass('blur'); }); - ipc.on('blurWindow', function(arg) { + ipc.on('blurWindow', function(event, arg) { $('body').addClass('blur'); }); // 后端发来event, 告诉要关闭了, 处理好后发送给后端说可以关闭了 - ipc.on('closeWindow', function(arg) { + ipc.on('closeWindow', function(event, arg) { console.log('Front get closeWindow message') onClose(function() { ipc.sendSync('quit-app'); @@ -1800,8 +1800,8 @@ var Pren = { me.preOrNext(); } - // windows下需要 - if(e.ctrlKey || e.metaKey) { + // linux,windows下需要 + if(!isMac() && e.ctrlKey) { // p if(keyCode == 80) { me.togglePren(); @@ -1958,7 +1958,7 @@ function setMacTopMenu() { accelerator: isMac_ ? 'Command+R' : 'Ctrl+R', click: function() { onClose(function() { - gui.win.reloadIgnoringCache(); + gui.win.reload(); }); } }, diff --git a/public/js/common.js b/public/js/common.js index 61320ed1..dd1da7ab 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -449,7 +449,7 @@ const {clipboard} = require('electron'); function pasteImage(e) { var image = clipboard.readImage(); if(image) { - var dataUrl = image.toDataUrl(); + var dataUrl = image.toDataURL(); // 空图片 if(dataUrl == "data:image/png;base64,") { return; @@ -1499,19 +1499,19 @@ var ContextTips = { }; function goToMainPage() { - var BrowserWindow = gui.remote.require('browser-window'); + var BrowserWindow = gui.remote.BrowserWindow; var win = new BrowserWindow(getMainWinParams()); - win.loadUrl('file://' + __dirname + '/note.html?from=login'); + win.loadURL('file://' + __dirname + '/note.html?from=login'); } function toLogin() { - var BrowserWindow = gui.remote.require('browser-window'); + var BrowserWindow = gui.remote.BrowserWindow; if(isMac()) { var win = new BrowserWindow({ width: 278, height: 326, show: true, frame: false, resizable: false }); - win.loadUrl('file://' + __dirname + '/login.html'); + win.loadURL('file://' + __dirname + '/login.html'); } else { var win = new BrowserWindow({ width: 278, height: 400, show: true, frame: true, resizable: false }); - win.loadUrl('file://' + __dirname + '/login.html'); + win.loadURL('file://' + __dirname + '/login.html'); } gui.getCurrentWindow().close(); } diff --git a/public/plugins/export_pdf/plugin.js b/public/plugins/export_pdf/plugin.js index 403eb60f..b0d78df3 100644 --- a/public/plugins/export_pdf/plugin.js +++ b/public/plugins/export_pdf/plugin.js @@ -48,7 +48,8 @@ define(function() { _exportPdfCallback: {}, _initExportPdf: function () { var me = this; - Api.ipc.on('export-pdf-ret', function(arg) { + // console.log('_initExportPdf'); + Api.ipc.on('export-pdf-ret', function(event, arg) { var seq = arg.seq; // console.log('export-pdf-ret'); // console.log(arg); diff --git a/public/tinymce/plugins/paste/plugin.js b/public/tinymce/plugins/paste/plugin.js index 7c5a12fd..4a358cc8 100644 --- a/public/tinymce/plugins/paste/plugin.js +++ b/public/tinymce/plugins/paste/plugin.js @@ -602,7 +602,9 @@ define("tinymce/pasteplugin/Clipboard", [ return; } */ - } catch(e) {}; + } catch(e) { + console.error(e); + }; });