2018-07-16 22:22:55 +08:00
|
|
|
import 'babel-polyfill'
|
2018-07-16 10:54:24 +08:00
|
|
|
import Vue from 'vue'
|
2018-07-16 22:22:55 +08:00
|
|
|
import App from './App'
|
2018-07-31 13:02:50 +08:00
|
|
|
// flex.css
|
|
|
|
|
import 'flex.css'
|
2018-07-16 22:22:55 +08:00
|
|
|
import ElementUI from 'element-ui'
|
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css'
|
|
|
|
|
import VCharts from 'v-charts'
|
|
|
|
|
import screenfull from 'screenfull'
|
|
|
|
|
import contentmenu from 'v-contextmenu'
|
|
|
|
|
import 'v-contextmenu/dist/index.css'
|
|
|
|
|
import vueJsonTreeView from 'vue-json-tree-view'
|
|
|
|
|
import i18n from './i18n'
|
2018-07-24 11:02:51 +08:00
|
|
|
import util from '@/libs/util.js'
|
2018-07-16 22:22:55 +08:00
|
|
|
import store from '@/store/index'
|
2018-07-17 16:29:40 +08:00
|
|
|
import '@/assets/svg-icons'
|
2018-07-16 22:22:55 +08:00
|
|
|
import '@/components'
|
|
|
|
|
import '@/plugin/axios'
|
|
|
|
|
import '@/mock/register'
|
|
|
|
|
import pluginImport from '@/plugin/import'
|
|
|
|
|
import pluginExport from '@/plugin/export'
|
|
|
|
|
import pluginOpen from '@/plugin/open'
|
2018-07-25 22:17:41 +08:00
|
|
|
|
|
|
|
|
// 菜单和路由设置
|
2018-07-16 10:54:24 +08:00
|
|
|
import router from './router'
|
2018-07-25 22:17:41 +08:00
|
|
|
import { menuHeader, menuAside } from '@/menu'
|
|
|
|
|
import { frameInRoutes } from '@/router/routes'
|
2018-07-16 22:22:55 +08:00
|
|
|
|
|
|
|
|
Vue.use(ElementUI)
|
|
|
|
|
Vue.use(VCharts)
|
|
|
|
|
Vue.use(contentmenu)
|
|
|
|
|
Vue.use(pluginImport)
|
|
|
|
|
Vue.use(pluginExport)
|
|
|
|
|
Vue.use(pluginOpen)
|
|
|
|
|
Vue.use(vueJsonTreeView)
|
2018-07-16 10:54:24 +08:00
|
|
|
|
|
|
|
|
Vue.config.productionTip = false
|
|
|
|
|
|
2018-07-16 22:22:55 +08:00
|
|
|
Vue.prototype.$env = process.env.NODE_ENV
|
|
|
|
|
Vue.prototype.$baseUrl = process.env.BASE_URL
|
|
|
|
|
|
2018-07-16 10:54:24 +08:00
|
|
|
new Vue({
|
|
|
|
|
router,
|
|
|
|
|
store,
|
2018-07-16 22:22:55 +08:00
|
|
|
i18n,
|
|
|
|
|
render: h => h(App),
|
|
|
|
|
created () {
|
|
|
|
|
// 处理路由 得到每一级的路由设置
|
2018-07-25 09:43:27 +08:00
|
|
|
this.getAllPageFromRoutes()
|
2018-07-17 22:49:13 +08:00
|
|
|
// 设置顶栏菜单
|
2018-07-23 23:05:14 +08:00
|
|
|
this.$store.commit('d2adminMenuHeaderSet', menuHeader)
|
2018-07-16 22:22:55 +08:00
|
|
|
},
|
|
|
|
|
mounted () {
|
2018-07-17 23:59:20 +08:00
|
|
|
// D2Admin 开发环境检查更新
|
|
|
|
|
util.checkUpdate(this)
|
2018-07-21 08:47:51 +08:00
|
|
|
// 获取并记录用户 UA
|
|
|
|
|
this.$store.commit('d2adminUaGet')
|
2018-07-17 23:59:20 +08:00
|
|
|
// 展示系统信息
|
2018-07-16 22:22:55 +08:00
|
|
|
util.showInfo()
|
2018-07-18 13:57:52 +08:00
|
|
|
// 用户登陆后从数据库加载一系列的设置
|
|
|
|
|
this.$store.commit('d2adminLoginSuccessLoad')
|
2018-07-16 22:22:55 +08:00
|
|
|
// 初始化全屏监听
|
|
|
|
|
this.fullscreenListenerInit()
|
|
|
|
|
},
|
2018-07-17 22:49:13 +08:00
|
|
|
watch: {
|
|
|
|
|
// 监听路由 控制侧边栏显示
|
|
|
|
|
'$route.matched' (val) {
|
2018-07-23 23:05:14 +08:00
|
|
|
const _side = menuAside.filter(menu => menu.path === val[0].path)
|
|
|
|
|
this.$store.commit('d2adminMenuAsideSet', _side.length > 0 ? _side[0].children : [])
|
2018-07-17 22:49:13 +08:00
|
|
|
}
|
|
|
|
|
},
|
2018-07-16 22:22:55 +08:00
|
|
|
methods: {
|
|
|
|
|
/**
|
|
|
|
|
* 初始化全屏监听
|
|
|
|
|
*/
|
|
|
|
|
fullscreenListenerInit () {
|
|
|
|
|
if (screenfull.enabled) {
|
|
|
|
|
screenfull.on('change', () => {
|
|
|
|
|
if (!screenfull.isFullscreen) {
|
|
|
|
|
this.$store.commit('d2adminFullScreenSet', false)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/**
|
2018-07-25 09:43:27 +08:00
|
|
|
* 处理路由 得到所有的页面
|
2018-07-16 22:22:55 +08:00
|
|
|
*/
|
2018-07-25 09:43:27 +08:00
|
|
|
getAllPageFromRoutes () {
|
2018-07-16 22:22:55 +08:00
|
|
|
const pool = []
|
|
|
|
|
const push = function (routes) {
|
|
|
|
|
routes.forEach(route => {
|
|
|
|
|
if (route.children) {
|
|
|
|
|
push(route.children)
|
|
|
|
|
} else {
|
|
|
|
|
const { meta, name, path } = route
|
|
|
|
|
pool.push({ meta, name, path })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
push(frameInRoutes)
|
2018-07-25 09:43:27 +08:00
|
|
|
this.$store.commit('d2adminPagePoolSet', pool)
|
2018-07-16 22:22:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
2018-07-16 10:54:24 +08:00
|
|
|
}).$mount('#app')
|