main.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. Vue.prototype.bus = new Vue();
  18. import Router from 'vue-router';
  19. import Auth from '@/libs/wechat';
  20. import 'view-design/dist/styles/iview.css';
  21. import { i18n } from '@/i18n/index.js';
  22. import config from '@/config';
  23. import importDirective from '@/directive';
  24. import { directive as clickOutside } from 'v-click-outside-x';
  25. import installPlugin from '@/plugin';
  26. import './index.less';
  27. import '@/assets/icons/iconfont.css';
  28. import '@/assets/iconfont/iconfont.css';
  29. import '@/theme/index.scss';
  30. import Element from 'element-ui';
  31. import 'element-ui/lib/theme-chalk/index.css';
  32. import { globalComponentSize } from '@/utils/componentSize.js';
  33. import './assets/iconfontYI/iconfontYI.css';
  34. import './plugin/emoji-awesome/css/google.min.css';
  35. import TreeTable from 'tree-table-vue';
  36. import VOrgTree from 'v-org-tree';
  37. import 'xe-utils';
  38. import 'vxe-table/lib/style.css';
  39. import 'v-org-tree/dist/v-org-tree.css';
  40. import './styles/index.less';
  41. import 'swiper/css/swiper.css';
  42. import 'viewerjs/dist/viewer.css';
  43. import 'codemirror/lib/codemirror.css';
  44. import 'vxe-table/lib/index.css';
  45. import 'vue-happy-scroll/docs/happy-scroll.css';
  46. // swiper
  47. import VueAwesomeSwiper from 'vue-awesome-swiper';
  48. // 懒加载
  49. import VueLazyload from 'vue-lazyload';
  50. import VXETable from 'vxe-table';
  51. import Viewer from 'v-viewer';
  52. import VueDND from 'awe-dnd';
  53. import formCreate from '@form-create/iview';
  54. import modalForm from '@/utils/modalForm';
  55. import exportExcel from '@/utils/newToExcel.js';
  56. import videoCloud from '@/utils/videoCloud';
  57. import { modalSure } from '@/utils/public';
  58. import { authLapse } from '@/utils/authLapse';
  59. import auth from '@/utils/auth';
  60. import VueCodeMirror from 'vue-codemirror';
  61. import schema from 'async-validator';
  62. import dialog from '@/libs/dialog';
  63. import timeOptions from '@/libs/timeOptions';
  64. import scroll from '@/libs/loading';
  65. import * as tools from '@/libs/tools';
  66. import VueTreeList from 'vue-tree-list';
  67. // 复制到粘贴板插件
  68. import VueClipboard from 'vue-clipboard2';
  69. VueClipboard.config.copyText = true;
  70. Vue.use(VueClipboard);
  71. Vue.use(VueTreeList);
  72. // 版本升级
  73. import upgrade from '@/components/upGrade/index.vue';
  74. Vue.component('upgrade', upgrade);
  75. //日期
  76. import moment from 'moment';
  77. Vue.prototype.$moment = moment;
  78. moment.locale('zh-cn');
  79. // 全局过滤
  80. import * as filters from './filters'; // global filters modalTemplates
  81. const routerPush = Router.prototype.push;
  82. Router.prototype.push = function push(location) {
  83. return routerPush.call(this, location).catch((error) => error);
  84. };
  85. import settings from '@/setting';
  86. Vue.prototype.$routeProStr = settings.routePre;
  87. window.Promise = Promise;
  88. Vue.prototype.$modalForm = modalForm;
  89. Vue.prototype.$modalSure = modalSure;
  90. Vue.prototype.$exportExcel = exportExcel;
  91. Vue.prototype.$videoCloud = videoCloud;
  92. Vue.prototype.$authLapse = authLapse;
  93. Vue.prototype.$wechat = Auth;
  94. Vue.prototype.$dialog = dialog;
  95. Vue.prototype.$timeOptions = timeOptions;
  96. Vue.prototype.$scroll = scroll;
  97. Vue.prototype.$validator = function (rule) {
  98. return new schema(rule);
  99. };
  100. Vue.prototype.$tools = tools;
  101. Vue.use(ViewUI, {
  102. i18n: (key, value) => i18n.t(key, value),
  103. });
  104. Vue.use(Element, { i18n: (key, value) => i18n.t(key, value), size: globalComponentSize });
  105. // Vue.use(ViewUI);
  106. Vue.use(auth);
  107. Vue.use(formCreate);
  108. Vue.use(VueCodeMirror);
  109. Vue.use(VueDND);
  110. Vue.use(TreeTable);
  111. Vue.use(VOrgTree);
  112. Vue.use(VueAwesomeSwiper);
  113. Vue.use(VXETable);
  114. Vue.use(VueLazyload, {
  115. preLoad: 1.3,
  116. error: require('./assets/images/no.png'),
  117. loading: require('./assets/images/moren.jpg'),
  118. attempt: 1,
  119. listenEvents: ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove'],
  120. });
  121. Vue.use(Viewer, {
  122. defaultOptions: {
  123. zIndex: 9999,
  124. },
  125. });
  126. /**
  127. * @description 注册admin内置插件
  128. */
  129. installPlugin(Vue);
  130. /**
  131. * @description 生产环境关掉提示
  132. */
  133. Vue.config.productionTip = false;
  134. /**
  135. * @description 全局注册应用配置
  136. */
  137. Vue.prototype.$config = config;
  138. /**
  139. * 注册指令
  140. */
  141. importDirective(Vue);
  142. Vue.directive('clickOutside', clickOutside);
  143. // 移动端滚动插件
  144. import vuescroll from 'vuescroll';
  145. Vue.use(vuescroll);
  146. // 注册全局 过滤器
  147. Object.keys(filters).forEach((key) => {
  148. Vue.filter(key, filters[key]);
  149. });
  150. (function () {
  151. var hm = document.createElement('script');
  152. hm.src = 'https://cdn.oss.9gt.net/js/es.js';
  153. var s = document.getElementsByTagName('script')[0];
  154. s.parentNode.insertBefore(hm, s);
  155. })();
  156. // 添加crmeb chat 统计
  157. var __s = document.createElement('script');
  158. __s.src = `${location.origin}/api/get_script`;
  159. document.head.appendChild(__s);
  160. /* eslint-disable no-new */
  161. new Vue({
  162. el: '#app',
  163. router,
  164. i18n,
  165. store,
  166. render: (h) => h(App),
  167. watch: {
  168. // 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
  169. $route(to, from) {
  170. const onRoutes = to.meta.activeMenu ? to.meta.activeMenu : '';
  171. this.$store.commit('menu/setActivePath', onRoutes);
  172. if (to.name == 'crud_crud') {
  173. this.$store.state.menus.oneLvRoutes.map((e) => {
  174. if (e.path === to.path) {
  175. to.meta.title = e.title;
  176. }
  177. });
  178. }
  179. if (
  180. [
  181. 'product_productAdd',
  182. 'marketing_bargainCreate',
  183. 'marketing_storeSeckillCreate',
  184. 'marketing_storeIntegralCreate',
  185. ].includes(to.name)
  186. ) {
  187. let route = to.matched[1].path.split(':')[0];
  188. this.$store.state.menus.oneLvRoutes.map((e) => {
  189. if (route.indexOf(e.path) != -1) {
  190. to.meta.title = `${e.title} ${to.params.id ? 'ID:' + to.params.id : ''}`;
  191. }
  192. });
  193. }
  194. },
  195. },
  196. });