2020-09-16 08:27:46 +08:00
|
|
|
import { createApp, nextTick } from 'vue'
|
2020-08-13 15:18:26 +08:00
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
|
|
|
import routes from './route.config'
|
|
|
|
import demoBlock from './components/demo-block'
|
|
|
|
import MainFooter from './components/footer'
|
|
|
|
import MainHeader from './components/header'
|
|
|
|
import SideNav from './components/side-nav'
|
|
|
|
import FooterNav from './components/footer-nav'
|
|
|
|
import title from './i18n/title'
|
2020-09-16 08:27:46 +08:00
|
|
|
import 'highlight.js/styles/color-brewer.css'
|
2020-08-13 15:18:26 +08:00
|
|
|
import './demo-styles/index.scss'
|
|
|
|
import './assets/styles/common.css'
|
|
|
|
import './assets/styles/fonts/style.css'
|
|
|
|
import icon from './icon.json'
|
2020-09-16 14:49:47 +08:00
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import 'dayjs/locale/zh-cn'
|
|
|
|
dayjs.locale('zh-cn') // todo: locale based on Doc site lang
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
import App from './app.vue'
|
2020-09-15 17:12:16 +08:00
|
|
|
import ElementPlus from 'element-plus'
|
2020-08-25 09:58:26 +08:00
|
|
|
if(process.env.NODE_ENV === 'development') require('../src/style/element-ui@2.13.2.css')
|
|
|
|
|
2020-08-13 15:18:26 +08:00
|
|
|
const app = createApp(App)
|
|
|
|
|
|
|
|
app.config.globalProperties.$icon = icon
|
|
|
|
|
|
|
|
app.component('DemoBlock', demoBlock)
|
|
|
|
app.component('MainFooter', MainFooter)
|
|
|
|
app.component('MainHeader', MainHeader)
|
|
|
|
app.component('SideNav', SideNav)
|
|
|
|
app.component('FooterNav', FooterNav)
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
history: createWebHashHistory(),
|
|
|
|
routes,
|
|
|
|
})
|
2020-09-15 17:12:16 +08:00
|
|
|
app.use(ElementPlus)
|
2020-08-13 15:18:26 +08:00
|
|
|
app.use(router)
|
|
|
|
router.isReady().then(()=>{
|
|
|
|
|
|
|
|
router.afterEach(async route => {
|
|
|
|
await nextTick()
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
app.mount('#app')
|