Skip to content

Commit bf0bb0e

Browse files
committed
增加 eslint
1 parent 87aeb68 commit bf0bb0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4244
-4249
lines changed

.babelrc

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
{
2-
"presets": ["es2015", "stage-0"],
3-
"plugins": ["transform-runtime"]
2+
"presets": [
3+
"es2015",
4+
"stage-2"
5+
],
6+
"plugins": ["transform-runtime"],
7+
"comments": false,
8+
"env": {
9+
"test": {
10+
"plugins": ["istanbul"]
11+
}
12+
}
413
}

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "eslint-config-o2team",
3+
"rules": {
4+
"no-multiple-empty-lines": [ 1,{ "max": 1 } ]
5+
}
6+
}

app/crashTempate.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
const electron = require('electron')
22
const crashReporter = electron.crashReporter
33

4-
54
exports.start = function () {
6-
crashReporter.start({
7-
productName: 'xcel',
8-
companyName: 'o2team',
9-
submitURL: 'http://localhost:4000/crash/',
10-
autoSubmit: true
11-
})
12-
}
5+
crashReporter.start({
6+
productName: 'xcel',
7+
companyName: 'o2team',
8+
submitURL: 'http://localhost:4000/crash/',
9+
autoSubmit: true
10+
})
11+
}

app/electron.js

+61-68
Original file line numberDiff line numberDiff line change
@@ -11,97 +11,90 @@ const Menu = electron.Menu
1111

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

1816
if (process.env.NODE_ENV === 'development') {
19-
config = require('../config')
20-
config.mainUrl = `http://localhost:${config.port}`
17+
config = require('../config')
18+
config.mainUrl = `http://localhost:${config.port}`
2119
} else {
22-
config.devtron = false
23-
config.mainUrl = `file://${__dirname}/dist/index.html`
20+
config.devtron = false
21+
config.mainUrl = `file://${__dirname}/dist/index.html`
2422
}
2523
config.backUrl = `file://${__dirname}/dist/background/index.html`
2624
config.isDev = process.env.NODE_ENV === 'development'
2725

28-
29-
function createMainWindow() {
30-
var win = new BrowserWindow({
31-
height: 850,
32-
width: 1280,
33-
minWidth: 1120,
34-
minHeight: 768,
35-
backgroundColor: "#f5f5f5",
36-
fullscreenable: false,
37-
frame: false,
38-
show: false
39-
})
40-
windowBounds = win.getBounds()
41-
win.loadURL(config.mainUrl)
42-
43-
if (config.isDev) {
44-
BrowserWindow.addDevToolsExtension(path.join(__dirname, '../node_modules/devtron'))
45-
46-
let installExtension = require('electron-devtools-installer')
47-
48-
installExtension.default(installExtension.VUEJS_DEVTOOLS)
49-
.then((name) => win.webContents.openDevTools())
50-
.catch((err) => console.log('An error occurred: ', err))
51-
}
52-
53-
win.on('closed', () => {
54-
console.log("触发 closed")
55-
mainWindow = null
56-
backgroundWindow = null
26+
function createMainWindow () {
27+
const win = new BrowserWindow({
28+
height: 850,
29+
width: 1280,
30+
minWidth: 1120,
31+
minHeight: 768,
32+
backgroundColor: '#f5f5f5',
33+
fullscreenable: false,
34+
frame: false,
35+
show: false
36+
})
37+
win.loadURL(config.mainUrl)
38+
39+
if (config.isDev) {
40+
BrowserWindow.addDevToolsExtension(path.join(__dirname, '../node_modules/devtron'))
41+
42+
const installExtension = require('electron-devtools-installer')
43+
44+
installExtension.default(installExtension.VUEJS_DEVTOOLS)
45+
.then(name => win.webContents.openDevTools())
46+
.catch(err => console.log('An error occurred: ', err))
47+
}
48+
49+
win.on('closed', () => {
50+
console.log('触发 closed')
51+
mainWindow = null
52+
backgroundWindow = null
5753
// 在Mac中完全退出程序,而不会留在dock中
58-
app.quit()
59-
})
60-
61-
win.on('ready-to-show', () => {
62-
win.show()
63-
win.focus()
64-
})
65-
console.log('mainWindow opened')
66-
return win
54+
app.quit()
55+
})
56+
57+
win.on('ready-to-show', () => {
58+
win.show()
59+
win.focus()
60+
})
61+
console.log('mainWindow opened')
62+
return win
6763
}
6864

69-
function createBackgroundWindow() {
70-
var win = new BrowserWindow({
71-
show: config.isDev
72-
})
73-
win.loadURL(config.backUrl)
74-
console.log("backgroundWindow opened")
75-
return win
65+
function createBackgroundWindow () {
66+
const win = new BrowserWindow({
67+
show: config.isDev
68+
})
69+
win.loadURL(config.backUrl)
70+
console.log('backgroundWindow opened')
71+
return win
7672
}
7773

78-
7974
app.on('ready', () => {
80-
console.log("ready")
81-
mainWindow = createMainWindow()
82-
backgroundWindow = createBackgroundWindow()
83-
ipcMainSets(mainWindow, backgroundWindow)
84-
const menu = Menu.buildFromTemplate(menuTemplate)
85-
Menu.setApplicationMenu(menu)
75+
console.log('ready')
76+
mainWindow = createMainWindow()
77+
backgroundWindow = createBackgroundWindow()
78+
ipcMainSets(mainWindow, backgroundWindow)
79+
const menu = Menu.buildFromTemplate(menuTemplate)
80+
Menu.setApplicationMenu(menu)
8681
})
8782

88-
89-
9083
app.on('window-all-closed', () => {
91-
if (process.platform !== 'darwin') {
92-
app.quit()
93-
}
84+
if (process.platform !== 'darwin') {
85+
app.quit()
86+
}
9487
})
9588

9689
// 当应用被激活时触发,常用于点击应用的 dock 图标的时候。
9790
// 现在取消保留在Dock中,完全退出
9891
app.on('activate', () => {
99-
if (mainWindow.isDestroyed()) {
100-
mainWindow = createMainWindow()
101-
backgroundWindow = createBackgroundWindow()
102-
}
92+
if (mainWindow.isDestroyed()) {
93+
mainWindow = createMainWindow()
94+
backgroundWindow = createBackgroundWindow()
95+
}
10396
})
10497

10598
crashTempate.start()
10699

107-
console.log("主进程pid:", process.pid)
100+
console.log('主进程pid:', process.pid)

0 commit comments

Comments
 (0)