main.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. // eslint-disable-next-line no-undef
  2. //__webpack_nonce__ = '*NONCE_TOKEN*';
  3. // eslint-disable-next-line no-undef
  4. __webpack_nonce__ = window.nonce_token;
  5. import { createApp, defineAsyncComponent } from 'vue';
  6. //import { createApp, defineAsyncComponent } from 'vue/dist/vue.runtime.esm-browser.prod.js';
  7. import Antd from 'ant-design-vue';
  8. import 'ant-design-vue/dist/antd.css';
  9. import { createI18n } from 'vue-i18n';
  10. import { createRouter, createWebHashHistory } from 'vue-router';
  11. import { createStore } from 'vuex';
  12. //import { createI18n } from 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js';
  13. //import { createI18n } from 'vue-i18n/dist/vue-i18n.runtime.esm-browser.js';
  14. import * as PcClientComponent from 'pc-component-v3';
  15. import 'pc-component-v3/dist/pc-component-v3.css';
  16. window.Uuid = PcClientComponent.Uuid;
  17. window.Notify = PcClientComponent.Notify;
  18. import ElementPlus from 'element-plus';
  19. import 'element-plus/dist/index.css';
  20. import App from '../client-base-v4/src/App.vue';
  21. import VTooltip from 'v-tooltip';
  22. import 'v-tooltip/dist/v-tooltip.css';
  23. import * as dd from 'dingtalk-jsapi';
  24. window.dd = dd;
  25. import 'jquery';
  26. import select2 from 'select2';
  27. import 'select2/dist/css/select2.css';
  28. import 'select2-bootstrap-theme/dist/select2-bootstrap.css';
  29. import downloadStore from '../client-base-v4/src/store/modules/downloadStore.js';
  30. import processConditionStore from '../client-workflow-v3/src/store/modules/processConditionStore.js';
  31. import merge from './merge.js';
  32. import langZhCn0 from '../client-base-v4/src/locales/zh-CN.json';
  33. import langEnUs0 from '../client-base-v4/src/locales/en-US.json';
  34. import langZhCn1 from '../client-eam-v3/src/locales/zh-CN.json';
  35. import langEnUs1 from '../client-eam-v3/src/locales/en-US.json';
  36. import langZhCn2 from '../client-role-v3/src/locales/zh-CN.json';
  37. import langEnUs2 from '../client-role-v3/src/locales/en-US.json';
  38. let langZhCn = merge.deepAssign(langZhCn0, langZhCn1, langZhCn2);
  39. let langEnUs = merge.deepAssign(langEnUs0, langEnUs1, langEnUs2);
  40. const i18n = createI18n({
  41. locale: 'zh-CN',
  42. messages: {
  43. 'zh-CN': langZhCn,
  44. 'en-US': langEnUs,
  45. },
  46. });
  47. window.CRUDId = -2147483640;
  48. import Common from '../client-base-v4/src/base/common/Common.js';
  49. window.Common = Common;
  50. import routes0 from '../client-base-v4/src/routes/main_routes.js';
  51. import routes1 from '../client-eam-v3/src/router/index.js';
  52. import routes2 from '../client-role-v3/src/router/routes.js';
  53. import routes3 from '../client-dictionary-v3/src/router/index.js';
  54. import routes4 from '../client-dic-v3/src/router/routes.js';
  55. import routes5 from '../client-workflow-v3/src/router/index.js';
  56. import routes6 from '../client-wms-v3/src/router/index.js';
  57. let routes = merge.mergeArray(routes0, routes1);
  58. routes = merge.mergeArray(routes, routes2);
  59. routes = merge.mergeArray(routes, routes3);
  60. routes = merge.mergeArray(routes, routes4);
  61. routes = merge.mergeArray(routes, routes5);
  62. routes = merge.mergeArray(routes, routes6);
  63. const router = createRouter({
  64. history: createWebHashHistory(),
  65. base: '/',
  66. mode: 'hash',
  67. routes: routes,
  68. });
  69. const store = createStore({
  70. modules: {
  71. downloadStore,
  72. processConditionStore,
  73. },
  74. });
  75. import '../client-workflow-v3/src/components/DynamicForm/styles/index.css';
  76. import '../client-workflow-v3/src/components/DynamicForm/icons';
  77. import FormControls from '../client-workflow-v3/src/components/FormControls/index.js';
  78. import * as ElementPlusIconsVue from '@element-plus/icons-vue';
  79. import '../client-workflow-v3/src/assets/style/global.css';
  80. import '../client-workflow-v3/src/assets/style/font_1388912_hzzxayghumf.css';
  81. import SvgIcon from '../client-workflow-v3/src/components/DynamicForm/components/SvgIcon/index.vue';// svg component
  82. const app = createApp(App);
  83. app.use(Antd);
  84. app.use(i18n);
  85. app.use(router);
  86. app.use(VTooltip);
  87. app.use(store);
  88. // PC Client 组件
  89. app.use(PcClientComponent);
  90. app.use(ElementPlus);
  91. app.use(router);
  92. app.use(FormControls);
  93. for (let [key, component] of Object.entries(ElementPlusIconsVue)) {
  94. app.component(key, component);
  95. }
  96. app.component( 'SvgIcon', SvgIcon );
  97. app.mount('#app');
  98. window.app = app;
  99. /**
  100. * 路由钩子
  101. * @param {[type]} (to, from, next [description]
  102. * @return {[type]} [description]
  103. */
  104. router.beforeEach((to, from, next) => {
  105. let funtionAccessDtos = [];
  106. if (to.matched.some(function (item) {
  107. // 判断是否需要登录才可以访问
  108. if (item.meta.loginRequired) {
  109. if (item.meta.functionAccessArray != undefined || item.meta.functionAccessArray != null) {
  110. funtionAccessDtos = item.meta.functionAccessArray;
  111. }
  112. if (funtionAccessDtos != null) {
  113. funtionAccessDtos.forEach(funtionAccessDto => {
  114. if(typeof (funtionAccessDto.itemNo) === 'string'){
  115. funtionAccessDto.itemNo = [funtionAccessDto.itemNo];
  116. }
  117. });
  118. }
  119. }
  120. return item.meta.loginRequired;
  121. })) {
  122. // 判断是否已登录
  123. var token = $.cookie('token');
  124. if (token == undefined || token.length == 0) {
  125. // 如果没有登录则直接返回
  126. next('/login');
  127. } else {
  128. // 判断该路由需要具备”xxx”功能-“x1”功能项,”xxx”功能-“x2“功能项,”yyy”功能-“y1”功能项访问权限的用户才可以访问
  129. $.ajax({
  130. url: Common.getApiURL(
  131. 'RoleResourceV2/canVisitFunctionAccess',
  132. ),
  133. type: 'post',
  134. dataType: 'json',
  135. contentType: 'application/json',
  136. data: JSON.stringify(funtionAccessDtos),
  137. beforeSend: function (request) {
  138. Common.addTokenToRequest(request);
  139. },
  140. success: function (data) {
  141. if (data.errorCode === 0 && data.data === true) {
  142. next();
  143. return;
  144. } else {
  145. next('/desktop/no-role');
  146. return;
  147. }
  148. },
  149. error: function (XMLHttpRequest, textStatus, errorThrown) {
  150. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  151. },
  152. });
  153. }
  154. } else {
  155. next();
  156. return;
  157. }
  158. });