-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
582 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-0"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
## 参考 http://eslint.org/docs/user-guide/configuring | ||
--- | ||
env: | ||
browser: true | ||
node: true | ||
es6: true | ||
ecmaFeatures: | ||
arrowFunctions: true | ||
binaryLiterals: true | ||
blockBindings: true | ||
classes: true | ||
defaultParams: true | ||
destructuring: true | ||
forOf: true | ||
generators: true | ||
modules: true | ||
objectLiteralComputedProperties: true | ||
objectLiteralDuplicateProperties: true | ||
objectLiteralShorthandMethods: true | ||
objectLiteralShorthandProperties: true | ||
octalLiterals: true | ||
regexUFlag: true | ||
regexYFlag: true | ||
spread: true | ||
superInFunctions: true | ||
templateStrings: true | ||
unicodeCodePointEscapes: true | ||
globalReturn: true | ||
jsx: true | ||
rules: | ||
# 应用撇号``,不使用时不报错 | ||
quotes: | ||
- 0 | ||
- "backtick" | ||
- "avoid-escape" | ||
# 警告多空格 | ||
no-multi-spaces: | ||
- 1 | ||
- | ||
exceptions: | ||
Property: true | ||
# 警告对象内多空格 | ||
key-spacing: | ||
- 0 | ||
- | ||
align: "colon" | ||
# 警告无逗号结尾 | ||
semi: | ||
- 1 | ||
- "always" | ||
# 允许逻辑语句单行 | ||
brace-style: | ||
- 2 | ||
- "1tbs" | ||
- | ||
allowSingleLine: true | ||
# 允许逻辑语句无大括号 | ||
curly: | ||
- 1 | ||
- "multi" | ||
# 支持 alert, confirm, prompt | ||
no-alert: 0 | ||
# 警告未定义使用 | ||
no-use-before-define: 1 | ||
# 允许 constructor 首字母小写 | ||
new-cap: 1 | ||
|
||
no-unused-expressions: 0 | ||
no-unused-vars: 1 | ||
consistent-return: 0 | ||
eqeqeq: 1 | ||
no-mixed-spaces-and-tabs: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ logs | |
node_modules | ||
.idea | ||
build | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
import gulp from 'gulp'; | ||
import jade from 'gulp-jade'; | ||
import mocha from 'gulp-mocha'; | ||
import rimraf from 'gulp-rimraf'; | ||
import imagemin from 'gulp-imagemin'; | ||
import pngquant from 'imagemin-pngquant'; | ||
import webpack from 'webpack-stream'; | ||
import webpackConf from './webpack.config.js'; | ||
|
||
const NODE_ENV = process.env.NODE_ENV || 'dev'; | ||
|
||
gulp.task('clean', () => { | ||
gulp.src('build/**/*.map', {read: false}).pipe(rimraf({force: true})); | ||
}); | ||
|
||
gulp.task('move', () => { | ||
gulp.src('manifest.json').pipe(gulp.dest('build')); | ||
gulp.src('src/lib/**/*.js').pipe(gulp.dest('build/lib')); | ||
}); | ||
|
||
gulp.task('jade', () => { | ||
gulp.src(['src/tpl/popup.jade', 'src/tpl/options.jade']) | ||
.pipe(jade()) | ||
.pipe(gulp.dest('build')); | ||
}); | ||
|
||
gulp.task('imagemin', () => { | ||
gulp.src('src/img/icon.png') | ||
.pipe(imagemin({ | ||
progressive: true, | ||
svgoPlugins: [{removeViewBox: false}], | ||
use: [pngquant()] | ||
})) | ||
.pipe(gulp.dest('build/img')); | ||
}); | ||
|
||
gulp.task('webpack', () => { | ||
gulp.src('./src/script/*.js') | ||
.pipe(webpack(webpackConf)) | ||
.pipe(gulp.dest('build')); | ||
}); | ||
|
||
gulp.task('mocha', () => { | ||
gulp.src('./test/**/*.js', {read: false}) | ||
.pipe(mocha({reporter: 'nyan'})); | ||
}); | ||
|
||
gulp.task('default', ['move', 'jade', 'imagemin', 'webpack'], () => { | ||
gulp.watch(['./manifest.json'], ['move']); | ||
gulp.watch(['./src/tpl/*.jade'], ['jade']); | ||
gulp.watch(['./src/tpl/*.jade', './src/style/*.scss', './src/script/**/*.js'], ['webpack']); | ||
}); | ||
|
||
gulp.task('build', ['clean', 'move', 'jade', 'imagemin', 'webpack']); | ||
gulp.task('test', ['mocha']); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
"use strict"; | ||
|
||
{ | ||
let defaultOptions = { | ||
dblclick: true, | ||
ctrl: true | ||
}; | ||
let defaultOptions = { | ||
dblclick: true, | ||
shortcut: true, | ||
shortcut1: 17, | ||
shortcut2: null, | ||
wordbook: false | ||
}; | ||
|
||
let addYoudaoDict = function(tab) { | ||
chrome.tabs.executeScript(tab.id, { | ||
file: "js/popover.js", | ||
allFrame: true | ||
}); | ||
chrome.tabs.insertCSS(tab.id, { | ||
file: "css/popover.css", | ||
allFrame: true | ||
}); | ||
}; | ||
let addYoudaoDict = function(tab) { | ||
chrome.tabs.executeScript(tab.id, { | ||
file: "js/popover.js", | ||
allFrame: true | ||
}); | ||
chrome.tabs.insertCSS(tab.id, { | ||
file: "css/popover.css", | ||
allFrame: true | ||
}); | ||
}; | ||
|
||
let init = function(details) { | ||
if (Object.is(details.reason, 'install')) { | ||
chrome.storage.sync.set(defaultOptions); | ||
// chrome.tab.query({}, (tabs) => tabs.forEach(addYoudaoDict)); | ||
} | ||
}; | ||
let init = function(details) { | ||
if (Object.is(details.reason, 'install')) { | ||
chrome.storage.sync.set(defaultOptions); | ||
// chrome.tab.query({}, (tabs) => tabs.forEach(addYoudaoDict)); | ||
} | ||
}; | ||
|
||
chrome.runtime.onInstalled.addListener(init); | ||
} | ||
chrome.runtime.onInstalled.addListener(init); |
Oops, something went wrong.