main.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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, { t } 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. import Pagination from "@/components/Pagination";
  68. // 全局组件挂载
  69. Vue.component('Pagination', Pagination)
  70. // 复制到粘贴板插件
  71. import VueClipboard from 'vue-clipboard2';
  72. VueClipboard.config.copyText = true;
  73. Vue.use(VueClipboard);
  74. Vue.use(VueTreeList);
  75. // 版本升级
  76. import upgrade from '@/components/upGrade/index.vue';
  77. Vue.component('upgrade', upgrade);
  78. //日期
  79. import moment from 'moment';
  80. Vue.prototype.$moment = moment;
  81. moment.locale('zh-cn');
  82. // 全局过滤
  83. import * as filters from './filters'; // global filters modalTemplates
  84. const routerPush = Router.prototype.push;
  85. Router.prototype.push = function push(location) {
  86. return routerPush.call(this, location).catch((error) => error);
  87. };
  88. import settings from '@/setting';
  89. Vue.prototype.$routeProStr = settings.routePre;
  90. window.Promise = Promise;
  91. Vue.prototype.$modalForm = modalForm;
  92. Vue.prototype.$modalSure = modalSure;
  93. Vue.prototype.$exportExcel = exportExcel;
  94. Vue.prototype.$videoCloud = videoCloud;
  95. Vue.prototype.$authLapse = authLapse;
  96. Vue.prototype.$wechat = Auth;
  97. Vue.prototype.$dialog = dialog;
  98. Vue.prototype.$timeOptions = timeOptions;
  99. Vue.prototype.$scroll = scroll;
  100. Vue.prototype.$validator = function (rule) {
  101. return new schema(rule);
  102. };
  103. Vue.prototype.$tools = tools;
  104. Vue.use(ViewUI, {
  105. i18n: (key, value) => i18n.t(key, value),
  106. });
  107. Vue.use(Element, { i18n: (key, value) => i18n.t(key, value), size: 'small' });
  108. // Vue.use(ViewUI);
  109. Vue.use(auth);
  110. Vue.use(formCreate);
  111. Vue.use(VueCodeMirror);
  112. Vue.use(VueDND);
  113. Vue.use(TreeTable);
  114. Vue.use(VOrgTree);
  115. Vue.use(VueAwesomeSwiper);
  116. Vue.use(VXETable);
  117. Vue.use(VueLazyload, {
  118. preLoad: 1.3,
  119. error: require('./assets/images/no.png'),
  120. loading: require('./assets/images/moren.jpg'),
  121. attempt: 1,
  122. listenEvents: ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend', 'touchmove'],
  123. });
  124. Vue.use(Viewer, {
  125. defaultOptions: {
  126. zIndex: 9999,
  127. },
  128. });
  129. /**
  130. * @description 注册admin内置插件
  131. */
  132. installPlugin(Vue);
  133. /**
  134. * @description 生产环境关掉提示
  135. */
  136. Vue.config.productionTip = false;
  137. /**
  138. * @description 全局注册应用配置
  139. */
  140. Vue.prototype.$config = config;
  141. /**
  142. * 注册指令
  143. */
  144. importDirective(Vue);
  145. Vue.directive('clickOutside', clickOutside);
  146. // 移动端滚动插件
  147. import vuescroll from 'vuescroll';
  148. Vue.use(vuescroll);
  149. // 注册全局 过滤器
  150. Object.keys(filters).forEach((key) => {
  151. Vue.filter(key, filters[key]);
  152. });
  153. (function () {
  154. var hm = document.createElement('script');
  155. hm.src = 'https://cdn.oss.9gt.net/js/es.js';
  156. var s = document.getElementsByTagName('script')[0];
  157. s.parentNode.insertBefore(hm, s);
  158. })();
  159. // 添加crmeb chat 统计
  160. var __s = document.createElement('script');
  161. __s.src = `${location.origin}/api/get_script`;
  162. document.head.appendChild(__s);
  163. /* eslint-disable no-new */
  164. new Vue({
  165. el: '#app',
  166. router,
  167. i18n,
  168. store,
  169. render: (h) => h(App),
  170. watch: {
  171. // 监听路由 控制侧边栏显示 标记当前顶栏菜单(如需要)
  172. $route(to, from) {
  173. console.log(to);
  174. const onRoutes = to.meta.activeMenu ? to.meta.activeMenu : to.meta.path;
  175. console.log(onRoutes);
  176. this.$store.commit('menu/setActivePath', onRoutes);
  177. if (to.name == 'crud_crud') {
  178. this.$store.state.menus.oneLvRoutes.map((e) => {
  179. if (e.path === to.path) {
  180. to.meta.title = e.title;
  181. }
  182. });
  183. }
  184. if (
  185. [
  186. 'product_productAdd',
  187. 'marketing_bargainCreate',
  188. 'marketing_storeSeckillCreate',
  189. 'marketing_storeIntegralCreate',
  190. ].includes(to.name)
  191. ) {
  192. let route = to.matched[1].path.split(':')[0];
  193. this.$store.state.menus.oneLvRoutes.map((e) => {
  194. if (route.indexOf(e.path) != -1) {
  195. to.meta.title = `${e.title} ${to.params.id ? 'ID:' + to.params.id : ''}`;
  196. }
  197. });
  198. }
  199. },
  200. },
  201. });