mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Discard finder (#1497)
* Discard finder * Upgrade electron * Discard anything related with finder * Fix lint errors * Run test serial * Test on v6 * Test on v6 only
This commit is contained in:
committed by
GitHub
parent
922570bb5c
commit
51a8c47afd
@@ -1,14 +0,0 @@
|
||||
const electron = require('electron')
|
||||
const app = electron.app
|
||||
|
||||
app.on('ready', function () {
|
||||
if (process.platform === 'darwin') {
|
||||
app.dock.hide()
|
||||
}
|
||||
|
||||
/* eslint-disable */
|
||||
finderWindow = require('./finder-window')
|
||||
/* eslint-enable */
|
||||
})
|
||||
|
||||
module.exports = app
|
||||
@@ -1,101 +0,0 @@
|
||||
const electron = require('electron')
|
||||
const { app } = electron
|
||||
const BrowserWindow = electron.BrowserWindow
|
||||
const Menu = electron.Menu
|
||||
const MenuItem = electron.MenuItem
|
||||
const Tray = electron.Tray
|
||||
const path = require('path')
|
||||
|
||||
var config = {
|
||||
width: 840,
|
||||
height: 540,
|
||||
show: false,
|
||||
frame: false,
|
||||
resizable: false,
|
||||
zoomFactor: 1.0,
|
||||
webPreferences: {
|
||||
blinkFeatures: 'OverlayScrollbars'
|
||||
},
|
||||
skipTaskbar: true,
|
||||
standardWindow: false
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
config['always-on-top'] = true
|
||||
}
|
||||
|
||||
var finderWindow = new BrowserWindow(config)
|
||||
|
||||
var url = path.resolve(__dirname, './finder.html')
|
||||
|
||||
finderWindow.loadURL('file://' + url)
|
||||
finderWindow.setSkipTaskbar(true)
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
finderWindow.setVisibleOnAllWorkspaces(true)
|
||||
}
|
||||
|
||||
finderWindow.on('blur', function () {
|
||||
hideFinder()
|
||||
})
|
||||
|
||||
finderWindow.on('close', function (e) {
|
||||
e.preventDefault()
|
||||
finderWindow.hide()
|
||||
})
|
||||
|
||||
var trayIcon = process.platform === 'darwin' || process.platform === 'win32'
|
||||
? path.join(__dirname, '../resources/tray-icon-default.png')
|
||||
: path.join(__dirname, '../resources/tray-icon.png')
|
||||
var appIcon = new Tray(trayIcon)
|
||||
appIcon.setToolTip('Boostnote')
|
||||
if (process.platform === 'darwin') {
|
||||
appIcon.setPressedImage(path.join(__dirname, '../resources/tray-icon-dark.png'))
|
||||
}
|
||||
|
||||
var trayMenu = new Menu()
|
||||
trayMenu.append(new MenuItem({
|
||||
label: 'Open Main window',
|
||||
click: function () {
|
||||
finderWindow.webContents.send('open-main-from-tray')
|
||||
}
|
||||
}))
|
||||
|
||||
if (process.env.platform !== 'linux' || process.env.DESKTOP_SESSION === 'cinnamon') {
|
||||
trayMenu.append(new MenuItem({
|
||||
label: 'Open Finder window',
|
||||
click: function () {
|
||||
finderWindow.webContents.send('open-finder-from-tray')
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
trayMenu.append(new MenuItem({
|
||||
label: 'Quit',
|
||||
click: function () {
|
||||
finderWindow.webContents.send('quit-from-tray')
|
||||
}
|
||||
}))
|
||||
|
||||
appIcon.setContextMenu(trayMenu)
|
||||
appIcon.on('click', function (e) {
|
||||
e.preventDefault()
|
||||
appIcon.popUpContextMenu(trayMenu)
|
||||
})
|
||||
|
||||
function hideFinder () {
|
||||
if (process.platform === 'win32') {
|
||||
finderWindow.minimize()
|
||||
return
|
||||
}
|
||||
if (process.platform === 'darwin') {
|
||||
Menu.sendActionToFirstResponder('hide:')
|
||||
}
|
||||
finderWindow.hide()
|
||||
}
|
||||
|
||||
app.on('before-quit', function (e) {
|
||||
finderWindow.removeAllListeners()
|
||||
})
|
||||
|
||||
module.exports = finderWindow
|
||||
@@ -1,65 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<title>Boostnote Finder</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../node_modules/font-awesome/css/font-awesome.min.css" media="screen" charset="utf-8">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<link rel="stylesheet" href="../node_modules/codemirror/lib/codemirror.css">
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
src: url('../resources/fonts/Lato-Regular.woff2') format('woff2'), /* Modern Browsers */
|
||||
url('../resources/fonts/Lato-Regular.woff') format('woff'), /* Modern Browsers */
|
||||
url('../resources/fonts/Lato-Regular.ttf') format('truetype');
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content"></div>
|
||||
|
||||
<script src="../node_modules/codemirror/lib/codemirror.js"></script>
|
||||
<script src="../node_modules/codemirror/mode/meta.js"></script>
|
||||
<script src="../node_modules/codemirror-mode-elixir/dist/elixir.js"></script>
|
||||
<script src="../node_modules/codemirror/addon/mode/overlay.js"></script>
|
||||
<script src="../node_modules/codemirror/addon/mode/loadmode.js"></script>
|
||||
<script src="../node_modules/codemirror/keymap/sublime.js"></script>
|
||||
<script src="../node_modules/codemirror/keymap/vim.js"></script>
|
||||
<script src="../node_modules/codemirror/keymap/emacs.js"></script>
|
||||
<script src="../node_modules/codemirror/addon/runmode/runmode.js"></script>
|
||||
<script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
|
||||
|
||||
<script src="../node_modules/raphael/raphael.min.js"></script>
|
||||
<script src="../node_modules/flowchart.js/release/flowchart.min.js"></script>
|
||||
|
||||
<script src="../node_modules/katex/dist/katex.min.js"></script>
|
||||
<script src="../node_modules/react/dist/react.min.js"></script>
|
||||
<script src="../node_modules/react-dom/dist/react-dom.min.js"></script>
|
||||
<script src="../node_modules/redux/dist/redux.min.js"></script>
|
||||
<script src="../node_modules/react-redux/dist/react-redux.min.js"></script>
|
||||
<script>
|
||||
window._ = require('lodash');
|
||||
</script>
|
||||
<script src="../node_modules/js-sequence-diagrams/fucknpm/sequence-diagram-min.js"></script>
|
||||
<script>
|
||||
const electron = require('electron')
|
||||
electron.webFrame.setZoomLevelLimits(1, 1)
|
||||
const _ = require('lodash')
|
||||
var scriptUrl = _.find(electron.remote.process.argv, (a) => a === '--hot')
|
||||
? 'http://localhost:8080/assets/finder.js'
|
||||
: '../compiled/finder.js'
|
||||
var scriptEl = document.createElement('script')
|
||||
scriptEl.setAttribute('type', 'text/javascript')
|
||||
scriptEl.setAttribute('src', scriptUrl)
|
||||
document.body.appendChild(scriptEl)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -26,10 +26,6 @@ function toggleMainWindow () {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleFinder () {
|
||||
nodeIpc.server.broadcast('open-finder')
|
||||
}
|
||||
|
||||
ipcMain.on('config-renew', (e, payload) => {
|
||||
nodeIpc.server.broadcast('config-renew', payload)
|
||||
|
||||
@@ -37,11 +33,6 @@ ipcMain.on('config-renew', (e, payload) => {
|
||||
var { config } = payload
|
||||
|
||||
var errors = []
|
||||
try {
|
||||
globalShortcut.register(config.hotkey.toggleFinder, toggleFinder)
|
||||
} catch (err) {
|
||||
errors.push('toggleFinder')
|
||||
}
|
||||
try {
|
||||
globalShortcut.register(config.hotkey.toggleMain, toggleMainWindow)
|
||||
} catch (err) {
|
||||
@@ -61,12 +52,6 @@ ipcMain.on('config-renew', (e, payload) => {
|
||||
nodeIpc.serve(
|
||||
path.join(app.getPath('userData'), 'boostnote.service'),
|
||||
function () {
|
||||
nodeIpc.server.on('open-main-from-finder', toggleMainWindow)
|
||||
|
||||
nodeIpc.server.on('quit-from-finder', function () {
|
||||
app.quit()
|
||||
})
|
||||
|
||||
nodeIpc.server.on('connect', function (socket) {
|
||||
nodeIpc.log('ipc server >> socket joinned'.rainbow)
|
||||
socket.on('close', function () {
|
||||
@@ -76,14 +61,6 @@ nodeIpc.serve(
|
||||
nodeIpc.server.on('error', function (err) {
|
||||
nodeIpc.log('Node IPC error'.rainbow, err)
|
||||
})
|
||||
|
||||
// Todo: Direct connection between Main window renderer & Finder window renderer
|
||||
nodeIpc.server.on('request-data-from-finder', function () {
|
||||
nodeIpc.server.broadcast('request-data-from-finder')
|
||||
})
|
||||
nodeIpc.server.on('throttle-data', function (payload) {
|
||||
nodeIpc.server.broadcast('throttle-data', payload)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@ const electron = require('electron')
|
||||
const app = electron.app
|
||||
const Menu = electron.Menu
|
||||
const ipc = electron.ipcMain
|
||||
const path = require('path')
|
||||
const ChildProcess = require('child_process')
|
||||
const _ = require('lodash')
|
||||
const GhReleases = require('electron-gh-releases')
|
||||
// electron.crashReporter.start()
|
||||
var ipcServer = null
|
||||
@@ -72,17 +69,6 @@ ipc.on('update-app-confirm', function (event, msg) {
|
||||
}
|
||||
})
|
||||
|
||||
function spawnFinder () {
|
||||
var finderArgv = [path.join(__dirname, 'finder-app.js'), '--finder']
|
||||
if (_.find(process.argv, a => a === '--hot')) finderArgv.push('--hot')
|
||||
var finderProcess = ChildProcess
|
||||
.execFile(process.execPath, finderArgv)
|
||||
|
||||
app.on('before-quit', function () {
|
||||
finderProcess.kill()
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', function () {
|
||||
mainWindow = require('./main-window')
|
||||
|
||||
@@ -90,15 +76,12 @@ app.on('ready', function () {
|
||||
var menu = Menu.buildFromTemplate(template)
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
spawnFinder()
|
||||
Menu.setApplicationMenu(menu)
|
||||
break
|
||||
case 'win32':
|
||||
require('./finder-window')
|
||||
mainWindow.setMenu(menu)
|
||||
break
|
||||
case 'linux':
|
||||
require('./finder-window')
|
||||
Menu.setApplicationMenu(menu)
|
||||
mainWindow.setMenu(menu)
|
||||
}
|
||||
@@ -125,4 +108,3 @@ app.on('ready', function () {
|
||||
})
|
||||
|
||||
module.exports = app
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ const BrowserWindow = electron.BrowserWindow
|
||||
const path = require('path')
|
||||
const Config = require('electron-config')
|
||||
const config = new Config()
|
||||
const _ = require('lodash')
|
||||
|
||||
var showMenu = process.platform !== 'win32'
|
||||
const windowSize = config.get('windowsize') || { width: 1080, height: 720 }
|
||||
|
||||
console.log(windowSize)
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: windowSize.width,
|
||||
height: windowSize.height,
|
||||
@@ -57,26 +58,21 @@ if (process.platform !== 'linux' || process.env.DESKTOP_SESSION === 'cinnamon')
|
||||
})
|
||||
|
||||
app.on('before-quit', function (e) {
|
||||
storeWindowSize()
|
||||
mainWindow.removeAllListeners()
|
||||
})
|
||||
} else {
|
||||
mainWindow.on('close', function () {
|
||||
storeWindowSize()
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
app.quit()
|
||||
})
|
||||
}
|
||||
|
||||
mainWindow.on('resize', _.throttle(storeWindowSize, 500))
|
||||
function quitApp () {
|
||||
storeWindowSize()
|
||||
app.quit()
|
||||
}
|
||||
|
||||
function storeWindowSize () {
|
||||
try {
|
||||
console.log(mainWindow.getBounds())
|
||||
config.set('windowsize', mainWindow.getBounds())
|
||||
} catch (e) {
|
||||
// ignore any errors because an error occurs only on update
|
||||
|
||||
Reference in New Issue
Block a user