upgrade to electron v1.1.1

This commit is contained in:
life
2016-05-22 12:17:16 +08:00
parent 00800e20ba
commit 15c2f75be9
12 changed files with 29 additions and 29 deletions

15
main.js
View File

@@ -1,10 +1,15 @@
var app = require('app'); // Module to control application life. // var app = require('electron').app; // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window. const {app, BrowserWindow, crashReporter} = require('electron');
var ipc = require('ipc'); var ipc = require('electron').ipcMain;
var pdfMain = require('pdf_main'); var pdfMain = require('pdf_main');
// Report crashes to our server. // Report crashes to our server.
require('crash-reporter').start(); crashReporter.start({
productName: 'YourName',
companyName: 'YourCompany',
submitURL: 'https://your-domain.com/url-to-submit',
autoSubmit: true
});
// Keep a global reference of the window object, if you don't, the window will // Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed. // be closed automatically when the javascript object is GCed.
@@ -101,7 +106,7 @@ function openIt() {
console.log('load: file://' + __dirname + '/note.html'); console.log('load: file://' + __dirname + '/note.html');
// and load the index.html of the app. // and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/note.html'); mainWindow.loadURL('file://' + __dirname + '/note.html');
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on('closed', function() { mainWindow.on('closed', function() {

2
node_modules/db_client.js generated vendored
View File

@@ -5,7 +5,7 @@
var DatastoreProxy = require('nedb_proxy'); var DatastoreProxy = require('nedb_proxy');
var path = require('path'); var path = require('path');
var Evt = require('evt'); var Evt = require('evt');
var ipc = require('ipc'); var ipc = require('electron').ipcRenderer;
// console.log(dbPath); // console.log(dbPath);
// g, 表全局环境 // g, 表全局环境

11
node_modules/gui.js generated vendored
View File

@@ -1,13 +1,12 @@
var remote = require('remote'); const {dialog, Menu, MenuItem, app} = require('electron').remote;
var dialog = remote.require('dialog'); var remote = require('electron').remote;
var Menu = remote.require('menu');
var MenuItem = remote.require('menu-item');
// var dialog = require('dialog'); // var dialog = require('dialog');
var gui = { var gui = {
Menu: Menu, Menu: Menu,
MenuItem: MenuItem, MenuItem: MenuItem,
remote: remote, remote: remote,
app: remote.require('app'), app: app,
dialog: dialog, dialog: dialog,
getSeparatorMenu: function() { getSeparatorMenu: function() {
@@ -17,7 +16,7 @@ var gui = {
getCurrentWindow: function() { getCurrentWindow: function() {
return remote.getCurrentWindow(); return remote.getCurrentWindow();
}, },
Shell: require('shell'), Shell: require('electron').shell,
on: function(type, callback) { on: function(type, callback) {
} }

3
node_modules/leanote_protocol.js generated vendored
View File

@@ -1,6 +1,5 @@
var protocol = require('protocol'); const {app, protocol} = require('electron');
var File = require('file_main'); var File = require('file_main');
var app = require('app');
var leanoteProtocol = { var leanoteProtocol = {
destroy: function (callback) { destroy: function (callback) {

2
node_modules/nedb_proxy.js generated vendored
View File

@@ -1,4 +1,4 @@
var ipc = require('ipc'); var ipc = require('electron').ipcRenderer;
function Find(dbProxy, dbname, query) { function Find(dbProxy, dbname, query) {
this.query = query; this.query = query;

5
node_modules/pdf_main.js generated vendored
View File

@@ -1,6 +1,5 @@
var app = require('app'); const {app, BrowserWindow} = require('electron');
var BrowserWindow = require('browser-window'); var ipc = require('electron').ipcMain;
var ipc = require('ipc');
var fs = require('fs'); var fs = require('fs');
var exportPdf = { var exportPdf = {

View File

@@ -29,6 +29,6 @@ var Config = {
"name": "日本語" "name": "日本語"
} }
], ],
"lang": "en-us", "lang": "zh-cn",
"theme": "" "theme": ""
}; };

View File

@@ -17,7 +17,7 @@ var Api = {
noteService: NoteService, noteService: NoteService,
userService: UserService, userService: UserService,
dbService: db, dbService: db,
ipc: nodeRequire('ipc'), ipc: nodeRequire('electron').ipcRenderer,
// 打开本地目录 // 打开本地目录
// mac和windows下不同 // mac和windows下不同

View File

@@ -1432,7 +1432,9 @@ function initPage(initedCallback) {
gui.win.on('blur', function() { gui.win.on('blur', function() {
}); });
*/ */
var ipc = require('ipc'); // var ipc = require('ipc');
const {ipcRenderer} = require('electron');
ipc = ipcRenderer;
ipc.on('focusWindow', function(arg) { ipc.on('focusWindow', function(arg) {
$('body').removeClass('blur'); $('body').removeClass('blur');
}); });

View File

@@ -1,16 +1,14 @@
var Common = require('common'); var Common = require('common');
var Evt = require('evt'); var Evt = require('evt');
var app = require('remote').require('app'); var app = require('electron').remote.app; // .require('app');
var basePath = app.getPath('appData') + '/leanote'; // /Users/life/Library/Application Support/Leanote'; // require('nw.gui').App.dataPath; var basePath = app.getPath('appData') + '/leanote'; // /Users/life/Library/Application Support/Leanote'; // require('nw.gui').App.dataPath;
Evt.setDataBasePath(basePath); Evt.setDataBasePath(basePath);
var protocol = require('remote').require('protocol'); var protocol = require('electron').protocol; // .require('protocol');
// 数据库初始化 // 数据库初始化
var db = require('db'); var db = require('db');
// db.init(); // db.init();
db.initGlobal(); db.initGlobal();
// 所有service, 与数据库打交道 // 所有service, 与数据库打交道
var Service = { var Service = {
notebookService: require('notebook'), notebookService: require('notebook'),
@@ -20,7 +18,6 @@ var Service = {
apiService: require('api'), apiService: require('api'),
syncServie: require('sync') syncServie: require('sync')
}; };
// 全局变量 // 全局变量
var ApiService = Service.apiService; var ApiService = Service.apiService;
var UserService = Service.userService; var UserService = Service.userService;
@@ -40,6 +37,5 @@ var NodeFs = require('fs');
// route = /note/notebook // route = /note/notebook
// 过时 // 过时
Service.dispatch = function() {}; Service.dispatch = function() {};
var gui = require('gui'); var gui = require('gui');
// var remote = require('remote'); // var remote = require('remote');

View File

@@ -1,7 +1,7 @@
var Common = require('common'); var Common = require('common');
var Evt = require('evt'); var Evt = require('evt');
var app = require('remote').require('app'); var app = require('electron').app; // .require('app');
var basePath = app.getPath('appData') + '/leanote'; // /Users/life/Library/Application Support/Leanote'; // require('nw.gui').App.dataPath; var basePath = app.getPath('appData') + '/leanote'; // /Users/life/Library/Application Support/Leanote'; // require('nw.gui').App.dataPath;
Evt.setDataBasePath(basePath); Evt.setDataBasePath(basePath);

View File

@@ -445,7 +445,7 @@ function _setEditorContent(content, isMarkdown, preview, callback) {
// 复制图片 // 复制图片
// 在web端得到图片 // 在web端得到图片
var clipboard = require('clipboard'); const {clipboard} = require('electron');
function pasteImage(e) { function pasteImage(e) {
var image = clipboard.readImage(); var image = clipboard.readImage();
if(image) { if(image) {