Skip to content

Commit

Permalink
[by Mrzyxing] feat: import/export leanote notebook structure leanote…
Browse files Browse the repository at this point in the history
  • Loading branch information
dlgcy committed Sep 21, 2023
1 parent 5d551b7 commit 4bd6a3f
Show file tree
Hide file tree
Showing 238 changed files with 10,838 additions and 1,971 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ node_modules/fs.extra

/public/themes/**/*.css
/public/css/**/*.css
/dev/node_modules
/dev/node_modules

node_modules
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ Please see http://app.leanote.com

## How to develop it

### 1. Install Electron
### 1. Install Electron v12.0.2

See https://github.com/atom/electron#downloads
See https://github.com/electron/electron/releases/tag/v12.0.2


### 2. Run it with electron

Download this project, and run

```shell
# 1. use gulp to parse less
# 1. install dependencies
$> cd PATH-TO-LEANOTE-DESKTOP-APP
$> npm i

# 2. use gulp to parse less
$> cd PATH-TO-LEANOTE-DESKTOP-APP/dev
$> npm install
$> npm i
$> gulp dev

# 2. run with electron
# 3. run with electron
$> cd PATH-TO-LEANOTE-DESKTOP-APP
$> electron .
```
Expand Down
2 changes: 1 addition & 1 deletion data/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"2.6.2","updatedTime":"2018-12-03T07:21:51.505Z"}
{"version":"2.7.0","updatedTime":"2020-03-28T07:21:51.505Z"}
10 changes: 10 additions & 0 deletions docs/version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
官方的electron是1.1.1版本。
其他文件不做更新的话,可以使用到1.3.15版本的electron。
修正ace版本至1.2.6以上,解决了ace的markdown中文输入bug,可以使用至3.1.8版本的electron。
修改main.js,解决了app.makeSingleInstance这个electron api问题,可以使用至最新4.1.4版本的electron。



/Users/life/app/electron-v4.1.4-darwin-x64/Electron.app/Contents/MacOS/Electron .
/Users/life/app/electron-v9.0.0-darwin-x64/Electron.app/Contents/MacOS/Electron .
/Users/life/app/electron-v12.0.2-darwin-x64/Electron.app/Contents/MacOS/Electron .
9 changes: 6 additions & 3 deletions login.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ <h1 id="logo">

</div>

<script src="public/config.js"></script>
<script src="public/js/jquery-1.9.0.min.js"></script>
<script src="public/js/app/service_login.js"></script>
<script src="public/js/lang.js"></script>
<script src="public/js/bootstrap.js"></script>

<script src="public/config.js"></script>
<script src="src/browser/service_login.js"></script>
<script src="public/js/lang.js"></script>
<script>
function getMsg(key) {
return langData[key] || key;
Expand All @@ -120,6 +121,8 @@ <h1 id="logo">

<script>
$(function() {
// 不要显示顶部菜单
gui.Menu.setApplicationMenu(null)

$('.tool-close-blur').click(function() {
gui.getCurrentWindow().close();
Expand Down
91 changes: 66 additions & 25 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
// var app = require('electron').app; // Module to control application life.
const {app, BrowserWindow, crashReporter} = require('electron');
var ipc = require('electron').ipcMain;
const electron = require('electron');
const Menu = electron.Menu
const Tray = electron.Tray
var pdfMain = require('pdf_main');
const {app, BrowserWindow, crashReporter, Tray, Menu, ipcMain: ipc} = require('electron');
var pdfMain = require('./src/pdf_main');
var appIcon;

// Report crashes to our server.
crashReporter.start({
productName: 'YourName',
companyName: 'YourCompany',
submitURL: 'https://your-domain.com/url-to-submit',
productName: 'Leanote',
companyName: 'Leanote',
submitURL: 'https://leanote.com/leanote-desktop/crash-reporter',
autoSubmit: true
});

require('@electron/remote/main').initialize()

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

// single instance
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
mainWindow.show();
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.focus();
if (!app.makeSingleInstance) {
app.allowRendererProcessReuse = true

// single instance
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
console.log("gotTheLock is false, another instance is running")
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
if (mainWindow) {
mainWindow.show();
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.focus();
}
})
}
})
}
else {
// single instance
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
mainWindow.show();
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.focus();
}
})

