// 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'; import Antd from 'ant-design-vue'; import 'ant-design-vue/dist/antd.css'; import { createRouter, createWebHashHistory } from 'vue-router'; import { createStore } from 'vuex'; import * as PcClientComponent from 'pc-component-v3'; import 'pc-component-v3/dist/pc-component-v3.css'; 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-trace-v3/dist/client-trace-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 } 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; const app = createApp(App); app.use(Antd); app.use(i18n); app.use(router); app.use(VTooltip); app.use(store); app.use(PcClientComponent); app.use(router); app.mount('#app'); 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'){ 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; } });