Рефакторинг маршрутов
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from 'vue-router';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
import App from './components/App.vue';
|
import App from './components/App.vue';
|
||||||
import CardIndex from './components/CardIndex/CardIndex.vue';
|
import CardIndex from './components/CardIndex/CardIndex.vue';
|
||||||
import Reader from './components/Reader/Reader.vue';
|
import Reader from './components/Reader/Reader.vue';
|
||||||
@@ -10,19 +12,27 @@ import Settings from './components/Settings/Settings.vue';
|
|||||||
import Help from './components/Help/Help.vue';
|
import Help from './components/Help/Help.vue';
|
||||||
import NotFound404 from './components/NotFound404/NotFound404.vue';
|
import NotFound404 from './components/NotFound404/NotFound404.vue';
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
const myRoutes = [
|
||||||
|
['/', null, null, '/cardindex'],
|
||||||
let routes = [
|
['/cardindex', CardIndex ],
|
||||||
{ path: '/', redirect: '/cardindex' },
|
['/reader', Reader ],
|
||||||
{ path: '/cardindex', component: CardIndex },
|
['/income', Income ],
|
||||||
{ path: '/reader', component: Reader },
|
['/sources', Sources ],
|
||||||
{ path: '/income', component: Income },
|
['/settings', Settings ],
|
||||||
{ path: '/sources', component: Sources },
|
['/help', Help ],
|
||||||
{ path: '/settings', component: Settings },
|
['*', NotFound404 ],
|
||||||
{ path: '/help', component: Help },
|
|
||||||
{ path: '*', component: NotFound404 },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let routes = [];
|
||||||
|
|
||||||
|
for (let route of myRoutes) {
|
||||||
|
const [path, component, name, redirect] = route;
|
||||||
|
let r = _.pickBy({path, component, name, redirect}, _.identity);
|
||||||
|
routes.push(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
export default new VueRouter({
|
export default new VueRouter({
|
||||||
routes
|
routes
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user