2019-01-12 03:33:27 +00:00
|
|
|
import 'babel-polyfill';
|
|
|
|
import '../components/style.js';
|
|
|
|
import './index.less';
|
2019-01-12 10:52:58 +00:00
|
|
|
import 'nprogress/nprogress.css';
|
2019-01-12 03:33:27 +00:00
|
|
|
import 'highlight.js/styles/solarized-light.css';
|
|
|
|
import Vue from 'vue';
|
2019-02-11 14:22:15 +00:00
|
|
|
import Vuex from 'vuex';
|
2019-01-12 03:33:27 +00:00
|
|
|
import VueI18n from 'vue-i18n';
|
|
|
|
import VueRouter from 'vue-router';
|
|
|
|
import VueClipboard from 'vue-clipboard2';
|
2019-01-16 05:24:47 +00:00
|
|
|
import NProgress from 'nprogress';
|
2019-01-12 03:33:27 +00:00
|
|
|
import routes from './routes';
|
|
|
|
import Md from './components/md';
|
|
|
|
import Api from './components/api';
|
|
|
|
import './components';
|
|
|
|
import demoBox from './components/demoBox';
|
|
|
|
import demoContainer from './components/demoContainer';
|
|
|
|
import zhCN from './theme/zh-CN';
|
|
|
|
import enUS from './theme/en-US';
|
|
|
|
import { isZhCN } from './util';
|
2018-04-04 10:39:21 +00:00
|
|
|
|
2018-07-14 09:59:25 +00:00
|
|
|
const mountedCallback = {
|
|
|
|
install: (Vue, options) => {
|
|
|
|
Vue.directive('mountedCallback', {
|
2019-01-12 03:33:27 +00:00
|
|
|
inserted: function(el, binding, vnode) {
|
|
|
|
binding.value(vnode);
|
2018-07-14 09:59:25 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-07-14 09:59:25 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-07-14 09:59:25 +00:00
|
|
|
|
2019-02-11 14:22:15 +00:00
|
|
|
Vue.use(Vuex);
|
2019-01-12 03:33:27 +00:00
|
|
|
Vue.use(mountedCallback);
|
|
|
|
Vue.use(VueClipboard);
|
|
|
|
Vue.use(VueRouter);
|
|
|
|
Vue.use(VueI18n);
|
|
|
|
Vue.component(Md.name, Md);
|
|
|
|
Vue.component(Api.name, Api);
|
|
|
|
Vue.component('demo-box', demoBox);
|
|
|
|
Vue.component('demo-container', demoContainer);
|
2018-04-04 10:39:21 +00:00
|
|
|
|
2018-11-27 10:25:38 +00:00
|
|
|
const i18n = new VueI18n({
|
|
|
|
locale: isZhCN(location.pathname) ? zhCN.locale : enUS.locale,
|
|
|
|
messages: {
|
|
|
|
[enUS.locale]: { message: enUS.messages },
|
|
|
|
[zhCN.locale]: { message: zhCN.messages },
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-11-27 10:25:38 +00:00
|
|
|
|
2018-04-04 10:39:21 +00:00
|
|
|
const router = new VueRouter({
|
|
|
|
mode: 'history',
|
2018-07-28 05:43:23 +00:00
|
|
|
fallback: false,
|
2018-04-04 10:39:21 +00:00
|
|
|
routes,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2019-01-16 05:24:47 +00:00
|
|
|
router.beforeEach((to, from, next) => {
|
2019-01-17 03:59:21 +00:00
|
|
|
if (to.path !== from.path) {
|
|
|
|
NProgress.start();
|
|
|
|
}
|
2019-01-16 05:24:47 +00:00
|
|
|
next();
|
|
|
|
});
|
2019-02-11 14:22:15 +00:00
|
|
|
|
|
|
|
const store = new Vuex.Store({
|
|
|
|
state: {
|
|
|
|
username: 'zeka',
|
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
update(state, payload) {
|
|
|
|
state.username = payload.username;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-04-04 10:39:21 +00:00
|
|
|
new Vue({
|
|
|
|
el: '#app',
|
2018-11-27 10:25:38 +00:00
|
|
|
i18n,
|
2018-04-04 10:39:21 +00:00
|
|
|
router,
|
2019-02-11 14:22:15 +00:00
|
|
|
store,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|