// eslint-disable-next-line no-undef __webpack_nonce__ = '*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); import './assets/common.css'; import './assets/common1.css'; import { createI18n } from 'vue-i18n'; import { createRouter, createWebHashHistory } from 'vue-router'; //import { createI18n } from 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'; //import { createI18n } from 'vue-i18n/dist/vue-i18n.runtime.esm-browser.js'; import * as PcComponentV3 from 'pc-component-v3'; import 'pc-component-v3/dist/pc-component-v3.css'; window.PcComponentV3 = PcComponentV3; import App from '../src/App.vue'; import VTooltip from 'v-tooltip'; import 'v-tooltip/dist/v-tooltip.css'; import * as dd from 'dingtalk-jsapi'; window.dd = dd; import routes from './routes/main_routes.js'; // console.log(window.$); // import $ from 'jquery'; // console.log(window.$); //$ = window.$; // console.log($); import store from './store/index.js'; import langZhCn from './locales/zh-CN.json'; import langEnUs from './locales/en-US.json'; import { Notify } from 'pc-component-v3/dist/pc-component-v3.js'; window.Notify = Notify; import * as AntDesignIconsVue from '@ant-design/icons-vue'; window.AntDesignIconsVue = AntDesignIconsVue; const i18n = createI18n({ locale: 'zh-CN', messages: { 'zh-CN': langZhCn, 'en-US': langEnUs, }, }); window.CRUDId = -2147483640; import Common from './common/Common.js'; window.Common = Common; // 报NavigationDuplicated: Avoided redundant navigation to current location: "/" 的错 //获取原型对象上的push函数 // const originalPush = VueRouter.prototype.push; //修改原型对象中的push方法 // VueRouter.prototype.push = function push(location) { // return originalPush.call(this, location).catch(err => err); // }; // const config = { // errorBagName: 'errors', // change if property conflicts. // fieldsBagName: 'fieldsBagName', // delay: 0, // locale: 'en', // dictionary: null, // strict: true, // enableAutoClasses: false, // classNames: { // touched: 'touched', // the control has been blurred // untouched: 'untouched', // the control hasn't been blurred // valid: 'valid', // model is valid // invalid: 'invalid', // model is invalid // pristine: 'pristine', // control has not been interacted with // dirty: 'dirty', // control has been interacted with // }, // events: 'input|blur', // inject: true, // }; // Vue.use(config); const router = createRouter({ history: createWebHashHistory(), base: '/', mode: 'hash', routes: routes, }); import CurdWindowModal from './window1/CurdWindowModal.vue'; import AuthImage from './widget/AuthImage.vue'; const app = createApp(App); app.use(Antd); app.use(i18n); app.use(router); app.use(VTooltip); app.use(store); // PC Client 组件 app.use(PcComponentV3); app.mount('#app'); // 全局注册组件, CURD窗口模态框编辑器 app.component('CurdWindowModal', CurdWindowModal); // 图片显示 app.component('AuthImage', AuthImage); window.app = app; /** * 路由钩子 * @param {[type]} (to, from, next [description] * @return {[type]} [description] */ router.beforeEach((to, from, next) => { 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; } });