element/examples/entry.js

54 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-07-27 14:15:02 +08:00
import Vue from 'vue';
import entry from './app';
import VueRouter from 'vue-router';
import Element from 'main/index.js';
import hljs from 'highlight.js';
2017-10-23 17:50:25 +08:00
import routes from './route.config';
import demoBlock from './components/demo-block';
import MainFooter from './components/footer';
import MainHeader from './components/header';
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';
import title from './i18n/title';
2016-08-23 14:03:45 +08:00
import 'packages/theme-chalk/src/index.scss';
import './demo-styles/index.scss';
import './assets/styles/common.css';
import './assets/styles/fonts/style.css';
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-07-27 17:05:28 +08:00
const router = new VueRouter({
2016-09-08 18:11:18 +08:00
mode: 'hash',
2016-07-27 17:05:28 +08:00
base: __dirname,
routes
2016-07-27 14:15:02 +08:00
});
2016-11-14 18:31:49 +08:00
router.afterEach(route => {
// https://github.com/highlightjs/highlight.js/issues/909#issuecomment-131686186
Vue.nextTick(() => {
const blocks = document.querySelectorAll('pre code:not(.hljs)');
Array.prototype.forEach.call(blocks, hljs.highlightBlock);
});
2016-11-22 10:22:20 +08:00
const data = title[route.meta.lang];
for (let val in data) {
if (new RegExp('^' + val, 'g').test(route.name)) {
document.title = data[val];
return;
}
}
document.title = 'Element';
ga('send', 'event', 'PageView', route.name);
2016-11-14 18:31:49 +08:00
});
2016-07-27 17:05:28 +08:00
new Vue({ // eslint-disable-line
...entry,
2016-07-27 17:05:28 +08:00
router
}).$mount('#app');