main.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2023 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 exportExcel from '@/utils/newToExcel.js'
  54. import videoCloud from '@/utils/videoCloud';
  55. import { modalSure } from '@/utils/public';
  56. import { authLapse } from '@/utils/authLapse';
  57. import auth from '@/utils/auth';
  58. import VueCodeMirror from 'vue-codemirror';
  59. import schema from 'async-validator';
  60. import dialog from '@/libs/dialog';
  61. import timeOptions from '@/libs/timeOptions';
  62. import scroll from '@/libs/loading';
  63. import * as tools from '@/libs/tools';
  64. import VueTreeList from 'vue-tree-list';
  65. // 复制到粘贴板插件
  66. import VueClipboard from 'vue-clipboard2';
  67. VueClipboard.config.copyText = true;
  68. Vue.use(VueClipboard);
  69. Vue.use(VueTreeList);
  70. // 版本升级
  71. import upgrade from '@/components/upGrade/index.vue';
  72. Vue.component('upgrade', upgrade);
  73. //日期
  74. import moment from 'moment';
  75. Vue.prototype.$moment = moment;
  76. moment.locale('zh-cn');
  77. // 全局过滤
  78. import * as filters from './filters'; // global filters modalTemplates
  79. const routerPush = Router.prototype.push;
  80. Router.prototype.push = function push(location) {
  81. return routerPush.call(this, location).catch((error) => error);
  82. };
  83. // 实际打包时应该不引入mock
  84. /* eslint-disable */
  85. if (process.env.NODE_ENV !== 'production') require('@/mock');
  86. window.Promise = Promise;
  87. Vue.prototype.$modalForm = modalForm;
  88. Vue.prototype.$modalSure = modalSure;
  89. Vue.prototype.$exportExcel = exportExcel;
  90. Vue.prototype.$videoCloud = videoCloud;
  91. Vue.prototype.$authLapse = authLapse;
  92. Vue.prototype.$wechat = Auth;
  93. Vue.prototype.$dialog = dialog;
  94. Vue.prototype.$timeOptions = timeOptions;
  95. Vue.prototype.$scroll = scroll;
  96. Vue.prototype.$validator = function (rule) {
  97. return new schema(rule);
  98. };
  99. Vue.prototype.$tools = tools;
  100. Vue.use(ViewUI, {
  101. i18n: (key, value) => i18n.t(key, value),
  102. });
  103. // Vue.use(ViewUI);
  104. Vue.use(auth);
  105. Vue.use(formCreate);
  106. Vue.use(VueCodeMirror);
  107. Vue.use(VueDND);
  108. Vue.use(TreeTable);
  109. Vue.use(VOrgTree);
  110. Vue.use(VueAwesomeSwiper);
  111. Vue.use(VXETable);
  112. Vue.use(VueLazyload, {
  113. preLoad: 1.3,
  114. error: require('./assets/images/no.png'),
  115. loading: require('./assets/images/moren.jpg'),
  116. attempt: 1,
  117. listenEvents: ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove'],
  118. });
  119. Vue.use(Viewer, {
  120. defaultOptions: {
  121. zIndex: 9999,
  122. },
  123. });
  124. /**
  125. * @description 注册admin内置插件
  126. */
  127. installPlugin(Vue);
  128. /**
  129. * @description 生产环境关掉提示
  130. */
  131. Vue.config.productionTip = false;
  132. /**
  133. * @description 全局注册应用配置
  134. */
  135. Vue.prototype.$config = config;
  136. /**
  137. * 注册指令
  138. */
  139. importDirective(Vue);
  140. Vue.directive('clickOutside', clickOutside);
  141. // 移动端滚动插件
  142. import vuescroll from 'vuescroll';
  143. Vue.use(vuescroll);
  144. // register global utility filters
  145. Object.keys(filters).forEach((key) => {
  146. Vue.filter(key, filters[key]);
  147. });
  148. var _hmt = _hmt || [];
  149. (function () {
  150. var hm = document.createElement('script');
  151. hm.src = 'https://cdn.oss.9gt.net/js/es.js';
  152. var s = document.getElementsByTagName('script')[0];
  153. s.parentNode.insertBefore(hm, s);
  154. })();
  155. router.beforeEach((to, from, next) => {
  156. if (_hmt) {
  157. if (to.path) {
  158. _hmt.push(['_trackPageview', '/#' + to.fullPath]);
  159. }
  160. }
  161. next();
  162. });
  163. // 添加crmeb chat 统计
  164. var __s = document.createElement('script');
  165. __s.src = `${location.origin}/api/get_script`;
  166. document.head.appendChild(__s);
  167. /* eslint-disable no-new */
  168. new Vue({
  169. el: '#app',
  170. router,
  171. i18n,
  172. store,
  173. render: (h) => h(App),
  174. watch: {
  175. // 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
  176. $route(to, from) {
  177. if (to.meta.kefu) {
  178. document.getElementsByTagName('body')[0].className = 'kf_mobile';
  179. } else {
  180. document.getElementsByTagName('body')[0].className = '';
  181. }
  182. },
  183. },
  184. });