2016-07-27 14:15:02 +08:00
|
|
|
import Vue from 'vue';
|
|
|
|
import entry from './app';
|
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import configRouter from './route.config';
|
|
|
|
import Element from 'main/index.js';
|
|
|
|
import 'packages/theme-default/src/index.css';
|
2016-08-23 16:57:58 +08:00
|
|
|
import demoBlock from './components/demo-block.vue';
|
2016-08-23 19:15:15 +08:00
|
|
|
import MainFooter from './components/footer.vue';
|
|
|
|
import MainHeader from './components/header.vue';
|
2016-08-23 14:03:45 +08:00
|
|
|
import SideNav from './components/side-nav';
|
2016-09-07 14:18:17 +08:00
|
|
|
import FooterNav from './components/footer-nav';
|
2016-08-23 14:03:45 +08:00
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
Vue.use(Element);
|
|
|
|
Vue.use(VueRouter);
|
2016-08-23 16:57:58 +08:00
|
|
|
Vue.component('demo-block', demoBlock);
|
2016-08-23 19:15:15 +08:00
|
|
|
Vue.component('main-footer', MainFooter);
|
|
|
|
Vue.component('main-header', MainHeader);
|
2016-08-23 14:03:45 +08:00
|
|
|
Vue.component('side-nav', SideNav);
|
2016-09-07 14:18:17 +08:00
|
|
|
Vue.component('footer-nav', FooterNav);
|
2016-08-23 14:03:45 +08:00
|
|
|
|
2016-08-31 11:25:02 +08:00
|
|
|
const scrollBehavior = (to, from, savedPosition) => {
|
|
|
|
if (savedPosition) {
|
|
|
|
// savedPosition is only available for popstate navigations.
|
|
|
|
return savedPosition;
|
|
|
|
} else {
|
|
|
|
// new navigation.
|
|
|
|
// scroll to anchor
|
|
|
|
if (to.hash) {
|
|
|
|
return { anchor: true };
|
|
|
|
}
|
|
|
|
// explicitly control scroll position
|
|
|
|
// check if any matched route config has meta that requires scrolling to top
|
|
|
|
if (to.matched.some(m => m.meta.scrollToTop)) {
|
|
|
|
return { x: 0, y: 0 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-07-27 17:05:28 +08:00
|
|
|
const router = new VueRouter({
|
2016-08-31 11:25:02 +08:00
|
|
|
mode: 'history',
|
2016-07-27 17:05:28 +08:00
|
|
|
base: __dirname,
|
2016-08-31 11:25:02 +08:00
|
|
|
scrollBehavior,
|
2016-07-27 17:05:28 +08:00
|
|
|
routes: configRouter
|
2016-07-27 14:15:02 +08:00
|
|
|
});
|
|
|
|
|
2016-07-27 17:05:28 +08:00
|
|
|
new Vue({ // eslint-disable-line
|
|
|
|
render: h => h(entry),
|
|
|
|
router
|
|
|
|
}).$mount('#app');
|