mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
fixed eslint error & integrated with prettier as well as formatted the whole codebase (#3450)
This commit is contained in:
@@ -7,7 +7,7 @@ nodeIpc.config.id = 'node'
|
||||
nodeIpc.config.retry = 1500
|
||||
nodeIpc.config.silent = true
|
||||
|
||||
function toggleMainWindow () {
|
||||
function toggleMainWindow() {
|
||||
switch (global.process.platform) {
|
||||
case 'darwin':
|
||||
if (mainWindow.isFocused()) {
|
||||
@@ -52,14 +52,14 @@ ipcMain.on('config-renew', (e, payload) => {
|
||||
|
||||
nodeIpc.serve(
|
||||
path.join(app.getPath('userData'), 'boostnote.service'),
|
||||
function () {
|
||||
nodeIpc.server.on('connect', function (socket) {
|
||||
function() {
|
||||
nodeIpc.server.on('connect', function(socket) {
|
||||
nodeIpc.log('ipc server >> socket joinned'.rainbow)
|
||||
socket.on('close', function () {
|
||||
socket.on('close', function() {
|
||||
nodeIpc.log('ipc server >> socket closed'.rainbow)
|
||||
})
|
||||
})
|
||||
nodeIpc.server.on('error', function (err) {
|
||||
nodeIpc.server.on('error', function(err) {
|
||||
nodeIpc.log('Node IPC error'.rainbow, err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -36,8 +36,9 @@ const updater = new GhReleases(ghReleasesOpts)
|
||||
|
||||
// Check for updates
|
||||
// `status` returns true if there is a new update available
|
||||
function checkUpdate () {
|
||||
if (!isPackaged) { // Prevents app from attempting to update when in dev mode.
|
||||
function checkUpdate() {
|
||||
if (!isPackaged) {
|
||||
// Prevents app from attempting to update when in dev mode.
|
||||
console.log('Updates are disabled in Development mode, see main-app.js')
|
||||
return true
|
||||
}
|
||||
@@ -58,29 +59,29 @@ function checkUpdate () {
|
||||
})
|
||||
}
|
||||
|
||||
updater.on('update-downloaded', (info) => {
|
||||
updater.on('update-downloaded', info => {
|
||||
if (mainWindow != null) {
|
||||
mainWindow.webContents.send('update-ready', 'Update available!')
|
||||
isUpdateReady = true
|
||||
}
|
||||
})
|
||||
|
||||
updater.autoUpdater.on('error', (err) => {
|
||||
updater.autoUpdater.on('error', err => {
|
||||
console.error(err)
|
||||
})
|
||||
|
||||
ipc.on('update-app-confirm', function (event, msg) {
|
||||
ipc.on('update-app-confirm', function(event, msg) {
|
||||
if (isUpdateReady) {
|
||||
mainWindow.removeAllListeners()
|
||||
updater.install()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
app.on('window-all-closed', function() {
|
||||
app.quit()
|
||||
})
|
||||
|
||||
app.on('ready', function () {
|
||||
app.on('ready', function() {
|
||||
mainWindow = require('./main-window')
|
||||
|
||||
var template = require('./main-menu')
|
||||
@@ -100,7 +101,7 @@ app.on('ready', function () {
|
||||
}
|
||||
|
||||
// Check update every day
|
||||
setInterval(function () {
|
||||
setInterval(function() {
|
||||
if (isPackaged) checkUpdate()
|
||||
}, 1000 * 60 * 60 * 24)
|
||||
|
||||
@@ -108,7 +109,7 @@ app.on('ready', function () {
|
||||
setTimeout(() => {
|
||||
if (isPackaged) checkUpdate()
|
||||
|
||||
ipc.on('update-check', function (event, msg) {
|
||||
ipc.on('update-check', function(event, msg) {
|
||||
if (isUpdateReady) {
|
||||
mainWindow.webContents.send('update-ready', 'Update available!')
|
||||
} else {
|
||||
|
||||
257
lib/main-menu.js
257
lib/main-menu.js
@@ -11,68 +11,68 @@ const LINUX = process.platform === 'linux'
|
||||
|
||||
const boost = macOS
|
||||
? {
|
||||
label: 'Boostnote',
|
||||
submenu: [
|
||||
{
|
||||
label: 'About Boostnote',
|
||||
selector: 'orderFrontStandardAboutPanel:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Preferences',
|
||||
accelerator: 'Command+,',
|
||||
click () {
|
||||
mainWindow.webContents.send('side:preferences')
|
||||
label: 'Boostnote',
|
||||
submenu: [
|
||||
{
|
||||
label: 'About Boostnote',
|
||||
selector: 'orderFrontStandardAboutPanel:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Preferences',
|
||||
accelerator: 'Command+,',
|
||||
click() {
|
||||
mainWindow.webContents.send('side:preferences')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Hide Boostnote',
|
||||
accelerator: 'Command+H',
|
||||
selector: 'hide:'
|
||||
},
|
||||
{
|
||||
label: 'Hide Others',
|
||||
accelerator: 'Command+Shift+H',
|
||||
selector: 'hideOtherApplications:'
|
||||
},
|
||||
{
|
||||
label: 'Show All',
|
||||
selector: 'unhideAllApplications:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Quit Boostnote',
|
||||
role: 'quit',
|
||||
accelerator: 'CommandOrControl+Q'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Hide Boostnote',
|
||||
accelerator: 'Command+H',
|
||||
selector: 'hide:'
|
||||
},
|
||||
{
|
||||
label: 'Hide Others',
|
||||
accelerator: 'Command+Shift+H',
|
||||
selector: 'hideOtherApplications:'
|
||||
},
|
||||
{
|
||||
label: 'Show All',
|
||||
selector: 'unhideAllApplications:'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Quit Boostnote',
|
||||
role: 'quit',
|
||||
accelerator: 'CommandOrControl+Q'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
: {
|
||||
label: 'Boostnote',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Preferences',
|
||||
accelerator: 'Control+,',
|
||||
click () {
|
||||
mainWindow.webContents.send('side:preferences')
|
||||
label: 'Boostnote',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Preferences',
|
||||
accelerator: 'Control+,',
|
||||
click() {
|
||||
mainWindow.webContents.send('side:preferences')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'quit',
|
||||
accelerator: 'Control+Q'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'quit',
|
||||
accelerator: 'Control+Q'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const file = {
|
||||
label: 'File',
|
||||
@@ -80,28 +80,28 @@ const file = {
|
||||
{
|
||||
label: 'New Note',
|
||||
accelerator: 'CommandOrControl+N',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('top:new-note')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Focus Note',
|
||||
accelerator: 'CommandOrControl+E',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('detail:focus')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Delete Note',
|
||||
accelerator: 'CommandOrControl+Shift+Backspace',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('detail:delete')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Clone Note',
|
||||
accelerator: 'CommandOrControl+D',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:clone')
|
||||
}
|
||||
},
|
||||
@@ -113,7 +113,7 @@ const file = {
|
||||
submenu: [
|
||||
{
|
||||
label: 'Plain Text, MarkDown (.txt, .md)',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('import:file')
|
||||
}
|
||||
}
|
||||
@@ -124,28 +124,28 @@ const file = {
|
||||
submenu: [
|
||||
{
|
||||
label: 'Plain Text (.txt)',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:isMarkdownNote', 'export-txt')
|
||||
mainWindow.webContents.send('export:save-text')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'MarkDown (.md)',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:isMarkdownNote', 'export-md')
|
||||
mainWindow.webContents.send('export:save-md')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'HTML (.html)',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:isMarkdownNote', 'export-html')
|
||||
mainWindow.webContents.send('export:save-html')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'PDF (.pdf)',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:isMarkdownNote', 'export-pdf')
|
||||
mainWindow.webContents.send('export:save-pdf')
|
||||
}
|
||||
@@ -158,13 +158,13 @@ const file = {
|
||||
{
|
||||
label: 'Generate/Update Markdown TOC',
|
||||
accelerator: 'Shift+Ctrl+T',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('code:generate-toc')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Format Table',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('code:format-table')
|
||||
}
|
||||
},
|
||||
@@ -174,7 +174,7 @@ const file = {
|
||||
{
|
||||
label: 'Print',
|
||||
accelerator: 'CommandOrControl+P',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:isMarkdownNote', 'print')
|
||||
mainWindow.webContents.send('print')
|
||||
}
|
||||
@@ -183,20 +183,25 @@ const file = {
|
||||
}
|
||||
|
||||
if (LINUX) {
|
||||
file.submenu.push({
|
||||
type: 'separator'
|
||||
}, {
|
||||
label: 'Preferences',
|
||||
accelerator: 'Control+,',
|
||||
click () {
|
||||
mainWindow.webContents.send('side:preferences')
|
||||
file.submenu.push(
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: 'Preferences',
|
||||
accelerator: 'Control+,',
|
||||
click() {
|
||||
mainWindow.webContents.send('side:preferences')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
role: 'quit',
|
||||
accelerator: 'Control+Q'
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
}, {
|
||||
role: 'quit',
|
||||
accelerator: 'Control+Q'
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const edit = {
|
||||
@@ -241,7 +246,7 @@ const edit = {
|
||||
{
|
||||
label: 'Add Tag',
|
||||
accelerator: 'CommandOrControl+Shift+T',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('editor:add-tag')
|
||||
}
|
||||
}
|
||||
@@ -254,14 +259,14 @@ const view = {
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CommandOrControl+R',
|
||||
click () {
|
||||
click() {
|
||||
BrowserWindow.getFocusedWindow().reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Developer Tools',
|
||||
accelerator: 'CommandOrControl+Alt+I',
|
||||
click () {
|
||||
click() {
|
||||
BrowserWindow.getFocusedWindow().toggleDevTools()
|
||||
}
|
||||
},
|
||||
@@ -271,14 +276,14 @@ const view = {
|
||||
{
|
||||
label: 'Next Note',
|
||||
accelerator: 'CommandOrControl+]',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:next')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Previous Note',
|
||||
accelerator: 'CommandOrControl+[',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('list:prior')
|
||||
}
|
||||
},
|
||||
@@ -288,7 +293,7 @@ const view = {
|
||||
{
|
||||
label: 'Focus Search',
|
||||
accelerator: 'CommandOrControl+Shift+L',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('top:focus-search')
|
||||
}
|
||||
},
|
||||
@@ -298,14 +303,14 @@ const view = {
|
||||
{
|
||||
label: 'Toggle Full Screen',
|
||||
accelerator: macOS ? 'Command+Control+F' : 'F11',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.setFullScreen(!mainWindow.isFullScreen())
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Toggle Side Bar',
|
||||
accelerator: 'CommandOrControl+B',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('editor:fullscreen')
|
||||
}
|
||||
},
|
||||
@@ -315,21 +320,21 @@ const view = {
|
||||
{
|
||||
label: 'Actual Size',
|
||||
accelerator: 'CommandOrControl+0',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('status:zoomreset')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom In',
|
||||
accelerator: 'CommandOrControl+=',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('status:zoomin')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Zoom Out',
|
||||
accelerator: 'CommandOrControl+-',
|
||||
click () {
|
||||
click() {
|
||||
mainWindow.webContents.send('status:zoomout')
|
||||
}
|
||||
}
|
||||
@@ -382,38 +387,58 @@ const help = {
|
||||
submenu: [
|
||||
{
|
||||
label: 'Boostnote official site',
|
||||
click () { shell.openExternal('https://boostnote.io/') }
|
||||
click() {
|
||||
shell.openExternal('https://boostnote.io/')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Wiki',
|
||||
click () { shell.openExternal('https://github.com/BoostIO/Boostnote/wiki') }
|
||||
click() {
|
||||
shell.openExternal('https://github.com/BoostIO/Boostnote/wiki')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Issue Tracker',
|
||||
click () { shell.openExternal('https://github.com/BoostIO/Boostnote/issues') }
|
||||
click() {
|
||||
shell.openExternal('https://github.com/BoostIO/Boostnote/issues')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Changelog',
|
||||
click () { shell.openExternal('https://github.com/BoostIO/boost-releases') }
|
||||
click() {
|
||||
shell.openExternal('https://github.com/BoostIO/boost-releases')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Cheatsheets',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Markdown',
|
||||
click () { shell.openExternal('https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet') }
|
||||
click() {
|
||||
shell.openExternal(
|
||||
'https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Latex',
|
||||
click () { shell.openExternal('https://katex.org/docs/supported.html') }
|
||||
click() {
|
||||
shell.openExternal('https://katex.org/docs/supported.html')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'HTML',
|
||||
click () { shell.openExternal('https://htmlcheatsheet.com/') }
|
||||
click() {
|
||||
shell.openExternal('https://htmlcheatsheet.com/')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Boostnote',
|
||||
click () { shell.openExternal('https://github.com/TobseF/boostnote-markdown-cheatsheet/blob/master/BOOSTNOTE_MARKDOWN_CHEAT_SHEET.md') }
|
||||
click() {
|
||||
shell.openExternal(
|
||||
'https://github.com/TobseF/boostnote-markdown-cheatsheet/blob/master/BOOSTNOTE_MARKDOWN_CHEAT_SHEET.md'
|
||||
)
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -422,7 +447,7 @@ const help = {
|
||||
},
|
||||
{
|
||||
label: 'About',
|
||||
click () {
|
||||
click() {
|
||||
const version = electron.app.getVersion()
|
||||
const electronVersion = process.versions.electron
|
||||
const chromeVersion = process.versions.chrome
|
||||
@@ -430,20 +455,20 @@ const help = {
|
||||
const v8Version = process.versions.v8
|
||||
const OSInfo = `${os.type()} ${os.arch()} ${os.release()}`
|
||||
const detail = `Version: ${version}\nElectron: ${electronVersion}\nChrome: ${chromeVersion}\nNode.js: ${nodeVersion}\nV8: ${v8Version}\nOS: ${OSInfo}`
|
||||
electron.dialog.showMessageBox(BrowserWindow.getFocusedWindow(),
|
||||
{
|
||||
title: 'BoostNote',
|
||||
message: 'BoostNote',
|
||||
type: 'info',
|
||||
detail: `\n${detail}`
|
||||
})
|
||||
electron.dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
|
||||
title: 'BoostNote',
|
||||
message: 'BoostNote',
|
||||
type: 'info',
|
||||
detail: `\n${detail}`
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
module.exports = process.platform === 'darwin'
|
||||
? [boost, file, edit, view, window, help]
|
||||
: process.platform === 'win32'
|
||||
? [boost, file, view, help]
|
||||
: [file, view, help]
|
||||
module.exports =
|
||||
process.platform === 'darwin'
|
||||
? [boost, file, edit, view, window, help]
|
||||
: process.platform === 'win32'
|
||||
? [boost, file, view, help]
|
||||
: [file, view, help]
|
||||
|
||||
@@ -54,12 +54,17 @@ const mainWindow = new BrowserWindow({
|
||||
},
|
||||
icon: path.resolve(__dirname, '../resources/app.png')
|
||||
})
|
||||
const url = path.resolve(__dirname, process.env.NODE_ENV === 'development' ? './main.development.html' : './main.production.html')
|
||||
const url = path.resolve(
|
||||
__dirname,
|
||||
process.env.NODE_ENV === 'development'
|
||||
? './main.development.html'
|
||||
: './main.production.html'
|
||||
)
|
||||
|
||||
mainWindow.loadURL('file://' + url)
|
||||
mainWindow.setMenuBarVisibility(false)
|
||||
|
||||
mainWindow.webContents.on('new-window', function (e) {
|
||||
mainWindow.webContents.on('new-window', function(e) {
|
||||
e.preventDefault()
|
||||
})
|
||||
|
||||
@@ -74,10 +79,10 @@ mainWindow.webContents.sendInputEvent({
|
||||
})
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
mainWindow.on('close', function (e) {
|
||||
mainWindow.on('close', function(e) {
|
||||
e.preventDefault()
|
||||
if (mainWindow.isFullScreen()) {
|
||||
mainWindow.once('leave-full-screen', function () {
|
||||
mainWindow.once('leave-full-screen', function() {
|
||||
mainWindow.hide()
|
||||
})
|
||||
mainWindow.setFullScreen(false)
|
||||
@@ -86,7 +91,7 @@ if (process.platform === 'darwin') {
|
||||
}
|
||||
})
|
||||
|
||||
app.on('before-quit', function (e) {
|
||||
app.on('before-quit', function(e) {
|
||||
mainWindow.removeAllListeners()
|
||||
})
|
||||
}
|
||||
@@ -94,7 +99,7 @@ if (process.platform === 'darwin') {
|
||||
mainWindow.on('resize', _.throttle(storeWindowSize, 500))
|
||||
mainWindow.on('move', _.throttle(storeWindowSize, 500))
|
||||
|
||||
function storeWindowSize () {
|
||||
function storeWindowSize() {
|
||||
try {
|
||||
config.set('windowsize', mainWindow.getBounds())
|
||||
} catch (e) {
|
||||
@@ -103,7 +108,7 @@ function storeWindowSize () {
|
||||
}
|
||||
}
|
||||
|
||||
app.on('activate', function () {
|
||||
app.on('activate', function() {
|
||||
if (mainWindow == null) return null
|
||||
mainWindow.show()
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const {TouchBar} = require('electron')
|
||||
const {TouchBarButton, TouchBarSpacer} = TouchBar
|
||||
const { TouchBar } = require('electron')
|
||||
const { TouchBarButton, TouchBarSpacer } = TouchBar
|
||||
const mainWindow = require('./main-window')
|
||||
|
||||
const allNotes = new TouchBarButton({
|
||||
@@ -35,7 +35,6 @@ module.exports = new TouchBar([
|
||||
allNotes,
|
||||
starredNotes,
|
||||
trash,
|
||||
new TouchBarSpacer({size: 'small'}),
|
||||
new TouchBarSpacer({ size: 'small' }),
|
||||
newNote
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user