Skip to content

Commit e713264

Browse files
committed
format code
1 parent f4ee9ef commit e713264

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed

.babelrc

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
{
22
"presets": [
3-
["env", { "modules": false }],
3+
[
4+
"env",
5+
{
6+
"modules": false
7+
}
8+
],
49
"stage-2"
510
],
611
"comments": false,
712
"env": {
813
"test": {
9-
"presets": ["env", "stage-2"],
10-
"plugins": [ "istanbul" ]
14+
"presets": [
15+
"env",
16+
"stage-2"
17+
],
18+
"plugins": [
19+
"istanbul"
20+
]
1121
}
1222
}
1323
}

build/build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const targets = [
4747
rollup.rollup(inputOptions).then(bundle => {
4848
const size = code => filesize(Buffer.byteLength(code))
4949
console.info('\nfiles size:')
50-
targets.forEach(({name, options, uglify}) => {
50+
targets.forEach(({ name, options, uglify }) => {
5151
const code = bundle.generate(options).code
5252
console.info(`${name}.js ${size(code)}`)
5353
fs.writeFileSync(`dist/${name}.js`, code, 'utf8')

examples/build/dev-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var devMiddleware = require('webpack-dev-middleware')(compiler, {
2828
})
2929

3030
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
31-
log: () => {}
31+
log: () => { }
3232
})
3333
// force page reload when html-webpack-Plugin template changes
3434
compiler.plugin('compilation', function (compilation) {

src/components/navigation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Routes from '../routes'
2-
import {getKey, matches} from '../utils'
2+
import { getKey, matches } from '../utils'
33

44
export default (keyName) => {
55
return {

src/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Routes from './routes'
22
import Navigator from './navigator'
33
import NavComponent from './components/navigation'
4-
import {genKey} from './utils'
4+
import { genKey } from './utils'
55

66
export default {
7-
install: (Vue, {router, store, moduleName = 'navigation', keyName = 'VNK'} = {}) => {
7+
install: (Vue, { router, store, moduleName = 'navigation', keyName = 'VNK' } = {}) => {
88
if (!router) {
99
console.error('vue-navigation need options: router')
1010
return
@@ -24,9 +24,9 @@ export default {
2424
// init router`s keyName
2525
router.beforeEach((to, from, next) => {
2626
if (!to.query[keyName]) {
27-
const query = {...to.query}
27+
const query = { ...to.query }
2828
query[keyName] = genKey()
29-
next({path: to.path, query, replace: replaceFlag || !from.query[keyName]})
29+
next({ path: to.path, query, replace: replaceFlag || !from.query[keyName] })
3030
} else {
3131
next()
3232
}

src/navigator.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Routes from './routes'
2-
import {getKey} from './utils'
2+
import { getKey } from './utils'
33

44
export default (bus, store, moduleName, keyName) => {
55
if (store) {
@@ -8,16 +8,16 @@ export default (bus, store, moduleName, keyName) => {
88
routes: Routes
99
},
1010
mutations: {
11-
'navigation/FORWARD': (state, {to, from, name}) => {
11+
'navigation/FORWARD': (state, { to, from, name }) => {
1212
state.routes.push(name)
1313
},
14-
'navigation/BACK': (state, {to, from, count}) => {
14+
'navigation/BACK': (state, { to, from, count }) => {
1515
state.routes.splice(state.routes.length - count, count)
1616
},
17-
'navigation/REPLACE': (state, {to, from, name}) => {
17+
'navigation/REPLACE': (state, { to, from, name }) => {
1818
state.routes.splice(Routes.length - 1, 1, name)
1919
},
20-
'navigation/REFRESH': (state, {to, from}) => {
20+
'navigation/REFRESH': (state, { to, from }) => {
2121
},
2222
'navigation/RESET': (state) => {
2323
state.routes.splice(0, state.routes.length)
@@ -27,43 +27,43 @@ export default (bus, store, moduleName, keyName) => {
2727
}
2828

2929
const forward = (name, toRoute, fromRoute) => {
30-
const to = {route: toRoute}
31-
const from = {route: fromRoute}
30+
const to = { route: toRoute }
31+
const from = { route: fromRoute }
3232
const routes = store ? store.state[moduleName].routes : Routes
3333
// if from does not exist, it will be set null
3434
from.name = routes[routes.length - 1] || null
3535
to.name = name
36-
store ? store.commit('navigation/FORWARD', {to, from, name}) : routes.push(name)
36+
store ? store.commit('navigation/FORWARD', { to, from, name }) : routes.push(name)
3737
window.sessionStorage.VUE_NAVIGATION = JSON.stringify(routes)
3838
bus.$emit('forward', to, from)
3939
}
4040
const back = (count, toRoute, fromRoute) => {
41-
const to = {route: toRoute}
42-
const from = {route: fromRoute}
41+
const to = { route: toRoute }
42+
const from = { route: fromRoute }
4343
const routes = store ? store.state[moduleName].routes : Routes
4444
from.name = routes[routes.length - 1]
4545
to.name = routes[routes.length - 1 - count]
46-
store ? store.commit('navigation/BACK', {to, from, count}) : routes.splice(Routes.length - count, count)
46+
store ? store.commit('navigation/BACK', { to, from, count }) : routes.splice(Routes.length - count, count)
4747
window.sessionStorage.VUE_NAVIGATION = JSON.stringify(routes)
4848
bus.$emit('back', to, from)
4949
}
5050
const replace = (name, toRoute, fromRoute) => {
51-
const to = {route: toRoute}
52-
const from = {route: fromRoute}
51+
const to = { route: toRoute }
52+
const from = { route: fromRoute }
5353
const routes = store ? store.state[moduleName].routes : Routes
5454
// if from does not exist, it will be set null
5555
from.name = routes[routes.length - 1] || null
5656
to.name = name
57-
store ? store.commit('navigation/REPLACE', {to, from, name}) : routes.splice(Routes.length - 1, 1, name)
57+
store ? store.commit('navigation/REPLACE', { to, from, name }) : routes.splice(Routes.length - 1, 1, name)
5858
window.sessionStorage.VUE_NAVIGATION = JSON.stringify(routes)
5959
bus.$emit('replace', to, from)
6060
}
6161
const refresh = (toRoute, fromRoute) => {
62-
const to = {route: toRoute}
63-
const from = {route: fromRoute}
62+
const to = { route: toRoute }
63+
const from = { route: fromRoute }
6464
const routes = store ? store.state[moduleName].routes : Routes
6565
to.name = from.name = routes[routes.length - 1]
66-
store ? store.commit('navigation/REFRESH', {to, from}) : null
66+
store ? store.commit('navigation/REFRESH', { to, from }) : null
6767
bus.$emit('refresh', to, from)
6868
}
6969
const reset = () => {

0 commit comments

Comments
 (0)