Skip to content

Commit

Permalink
增加 eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
JChehe committed Jun 2, 2017
1 parent 87aeb68 commit bf0bb0e
Show file tree
Hide file tree
Showing 57 changed files with 4,244 additions and 4,249 deletions.
13 changes: 11 additions & 2 deletions .babelrc
@@ -1,4 +1,13 @@
{
"presets": ["es2015", "stage-0"],
"plugins": ["transform-runtime"]
"presets": [
"es2015",
"stage-2"
],
"plugins": ["transform-runtime"],
"comments": false,
"env": {
"test": {
"plugins": ["istanbul"]
}
}
}
15 changes: 15 additions & 0 deletions .editorconfig
@@ -0,0 +1,15 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .eslintrc
@@ -0,0 +1,6 @@
{
"extends": "eslint-config-o2team",
"rules": {
"no-multiple-empty-lines": [ 1,{ "max": 1 } ]
}
}
15 changes: 7 additions & 8 deletions app/crashTempate.js
@@ -1,12 +1,11 @@
const electron = require('electron')
const crashReporter = electron.crashReporter


exports.start = function () {
crashReporter.start({
productName: 'xcel',
companyName: 'o2team',
submitURL: 'http://localhost:4000/crash/',
autoSubmit: true
})
}
crashReporter.start({
productName: 'xcel',
companyName: 'o2team',
submitURL: 'http://localhost:4000/crash/',
autoSubmit: true
})
}
129 changes: 61 additions & 68 deletions app/electron.js
Expand Up @@ -11,97 +11,90 @@ const Menu = electron.Menu

let mainWindow // 主窗口
let backgroundWindow // 执行耗时运算的 背后窗口
let updateWindow // 更新的下载窗口
var windowBounds = {} // 主窗口的尺寸信息
let config = {}

if (process.env.NODE_ENV === 'development') {
config = require('../config')
config.mainUrl = `http://localhost:${config.port}`
config = require('../config')
config.mainUrl = `http://localhost:${config.port}`
} else {
config.devtron = false
config.mainUrl = `file://${__dirname}/dist/index.html`
config.devtron = false
config.mainUrl = `file://${__dirname}/dist/index.html`
}
config.backUrl = `file://${__dirname}/dist/background/index.html`
config.isDev = process.env.NODE_ENV === 'development'


function createMainWindow() {
var win = new BrowserWindow({
height: 850,
width: 1280,
minWidth: 1120,
minHeight: 768,
backgroundColor: "#f5f5f5",
fullscreenable: false,
frame: false,
show: false
})
windowBounds = win.getBounds()
win.loadURL(config.mainUrl)

if (config.isDev) {
BrowserWindow.addDevToolsExtension(path.join(__dirname, '../node_modules/devtron'))

let installExtension = require('electron-devtools-installer')

installExtension.default(installExtension.VUEJS_DEVTOOLS)
.then((name) => win.webContents.openDevTools())
.catch((err) => console.log('An error occurred: ', err))
}

win.on('closed', () => {
console.log("触发 closed")
mainWindow = null
backgroundWindow = null
function createMainWindow () {
const win = new BrowserWindow({
height: 850,
width: 1280,
minWidth: 1120,
minHeight: 768,
backgroundColor: '#f5f5f5',
fullscreenable: false,
frame: false,
show: false
})
win.loadURL(config.mainUrl)

if (config.isDev) {
BrowserWindow.addDevToolsExtension(path.join(__dirname, '../node_modules/devtron'))

const installExtension = require('electron-devtools-installer')

installExtension.default(installExtension.VUEJS_DEVTOOLS)
.then(name => win.webContents.openDevTools())
.catch(err => console.log('An error occurred: ', err))
}

win.on('closed', () => {
console.log('触发 closed')
mainWindow = null
backgroundWindow = null
// 在Mac中完全退出程序,而不会留在dock中
app.quit()
})

win.on('ready-to-show', () => {
win.show()
win.focus()
})
console.log('mainWindow opened')
return win
app.quit()
})

win.on('ready-to-show', () => {
win.show()
win.focus()
})
console.log('mainWindow opened')
return win
}

function createBackgroundWindow() {
var win = new BrowserWindow({
show: config.isDev
})
win.loadURL(config.backUrl)
console.log("backgroundWindow opened")
return win
function createBackgroundWindow () {
const win = new BrowserWindow({
show: config.isDev
})
win.loadURL(config.backUrl)
console.log('backgroundWindow opened')
return win
}


app.on('ready', () => {
console.log("ready")
mainWindow = createMainWindow()
backgroundWindow = createBackgroundWindow()
ipcMainSets(mainWindow, backgroundWindow)
const menu = Menu.buildFromTemplate(menuTemplate)
Menu.setApplicationMenu(menu)
console.log('ready')
mainWindow = createMainWindow()
backgroundWindow = createBackgroundWindow()
ipcMainSets(mainWindow, backgroundWindow)
const menu = Menu.buildFromTemplate(menuTemplate)
Menu.setApplicationMenu(menu)
})



app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
if (process.platform !== 'darwin') {
app.quit()
}
})

// 当应用被激活时触发,常用于点击应用的 dock 图标的时候。
// 现在取消保留在Dock中,完全退出
app.on('activate', () => {
if (mainWindow.isDestroyed()) {
mainWindow = createMainWindow()
backgroundWindow = createBackgroundWindow()
}
if (mainWindow.isDestroyed()) {
mainWindow = createMainWindow()
backgroundWindow = createBackgroundWindow()
}
})

crashTempate.start()

console.log("主进程pid:", process.pid)
console.log('主进程pid:', process.pid)

0 comments on commit bf0bb0e

Please sign in to comment.