2016-07-27 06:15:02 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import entry from './app';
|
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import Element from 'main/index.js';
|
2019-03-01 10:35:08 +00:00
|
|
|
import hljs from 'highlight.js';
|
2017-10-23 09:50:25 +00:00
|
|
|
import routes from './route.config';
|
2019-01-23 03:34:19 +00:00
|
|
|
import demoBlock from './components/demo-block';
|
|
|
|
import MainFooter from './components/footer';
|
|
|
|
import MainHeader from './components/header';
|
2016-08-23 06:03:45 +00:00
|
|
|
import SideNav from './components/side-nav';
|
2016-09-07 06:18:17 +00:00
|
|
|
import FooterNav from './components/footer-nav';
|
2019-01-23 03:34:19 +00:00
|
|
|
import title from './i18n/title';
|
2016-08-23 06:03:45 +00:00
|
|
|
|
2019-02-26 08:23:26 +00:00
|
|
|
import 'packages/theme-chalk/src/index.scss';
|
2019-03-01 10:35:08 +00:00
|
|
|
import './demo-styles/index.scss';
|
2019-02-26 08:23:26 +00:00
|
|
|
import './assets/styles/common.css';
|
|
|
|
import './assets/styles/fonts/style.css';
|
2019-04-25 04:19:38 +00:00
|
|
|
import icon from './icon.json';
|
2019-02-26 08:23:26 +00:00
|
|
|
|
2016-07-27 06:15:02 +00:00
|
|
|
Vue.use(Element);
|
|
|
|
Vue.use(VueRouter);
|
2016-08-23 08:57:58 +00:00
|
|
|
Vue.component('demo-block', demoBlock);
|
2016-08-23 11:15:15 +00:00
|
|
|
Vue.component('main-footer', MainFooter);
|
|
|
|
Vue.component('main-header', MainHeader);
|
2016-08-23 06:03:45 +00:00
|
|
|
Vue.component('side-nav', SideNav);
|
2016-09-07 06:18:17 +00:00
|
|
|
Vue.component('footer-nav', FooterNav);
|
2016-08-23 06:03:45 +00:00
|
|
|
|
2019-04-30 09:52:18 +00:00
|
|
|
const globalEle = new Vue({
|
|
|
|
data: { $isEle: false } // 是否 ele 用户
|
|
|
|
});
|
|
|
|
|
|
|
|
Vue.mixin({
|
|
|
|
computed: {
|
|
|
|
$isEle: {
|
|
|
|
get: () => (globalEle.$data.$isEle),
|
|
|
|
set: (data) => {globalEle.$data.$isEle = data;}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-04-25 04:19:38 +00:00
|
|
|
Vue.prototype.$icon = icon; // Icon 列表页用
|
|
|
|
|
2016-07-27 09:05:28 +00:00
|
|
|
const router = new VueRouter({
|
2016-09-08 10:11:18 +00:00
|
|
|
mode: 'hash',
|
2016-07-27 09:05:28 +00:00
|
|
|
base: __dirname,
|
2016-11-10 13:46:55 +00:00
|
|
|
routes
|
2016-07-27 06:15:02 +00:00
|
|
|
});
|
|
|
|
|
2016-11-14 10:31:49 +00:00
|
|
|
router.afterEach(route => {
|
2019-03-01 10:35:08 +00:00
|
|
|
// 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 02:22:20 +00: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';
|
2019-03-13 11:46:03 +00:00
|
|
|
ga('send', 'event', 'PageView', route.name);
|
2016-11-14 10:31:49 +00:00
|
|
|
});
|
|
|
|
|
2016-07-27 09:05:28 +00:00
|
|
|
new Vue({ // eslint-disable-line
|
2019-01-23 03:34:19 +00:00
|
|
|
...entry,
|
2016-07-27 09:05:28 +00:00
|
|
|
router
|
|
|
|
}).$mount('#app');
|