1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-09-20 09:27:16 +03:00
This commit is contained in:
Eugene Pankov 2020-02-05 15:16:31 +03:00
parent 04d4474648
commit 3f8b933d05
6 changed files with 44 additions and 41 deletions

View File

@ -1,4 +1,5 @@
import { app, ipcMain, Menu, Tray, shell } from 'electron'
// eslint-disable-next-line no-duplicate-imports
import * as electron from 'electron'
import { loadConfig } from './config'
import { Window, WindowOptions } from './window'
@ -75,7 +76,7 @@ export class Application {
this.tray = new Tray(`${app.getAppPath()}/assets/tray.png`)
}
this.tray.on('click', () => setTimeout(() => this.focus()));
this.tray.on('click', () => setTimeout(() => this.focus()))
const contextMenu = Menu.buildFromTemplate([{
label: 'Show',
@ -186,7 +187,7 @@ export class Application {
},
},
],
}
},
]
Menu.setApplicationMenu(Menu.buildFromTemplate(template))

View File

@ -20,25 +20,25 @@ export function parseArgs (argv, cwd) {
return yargs.option('escape', {
alias: 'e',
type: 'boolean',
describe: 'Perform shell escaping'
describe: 'Perform shell escaping',
}).positional('text', {
type: 'string'
type: 'string',
})
})
.version('version', '', app.getVersion())
.option('debug', {
alias: 'd',
describe: 'Show DevTools on start',
type: 'boolean'
type: 'boolean',
})
.option('hidden', {
describe: 'Start minimized',
type: 'boolean'
type: 'boolean',
})
.option('version', {
alias: 'v',
describe: 'Show version and exit',
type: 'boolean'
type: 'boolean',
})
.help('help')
.parse(argv.slice(1))

View File

@ -59,8 +59,8 @@ app.on('ready', () => {
label: 'New window',
click () {
this.app.newWindow()
}
}
},
},
]))
}
application.init()

View File

@ -1,13 +1,15 @@
let lru = require('lru-cache')({ max: 256, maxAge: 250 })
let fs = require('fs')
let origLstat = fs.realpathSync.bind(fs)
import createLRU from 'lru-cache'
import * as fs from 'fs'
const lru = createLRU({ max: 256, maxAge: 250 })
const origLstat = fs.realpathSync.bind(fs)
// NB: The biggest offender of thrashing realpathSync is the node module system
// itself, which we can't get into via any sane means.
require('fs').realpathSync = function (p) {
let r = lru.get(p)
if (r) return r
if (r) {
return r
}
r = origLstat(p)
lru.set(p, r)

View File

@ -1,21 +1,21 @@
const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer')
import * as isDev from 'electron-is-dev'
const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876'
let release
try {
release = require('electron').app.getVersion()
} catch {
release = require('electron').remote.app.getVersion()
}
if (!isDev) {
init({
dsn: SENTRY_DSN,
release,
integrations (integrations) {
return integrations.filter(integration => integration.name !== 'Breadcrumbs')
},
})
}
const { init } = process.type === 'main' ? require('@sentry/electron/dist/main') : require('@sentry/electron/dist/renderer')
import * as isDev from 'electron-is-dev'
const SENTRY_DSN = 'https://4717a0a7ee0b4429bd3a0f06c3d7eec3@sentry.io/181876'
let release
try {
release = require('electron').app.getVersion()
} catch {
release = require('electron').remote.app.getVersion()
}
if (!isDev) {
init({
dsn: SENTRY_DSN,
release,
integrations (integrations) {
return integrations.filter(integration => integration.name !== 'Breadcrumbs')
},
})
}

View File

@ -56,14 +56,14 @@ export class Window {
if (this.windowBounds) {
Object.assign(bwOptions, this.windowBounds)
const closestDisplay = screen.getDisplayNearestPoint( {x: this.windowBounds.x, y: this.windowBounds.y} )
const closestDisplay = screen.getDisplayNearestPoint( { x: this.windowBounds.x, y: this.windowBounds.y } )
const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height];
const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height];
const [left1, top1, right1, bottom1] = [this.windowBounds.x, this.windowBounds.y, this.windowBounds.x + this.windowBounds.width, this.windowBounds.y + this.windowBounds.height]
const [left2, top2, right2, bottom2] = [closestDisplay.bounds.x, closestDisplay.bounds.y, closestDisplay.bounds.x + closestDisplay.bounds.width, closestDisplay.bounds.y + closestDisplay.bounds.height]
if ((left2 > right1 || right2 < left1 || top2 > bottom1 || bottom2 < top1) && !maximized) {
bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2;
bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2;
bwOptions.x = closestDisplay.bounds.width / 2 - bwOptions.width / 2
bwOptions.y = closestDisplay.bounds.height / 2 - bwOptions.height / 2
}
}
@ -150,7 +150,7 @@ export class Window {
}
isDestroyed () {
return !this.window || this.window.isDestroyed();
return !this.window || this.window.isDestroyed()
}
private setupWindowManagement () {