| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- // 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';
- import Antd from 'ant-design-vue';
- // import 'ant-design-vue/dist/antd.css';
- 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 PcClientComponent from 'pc-component-v3';
- import 'pc-component-v3/dist/pc-component-v3.css';
- 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;
- 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,
- });
- const app = createApp(App);
- app.use(Antd);
- app.use(i18n);
- app.use(router);
- app.use(VTooltip);
- app.use(store);
- // PC Client 组件
- app.use(PcClientComponent);
- app.mount('#app');
- 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;
- }
- });
|