if (shouldQuit) {
app.quit()
if (shouldQuit) {
app.quit()
}
}

// Quit when all windows are closed.
Expand Down Expand Up @@ -74,7 +93,7 @@ app.on('activate', function() {
var DB = {
init: function () {
var me = this;
var db = require('db_main');
var db = require('./src/db_main');

// 前端发来消息
// m = {token: token, method: 'insert, findOne', dbname: 'notes', params: {username: "life"}};
Expand Down Expand Up @@ -173,15 +192,21 @@ function openIt() {
DB.init();

// 协议
var leanoteProtocol = require('leanote_protocol');
var leanoteProtocol = require('./src/leanote_protocol');
leanoteProtocol.init();

// Create the browser window.
mainWindow = new BrowserWindow({
width: 1050,
height: 595,
frame: process.platform != 'darwin',
transparent: false
transparent: false,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false, // https://github.com/electron/electron/issues/27961
enableRemoteModule: true
}
}
);

Expand All @@ -207,8 +232,20 @@ function openIt() {
ipc.on('openUrl', function(event, arg) {
console.log('openUrl', arg);

// if (appIcon) {
// appIcon.destroy()
// }

arg.webPreferences = arg.webPreferences === undefined ? {} : arg.webPreferences;
arg.webPreferences.nodeIntegration = true;
arg.webPreferences.contextIsolation = false;
arg.webPreferences.enableRemoteModule = true;

var html = arg.html;
var everWindow = mainWindow;
if (arg.icon) {
arg.icon = new Tray(__dirname + arg.icon)
}
var win2 = new BrowserWindow(arg);
win2.loadURL('file://' + __dirname + '/' + html);
mainWindow = win2;
Expand All @@ -235,6 +272,8 @@ function openIt() {
}
}

// tray只要实例化一次
// tray在windows下可能会有两个, 原因不明, 当注销后再启动
var trayShowed = false;
ipc.on('show-tray', function(event, arg) {
if (trayShowed) {
Expand All @@ -246,6 +285,8 @@ function openIt() {
return;
}

console.log('show tray')

appIcon = new Tray(__dirname + '/public/images/tray/' + ( process.platform == 'darwin' ? 'trayTemplate.png' : 'tray.png'))
var contextMenu = Menu.buildFromTemplate([
{
Expand All @@ -265,7 +306,7 @@ function openIt() {

appIcon.on('click', function (e) {
show();
e.preventDefault();
// e.preventDefault();
});
appIcon.on('right-click', function () {
appIcon.popUpContextMenu(contextMenu);
Expand Down
14 changes: 8 additions & 6 deletions note.html
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,15 @@ <h4 class="modal-title modalTitle lang">Local account warning</h4>
<p class="lang">It will not be synced before fixed.</p>
</div>

<script src="public/config.js"></script>
<script src="public/js/jquery-1.9.0.min.js"></script>
<script src="public/js/jquery.ztree.all-3.5.js"></script>
<script src="public/js/app/service.js"></script>
<script src="public/js/bootstrap-min.js"></script>
<script src="public/tinymce/tinymce.min.js"></script>
<script src="public/libs/ace/ace.js"></script>

<script src="src/browser/service.js"></script>

<script src="public/config.js"></script>
<script src="public/js/lang.js"></script>
<script src="public/js/common.js"></script>
<script>
Expand All @@ -650,16 +655,13 @@ <h4 class="modal-title modalTitle lang">Local account warning</h4>
window.requireNode = window.require;
window.nodeRequire = window.require;
window.require = undefined;
window.debug = false;
window.isDebug = false;
</script>

<!-- 渲染view -->
<script src="public/tinymce/tinymce.min.js"></script>
<script src="public/libs/ace/ace.js"></script>
<script src="public/js/app/api.js"></script> <!-- 本地api -->
<script src="public/js/app/native.js"></script>
<script src="public/js/app/page.js"></script>
<script src="public/js/bootstrap-min.js"></script>
<script src="public/js/app/note.js"></script>
<script src="public/js/app/tag.js"></script>
<script src="public/js/app/notebook.js"></script>
Expand Down
100 changes: 100 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4bd6a3f

Please sign in to comment.