main.js 5.6 KB

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