main.js 6.3 KB

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