main.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // The Vue build version to load with the `import` command
  2. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  3. import Vue from 'vue'
  4. import App from './App'
  5. import router from './router'
  6. import './icons' // icon
  7. import 'font-awesome/css/font-awesome.css'
  8. import './style/main.scss'
  9. import {getAuthUrls, getCurrentUser, getRolesPermissions, storageGet, storageSave} from '@/js/index'
  10. import {notify} from '@/constants/index'
  11. import store from './store'
  12. import moment from 'moment'
  13. import vRegion from 'v-region'
  14. import echarts from 'echarts';
  15. import Http from '@/js/http.js'
  16. import {configToJson} from './utils/filters'
  17. import {
  18. Avatar,
  19. Alert,
  20. Badge,
  21. Button,
  22. ButtonGroup,
  23. Card,
  24. Carousel,
  25. CarouselItem,
  26. Checkbox,
  27. CheckboxButton,
  28. CheckboxGroup,
  29. Col,
  30. Collapse,
  31. CollapseItem,
  32. DatePicker,
  33. Dialog,
  34. Dropdown,
  35. DropdownItem,
  36. DropdownMenu,
  37. Form,
  38. FormItem,
  39. Image,
  40. Input,
  41. InputNumber,
  42. Link,
  43. Loading,
  44. Menu,
  45. MenuItem,
  46. MenuItemGroup,
  47. Message,
  48. MessageBox,
  49. Notification,
  50. Option,
  51. Pagination,
  52. Popover,
  53. Radio,
  54. RadioButton,
  55. RadioGroup,
  56. Row,
  57. Select,
  58. Submenu,
  59. Switch,
  60. Table,
  61. TableColumn,
  62. TabPane,
  63. Tabs,
  64. Tag,
  65. TimePicker,
  66. TimeSelect,
  67. Tooltip,
  68. Upload,
  69. Progress,
  70. Step,
  71. Steps,
  72. Divider
  73. } from 'element-ui'
  74. import {setConfig} from "./config";
  75. import china from 'echarts/map/json/china.json'
  76. echarts.registerMap('china', china)
  77. Vue.prototype.$moment = moment
  78. Vue.prototype.$echarts = echarts;
  79. function getCurrentUserSuccess(res){
  80. }
  81. // var _hmt = _hmt || [];
  82. // (function() {
  83. // var hm = document.createElement("script");
  84. // hm.src = "https://hm.baidu.com/hm.js?0e3bd98236bd62558926fc433751d60c";
  85. // var s = document.getElementsByTagName("script")[0];
  86. // s.parentNode.insertBefore(hm, s);
  87. // })();
  88. // router.beforeEach((to, from, next) => {
  89. // // if (_hmt) {
  90. // // if (to.path) {
  91. // // _hmt.push(['_trackPageview', '/#' + to.fullPath]);
  92. // // }
  93. // // }
  94. // const urls = getAuthUrls()
  95. // if (storageGet('user') == null) {
  96. // getCurrentUser().then((res) => {
  97. // hstorageSave('user', res)
  98. // storageSave('rolesPermissions', getRolesPermissions(res.roleList))
  99. // if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
  100. // if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
  101. // next()
  102. // } else {
  103. // next({
  104. // path: '/',
  105. // query: {
  106. // redirect: to.fullPath
  107. // } // 将跳转的路由path作为参数,登录成功后跳转到该路由
  108. // })
  109. // }
  110. // } else {
  111. // next()
  112. // }
  113. // }).catch((error) => {
  114. // // notify('warning', '请登录')
  115. // if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
  116. // if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
  117. // next()
  118. // } else {
  119. // next({
  120. // path: '/',
  121. // query: {
  122. // redirect: to.fullPath
  123. // } // 将跳转的路由path作为参数,登录成功后跳转到该路由
  124. // })
  125. // }
  126. // } else {
  127. // next()
  128. // }
  129. // })
  130. // } else {
  131. // if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
  132. // if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
  133. // next()
  134. // } else {
  135. // next({
  136. // path: '/',
  137. // query: {
  138. // redirect: to.fullPath
  139. // } // 将跳转的路由path作为参数,登录成功后跳转到该路由
  140. // })
  141. // }
  142. // } else {
  143. // next()
  144. // }
  145. // }
  146. // //console.log(to.matched[0].path)
  147. // //console.log(urls.includes(to.matched[0].path))
  148. //
  149. // })
  150. // require('./mock.js')
  151. Vue.use(Carousel)
  152. Vue.use(CarouselItem)
  153. Vue.use(Row)
  154. Vue.use(Col)
  155. Vue.use(Table)
  156. Vue.use(TableColumn)
  157. Vue.use(Form)
  158. Vue.use(FormItem)
  159. Vue.use(Button)
  160. Vue.use(ButtonGroup)
  161. Vue.use(Menu)
  162. Vue.use(Submenu)
  163. Vue.use(MenuItem)
  164. Vue.use(MenuItemGroup)
  165. Vue.use(Input)
  166. Vue.use(InputNumber)
  167. Vue.use(Radio)
  168. Vue.use(RadioGroup)
  169. Vue.use(RadioButton)
  170. Vue.use(Checkbox)
  171. Vue.use(CheckboxButton)
  172. Vue.use(CheckboxGroup)
  173. Vue.use(DatePicker)
  174. Vue.use(TimeSelect)
  175. Vue.use(TimePicker)
  176. Vue.use(Switch)
  177. Vue.use(Select)
  178. Vue.use(Option)
  179. Vue.use(Upload)
  180. Vue.use(Tabs)
  181. Vue.use(TabPane)
  182. Vue.use(Collapse)
  183. Vue.use(CollapseItem)
  184. Vue.use(Dialog)
  185. Vue.use(Card)
  186. Vue.use(Tag)
  187. Vue.use(Avatar)
  188. Vue.use(Pagination)
  189. Vue.use(Link)
  190. Vue.use(Loading)
  191. Vue.use(Tooltip)
  192. Vue.use(Dropdown)
  193. Vue.use(DropdownItem)
  194. Vue.use(DropdownMenu)
  195. Vue.use(Image)
  196. Vue.use(Badge)
  197. Vue.use(Popover)
  198. Vue.use(Progress)
  199. Vue.use(Steps)
  200. Vue.use(Step)
  201. Vue.use(Divider)
  202. Vue.use(Alert)
  203. Vue.prototype.$msgbox = MessageBox
  204. Vue.prototype.$alert = MessageBox.alert
  205. Vue.prototype.$confirm = MessageBox.confirm
  206. Vue.prototype.$prompt = MessageBox.prompt
  207. Vue.prototype.$notify = Notification
  208. Vue.prototype.$message = Message
  209. Vue.config.productionTip = false
  210. Http.get('/api/common/configuration').then((res) => {
  211. let config = res.data&&res.data.configurationList;
  212. let configData = configToJson(config);
  213. this.homeDataNoCache = configData;
  214. setConfig(configData);
  215. storageSave('config', configData);
  216. new Vue({
  217. el: '#app',
  218. router,
  219. data: {
  220. Bus: new Vue()
  221. },
  222. components: {App},
  223. template: '<App/>',
  224. store
  225. })
  226. }).catch((error) => {
  227. console.log(error)
  228. notify('error', error.data)
  229. })
  230. /* eslint-disable no-new */