2018-07-02 14:57:46 +08:00
|
|
|
// polyfill
|
2018-06-26 13:12:52 +08:00
|
|
|
import 'babel-polyfill'
|
|
|
|
|
|
2018-07-02 14:57:46 +08:00
|
|
|
// Vue
|
2018-01-14 22:51:12 +08:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import App from './App'
|
2018-07-02 14:57:46 +08:00
|
|
|
|
|
|
|
|
// 多国语
|
2018-02-13 20:26:26 +08:00
|
|
|
import i18n from './i18n'
|
2018-01-14 22:51:12 +08:00
|
|
|
|
2018-07-02 10:15:20 +08:00
|
|
|
// 工具
|
|
|
|
|
import util from '@/libs/util'
|
|
|
|
|
|
2018-06-30 14:29:11 +08:00
|
|
|
// vuex
|
2018-07-02 10:15:20 +08:00
|
|
|
import store from '@/store/index'
|
2018-06-30 14:29:11 +08:00
|
|
|
|
2018-06-30 15:42:04 +08:00
|
|
|
// 路由
|
2018-06-30 14:29:11 +08:00
|
|
|
import router from './router'
|
2018-06-30 15:42:04 +08:00
|
|
|
// 框架内的路由
|
|
|
|
|
import { frameInRoutes } from '@/router/routes'
|
2018-06-30 14:29:11 +08:00
|
|
|
|
2018-07-02 14:57:46 +08:00
|
|
|
// ElementUI
|
2018-01-14 22:51:12 +08:00
|
|
|
import ElementUI from 'element-ui'
|
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css'
|
|
|
|
|
|
2018-06-27 00:48:46 +08:00
|
|
|
// v-charts
|
|
|
|
|
import VCharts from 'v-charts'
|
|
|
|
|
|
2018-01-14 22:51:12 +08:00
|
|
|
// font-awesome
|
|
|
|
|
import '@/assets/library/font-awesome-4.7.0/css/font-awesome.min.css'
|
|
|
|
|
|
|
|
|
|
// simplemde css
|
|
|
|
|
import 'simplemde/dist/simplemde.min.css'
|
|
|
|
|
|
2018-02-22 13:20:17 +08:00
|
|
|
// svg图标
|
2018-07-02 10:15:20 +08:00
|
|
|
import '@/assets/icons/index'
|
2018-02-22 13:20:17 +08:00
|
|
|
|
2018-01-14 22:51:12 +08:00
|
|
|
// markdown主题
|
|
|
|
|
import 'github-markdown-css'
|
|
|
|
|
|
|
|
|
|
// 代码高亮主题
|
|
|
|
|
import '@/assets/library/highlight/styles/atom-one-light.css'
|
|
|
|
|
|
|
|
|
|
// 全局注册的组件
|
|
|
|
|
import '@/components'
|
|
|
|
|
|
|
|
|
|
// 异步请求库
|
|
|
|
|
import '@/plugin/axios'
|
|
|
|
|
|
2018-01-15 19:00:38 +08:00
|
|
|
// mock接口设置
|
2018-02-19 10:02:47 +08:00
|
|
|
import '@/mock/register'
|
2018-01-15 19:00:38 +08:00
|
|
|
|
2018-06-19 23:35:29 +08:00
|
|
|
// 右键菜单
|
|
|
|
|
import contentmenu from 'v-contextmenu'
|
|
|
|
|
import 'v-contextmenu/dist/index.css'
|
|
|
|
|
|
2018-02-10 21:18:53 +08:00
|
|
|
// 插件 导出文件
|
2018-02-15 15:30:00 +08:00
|
|
|
import pluginImport from '@/plugin/import'
|
|
|
|
|
// 插件 导出文件
|
2018-02-10 21:18:53 +08:00
|
|
|
import pluginExport from '@/plugin/export'
|
2018-06-12 11:04:16 +08:00
|
|
|
// 插件 log简化
|
|
|
|
|
import pluginLog from '@/plugin/log'
|
|
|
|
|
// 插件 打开页面
|
|
|
|
|
import pluginOpen from '@/plugin/open'
|
2018-06-13 15:13:27 +08:00
|
|
|
// 插件 支持百万级数据的表格
|
|
|
|
|
import bigdataTable from '@/plugin/vue-bigdata-table'
|
2018-07-02 22:42:56 +08:00
|
|
|
// 插件 json 展示
|
|
|
|
|
import vueJsonTreeView from 'vue-json-tree-view'
|
2018-01-25 20:26:12 +08:00
|
|
|
|
2018-06-30 19:59:04 +08:00
|
|
|
// 打包的设置 用户获取路径
|
2018-06-22 01:15:28 +08:00
|
|
|
import buildConfig from '../config/index'
|
|
|
|
|
|
2018-01-14 22:51:12 +08:00
|
|
|
Vue.use(ElementUI)
|
2018-06-27 00:48:46 +08:00
|
|
|
Vue.use(VCharts)
|
2018-06-19 23:35:29 +08:00
|
|
|
Vue.use(contentmenu)
|
2018-01-14 22:51:12 +08:00
|
|
|
|
2018-02-15 15:30:00 +08:00
|
|
|
Vue.use(pluginImport)
|
2018-02-10 21:18:53 +08:00
|
|
|
Vue.use(pluginExport)
|
2018-06-12 11:04:16 +08:00
|
|
|
Vue.use(pluginLog)
|
|
|
|
|
Vue.use(pluginOpen)
|
2018-06-13 15:13:27 +08:00
|
|
|
Vue.use(bigdataTable)
|
2018-07-02 22:42:56 +08:00
|
|
|
Vue.use(vueJsonTreeView)
|
2018-01-25 20:26:12 +08:00
|
|
|
|
2018-01-14 22:51:12 +08:00
|
|
|
Vue.config.productionTip = false
|
|
|
|
|
|
2018-07-02 12:07:44 +08:00
|
|
|
Vue.prototype.$env = process.env.NODE_ENV
|
2018-05-26 20:53:56 +08:00
|
|
|
|
2018-06-22 01:15:28 +08:00
|
|
|
Vue.prototype.$assetsPublicPath = process.env.NODE_ENV === 'development' ? buildConfig.dev.assetsPublicPath : buildConfig.build.assetsPublicPath
|
|
|
|
|
|
2018-01-14 22:51:12 +08:00
|
|
|
/* eslint-disable no-new */
|
|
|
|
|
new Vue({
|
|
|
|
|
el: '#app',
|
|
|
|
|
store,
|
2018-02-13 20:26:26 +08:00
|
|
|
i18n,
|
2018-01-14 22:51:12 +08:00
|
|
|
router,
|
|
|
|
|
template: '<App/>',
|
2018-06-30 15:42:04 +08:00
|
|
|
components: { App },
|
|
|
|
|
created () {
|
|
|
|
|
// 处理路由 得到每一级的路由设置
|
|
|
|
|
this.getAllTagFromRoutes()
|
|
|
|
|
},
|
2018-07-02 10:15:20 +08:00
|
|
|
mounted () {
|
2018-07-03 15:17:18 +08:00
|
|
|
// DB -> store 加载用户名
|
|
|
|
|
this.$store.commit('d2adminUsernameLoad')
|
2018-07-02 21:42:55 +08:00
|
|
|
// DB -> store 加载版本更新弹窗的设置
|
|
|
|
|
this.$store.commit('d2adminUpdateNotifyLoad')
|
|
|
|
|
// DB -> store 加载主题
|
|
|
|
|
this.$store.commit('d2adminThemeLoad')
|
|
|
|
|
// DB -> store 数据库加载上次退出时的多页列表
|
2018-07-02 16:10:32 +08:00
|
|
|
this.$store.commit('d2adminPageOpenedListLoad')
|
2018-07-02 12:07:44 +08:00
|
|
|
// D2Admin 开发环境检查更新
|
2018-07-02 12:18:28 +08:00
|
|
|
util.checkUpdate(this)
|
2018-07-02 10:15:20 +08:00
|
|
|
},
|
2018-06-30 15:42:04 +08:00
|
|
|
methods: {
|
|
|
|
|
/**
|
|
|
|
|
* 处理路由 得到每一级的路由设置
|
|
|
|
|
*/
|
|
|
|
|
getAllTagFromRoutes () {
|
2018-06-30 19:29:01 +08:00
|
|
|
// 所有加载在主框架内的页面
|
2018-06-30 16:45:06 +08:00
|
|
|
const tagPool = []
|
2018-06-30 15:42:04 +08:00
|
|
|
const push = function (routes) {
|
|
|
|
|
routes.forEach(route => {
|
|
|
|
|
if (route.children) {
|
|
|
|
|
push(route.children)
|
|
|
|
|
} else {
|
2018-07-03 14:28:18 +08:00
|
|
|
const { meta, name, path } = route
|
|
|
|
|
tagPool.push({ meta, name, path })
|
2018-06-30 15:42:04 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
push(frameInRoutes)
|
2018-06-30 19:29:01 +08:00
|
|
|
this.$store.commit('d2adminTagPoolSet', tagPool)
|
2018-06-30 15:42:04 +08:00
|
|
|
}
|
|
|
|
|
}
|
2018-01-14 22:51:12 +08:00
|
|
|
})
|