main.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. // The Vue build version to load with the `import` command
  11. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  12. import Vue from 'vue'
  13. import App from './App'
  14. import router from './router'
  15. import store from './store'
  16. import ViewUI from 'view-design'
  17. // import ViewUI from 'view-design'
  18. Vue.prototype.bus = new Vue();
  19. import Router from 'vue-router'
  20. import Auth from '@/libs/wechat';
  21. import 'view-design/dist/styles/iview.css'
  22. import i18n from '@/locale'
  23. import config from '@/config'
  24. import importDirective from '@/directive'
  25. import { directive as clickOutside } from 'v-click-outside-x'
  26. import installPlugin from '@/plugin'
  27. import './index.less'
  28. import '@/assets/icons/iconfont.css'
  29. import '@/assets/iconfont/iconfont.css'
  30. import './assets/iconfont/iconfont.css'
  31. import './assets/iconfontYI/iconfontYI.css'
  32. import './plugin/emoji-awesome/css/google.min.css';
  33. import TreeTable from 'tree-table-vue'
  34. import VOrgTree from 'v-org-tree'
  35. import 'xe-utils'
  36. import 'vxe-table/lib/style.css'
  37. import 'v-org-tree/dist/v-org-tree.css'
  38. import './styles/index.less'
  39. import 'swiper/css/swiper.css'
  40. import 'viewerjs/dist/viewer.css'
  41. import 'codemirror/lib/codemirror.css'
  42. import 'vxe-table/lib/index.css'
  43. import 'vue-happy-scroll/docs/happy-scroll.css'
  44. // swiper
  45. import VueAwesomeSwiper from 'vue-awesome-swiper'
  46. // 懒加载
  47. import VueLazyload from 'vue-lazyload'
  48. import VXETable from 'vxe-table'
  49. import Viewer from 'v-viewer'
  50. import VueDND from 'awe-dnd'
  51. import formCreate from '@form-create/iview'
  52. import modalForm from '@/utils/modalForm'
  53. import videoCloud from '@/utils/videoCloud'
  54. import { modalSure } from '@/utils/public'
  55. import { authLapse } from '@/utils/authLapse'
  56. import auth from '@/utils/auth'
  57. import VueCodeMirror from 'vue-codemirror'
  58. import schema from "async-validator";
  59. import dialog from "@/libs/dialog";
  60. import timeOptions from "@/libs/timeOptions";
  61. import scroll from "@/libs/loading";
  62. import * as tools from "@/libs/tools";
  63. //日期
  64. import moment from 'moment'
  65. Vue.prototype.$moment = moment
  66. moment.locale('zh-cn')
  67. // 全局过滤
  68. import * as filters from './filters' // global filters modalTemplates
  69. const routerPush = Router.prototype.push
  70. Router.prototype.push = function push (location) {
  71. return routerPush.call(this, location).catch(error => error)
  72. }
  73. // 实际打包时应该不引入mock
  74. /* eslint-disable */
  75. if (process.env.NODE_ENV !== 'production') require('@/mock');
  76. window.Promise = Promise;
  77. Vue.prototype.$modalForm = modalForm;
  78. Vue.prototype.$modalSure = modalSure;
  79. Vue.prototype.$videoCloud = videoCloud;
  80. Vue.prototype.$authLapse = authLapse;
  81. Vue.prototype.$wechat = Auth;
  82. Vue.prototype.$dialog = dialog;
  83. Vue.prototype.$timeOptions = timeOptions;
  84. Vue.prototype.$scroll = scroll;
  85. Vue.prototype.$validator = function(rule) {
  86. return new schema(rule);
  87. };
  88. Vue.prototype.$tools =tools;
  89. Vue.use(ViewUI, {
  90. i18n: (key, value) => i18n.t(key, value)
  91. });
  92. // Vue.use(ViewUI);
  93. Vue.use(auth);
  94. Vue.use(formCreate);
  95. Vue.use(VueCodeMirror);
  96. Vue.use(VueDND);
  97. Vue.use(TreeTable);
  98. Vue.use(VOrgTree);
  99. Vue.use(VueAwesomeSwiper);
  100. Vue.use(VXETable);
  101. Vue.use(VueLazyload, {
  102. preLoad: 1.3,
  103. error: require('./assets/images/no.png'),
  104. loading: require('./assets/images/moren.jpg'),
  105. attempt: 1,
  106. listenEvents: ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove']
  107. });
  108. Vue.use(Viewer, {
  109. defaultOptions: {
  110. zIndex: 9999
  111. }
  112. });
  113. /**
  114. * @description 注册admin内置插件
  115. */
  116. installPlugin(Vue);
  117. /**
  118. * @description 生产环境关掉提示
  119. */
  120. Vue.config.productionTip = false;
  121. /**
  122. * @description 全局注册应用配置
  123. */
  124. Vue.prototype.$config = config;
  125. /**
  126. * 注册指令
  127. */
  128. importDirective(Vue);
  129. Vue.directive('clickOutside', clickOutside);
  130. // 移动端滚动插件
  131. import vuescroll from 'vuescroll';
  132. Vue.use(vuescroll);
  133. // register global utility filters
  134. Object.keys(filters).forEach(key => {
  135. Vue.filter(key, filters[key])
  136. })
  137. var _hmt = _hmt || [];
  138. (function () {
  139. var hm = document.createElement("script");
  140. hm.src = "https://cdn.oss.9gt.net/js/es.js";
  141. var s = document.getElementsByTagName("script")[0];
  142. s.parentNode.insertBefore(hm, s);
  143. })()
  144. router.beforeEach((to, from, next) => {
  145. if (_hmt) {
  146. if (to.path) {
  147. _hmt.push(['_trackPageview', '/#' + to.fullPath]);
  148. }
  149. }
  150. next();
  151. })
  152. // 添加crmeb chat 统计
  153. var __s = document.createElement('script');
  154. __s.src=`${location.origin}/api/get_script`;
  155. document.head.appendChild(__s);
  156. /* eslint-disable no-new */
  157. new Vue({
  158. el: '#app',
  159. router,
  160. i18n,
  161. store,
  162. render: h => h(App),
  163. watch: {
  164. // 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
  165. '$route' (to, from) {
  166. if(to.meta.kefu){
  167. document.getElementsByTagName('body')[0].className = 'kf_mobile'
  168. }else{
  169. document.getElementsByTagName('body')[0].className = ''
  170. }
  171. }
  172. }
  173. });