main.js 1.2 KB
Newer Older
yma16's avatar
yma16 已提交
1 2 3 4
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
yma16's avatar
yma16 已提交
5
import VueRouter from 'vue-router'
yma16's avatar
yma16 已提交
6 7
import cookies from 'vue-cookies'
import hljs from 'highlight.js'
yma16's avatar
yma16 已提交
8 9
import useRouter from './router'
import axios from 'axios'
yma16's avatar
yma16 已提交
10 11 12
import importElementComponents from './importElement'
import importEchartsComponents from './importEchartsComponents'

yma16's avatar
yma16 已提交
13 14 15 16 17
// 样式
import 'github-markdown-css/github-markdown.css'
import 'highlight.js/styles/github.css'
import 'nprogress/nprogress.css'

18
// 路由
yma16's avatar
yma16 已提交
19
const router = useRouter(Vue, VueRouter)
20

yma16's avatar
yma16 已提交
21
// 按需引入elementui
22
importElementComponents(Vue)
yma16's avatar
yma16 已提交
23

24 25
// 按需引入echarts
importEchartsComponents(Vue)
yma16's avatar
yma16 已提交
26 27 28 29

Vue.config.productionTip = false
Vue.use(cookies)

yma16's avatar
yma16 已提交
30
Vue.use(hljs)
31
Vue.directive('highlight', function (el) {
yma16's avatar
yma16 已提交
32 33 34 35 36
    const blocks = el.querySelectorAll('pre code')
    blocks.forEach(block => {
        hljs.highlightBlock(block)
    })
})
yma16's avatar
yma16 已提交
37
// cookie
yma16's avatar
yma16 已提交
38
Vue.prototype.$cookies = cookies
yma16's avatar
yma16 已提交
39 40
// axios
Vue.prototype.$axios = axios
yma16's avatar
yma16 已提交
41

42
Vue.prototype.$cookies.set('user_session', 'null')
yma16's avatar
yma16 已提交
43 44 45 46 47 48

new Vue({
    el: '#app',
    router,
    components: { App },
    template: '<App/>'
yma16's avatar
yma16 已提交
49
})