2019-05-17 18:23:03 +08:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import ElementUI from 'element-ui'
|
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css'
|
|
|
|
|
import App from './App.vue'
|
|
|
|
|
|
|
|
|
|
import VueRouter from 'vue-router'
|
|
|
|
|
import routes from './routes'
|
2020-05-29 22:38:25 +08:00
|
|
|
import store from './store/index'
|
2019-05-17 18:23:03 +08:00
|
|
|
import axios from 'axios'
|
|
|
|
|
import VueAxios from 'vue-axios'
|
2022-12-26 16:03:31 +08:00
|
|
|
// 注册一个全局自定义指令
|
|
|
|
|
import hljs from 'highlight.js'
|
|
|
|
|
import 'highlight.js/styles/googlecode.css'
|
2019-05-17 18:23:03 +08:00
|
|
|
|
|
|
|
|
Vue.use(ElementUI);
|
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
|
Vue.use(VueAxios, axios);
|
|
|
|
|
|
|
|
|
|
// 公用方法
|
2020-05-29 22:38:25 +08:00
|
|
|
Vue.prototype.$store = store;
|
2022-12-26 16:03:31 +08:00
|
|
|
// 路由重复点击报错处理
|
|
|
|
|
const originalPush = VueRouter.prototype.push
|
|
|
|
|
VueRouter.prototype.push = function push(location) {
|
|
|
|
|
return originalPush.call(this, location).catch(err => err)
|
|
|
|
|
}
|
2019-05-17 18:23:03 +08:00
|
|
|
|
|
|
|
|
const router = new VueRouter({routes});
|
|
|
|
|
// 路由跳转时判断处理
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
2022-12-26 16:03:31 +08:00
|
|
|
if (to.name) {
|
|
|
|
|
document.title = to.name;
|
|
|
|
|
}
|
|
|
|
|
next();
|
2019-05-17 18:23:03 +08:00
|
|
|
});
|
2020-05-29 22:43:20 +08:00
|
|
|
|
2022-12-26 16:03:31 +08:00
|
|
|
|
|
|
|
|
|
2020-05-29 22:38:25 +08:00
|
|
|
let vue = new Vue({
|
2022-12-26 16:03:31 +08:00
|
|
|
el: '#app',
|
|
|
|
|
router,
|
|
|
|
|
render(h) {
|
|
|
|
|
return h(App);
|
|
|
|
|
}
|
2019-05-17 18:23:03 +08:00
|
|
|
});
|
2021-11-01 22:44:11 +08:00
|
|
|
|
|
|
|
|
Vue.directive('highlight', function (el) {
|
|
|
|
|
let blocks = el.querySelectorAll('pre code');
|
|
|
|
|
blocks.forEach((block) => {
|
|
|
|
|
hljs.highlightBlock(block);
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
2020-05-29 22:38:25 +08:00
|
|
|
export default vue;
|
2019-05-17 18:23:03 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|