// eslint-disable-next-line no-undef //__webpack_nonce__ = '*NONCE_TOKEN*'; // eslint-disable-next-line no-undef __webpack_nonce__ = window.nonce_token; import { createApp, defineAsyncComponent } from 'vue'; //import { createApp, defineAsyncComponent } from 'vue/dist/vue.runtime.esm-browser.prod.js'; // 修复异步组件中AntV控件不能打开的BUG。 // import Antd from 'ant-design-vue'; import * as Antd from 'ant-design-vue'; import 'ant-design-vue/dist/reset.css'; window.Antd = Antd; //console.log(Antd); // 修复异步组件中AntV控件不能打开的BUG。 import * as AntdComponents from 'ant-design-vue'; window.Antd = AntdComponents; import { createRouter, createWebHashHistory } from 'vue-router'; import { createStore } from 'vuex'; import * as PcComponentV3 from 'pc-component-v3'; import 'pc-component-v3/dist/pc-component-v3.css'; window.PcComponentV3 = PcComponentV3; import VTooltip from 'v-tooltip'; import 'v-tooltip/dist/v-tooltip.css'; import * as dd from 'dingtalk-jsapi'; window.dd = dd; import 'jquery'; import 'client-base-v4/dist/client-base-v4.css'; import 'client-role-v3/dist/client-role-v3.css'; // import 'client-dictionary-v3/dist/client-dictionary-v3.css'; import 'client-dic-v3/dist/client-dic-v3.css'; import 'client-eam-v3/dist/client-eam-v3.css'; import 'client-wms-v3/dist/client-wms-v3.css'; import 'client-sensor-v3/dist/client-sensor-v3.css'; import { store } from './store.js'; import { i18n } from './lang.js'; import { router } from './routes/index.js'; import { App, Common, PushMessage, CurdWindowModal, AuthImage } from 'client-base-v4/dist/client-base-v4.js'; import { Notify } from 'pc-component-v3/dist/pc-component-v3.js'; window.Common = Common; window.Notify = Notify; import * as AntDesignIconsVue from '@ant-design/icons-vue'; window.AntDesignIconsVue = AntDesignIconsVue; const app = createApp(App); app.use(Antd); app.use(i18n); app.use(router); app.use(VTooltip); app.use(store); app.use(PcComponentV3); app.use(router); app.mount('#app'); // 全局注册组件, CURD窗口模态框编辑器 app.component('CurdWindowModal', CurdWindowModal); // 图片显示 app.component('AuthImage', AuthImage); window.app = app; // 当页面刷新后重新打开声音提示 if (window.performance.navigation.type == 1) { localStorage.setItem('allowSound', false) } /** * 路由钩子 * @param {[type]} (to, from, next [description] * @return {[type]} [description] */ router.beforeEach((to, from, next) => { let allowSound = localStorage.getItem('allowSound') // 不是登录页才进行消息推送 if (to.fullPath !== '/login' && !to.path.includes('login') && !to.path.includes('Login')) { PushMessage.openWebSocket() if (allowSound && allowSound == 'false') { PushMessage.messageModal() } } else { PushMessage.closeWebsocket() } let funtionAccessDtos = []; if (to.matched.some(function (item) { // 判断是否需要登录才可以访问 if (item.meta.loginRequired) { if (item.meta.functionAccessArray != undefined || item.meta.functionAccessArray != null) { funtionAccessDtos = item.meta.functionAccessArray; } if (funtionAccessDtos != null) { funtionAccessDtos.forEach(funtionAccessDto => { if (typeof (funtionAccessDto.itemNo) === 'string') { funtionAccessDto.itemNo = [funtionAccessDto.itemNo]; } }); } } return item.meta.loginRequired; })) { // 判断是否已登录 var token = localStorage.getItem('#token'); if (token == undefined || token.length == 0) { // 如果没有登录则直接返回 next('/login'); } else { // 判断该路由需要具备”xxx”功能-“x1”功能项,”xxx”功能-“x2“功能项,”yyy”功能-“y1”功能项访问权限的用户才可以访问 $.ajax({ url: Common.getApiURL( 'RoleResourceV3/canVisitFunctionAccess', ), type: 'post', dataType: 'json', contentType: 'application/json', data: JSON.stringify(funtionAccessDtos), beforeSend: function (request) { Common.addTokenToRequest(request); }, success: function (data) { if (data.errorCode === 0 && data.data === true) { next(); return; } else { next('/desktop/no-role'); return; } }, error: function (XMLHttpRequest, textStatus, errorThrown) { Common.processException(XMLHttpRequest, textStatus, errorThrown); }, }); } } else { next(); return; } });