management/front/dkha-web-sz-main/node_modules/.cache/babel-loader/954bcd9f6f66a1e07560382cdc7...

1 line
20 KiB
JSON

{"remainingRequest":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js!C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\router\\index.js","dependencies":[{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\router\\index.js","mtime":1614735254000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\node_modules\\babel-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es7.object.get-own-property-descriptors\";\nimport \"core-js/modules/web.dom.iterable\";\nimport \"core-js/modules/es6.object.keys\";\nimport _defineProperty from \"C:\\\\Users\\\\27446\\\\Desktop\\\\up\\\\front\\\\dkha-web-sz-main\\\\node_modules\\\\@babel\\\\runtime-corejs2/helpers/esm/defineProperty\";\nimport \"core-js/modules/es6.function.name\";\nimport \"core-js/modules/es6.regexp.replace\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nimport Vue from 'vue';\nimport Router from 'vue-router';\nimport http from '@/utils/request';\nimport { isURL } from '@/utils/validate';\nimport { getPersonRegion, getDictDataListAll } from '@/utils/index';\nVue.use(Router); // 页面路由(独立页面)\n\nexport var pageRoutes = [{\n path: '/404',\n component: function component() {\n return import('@/views/pages/404');\n },\n name: '404',\n meta: {\n title: '404未找到'\n },\n beforeEnter: function beforeEnter(to, from, next) {\n // 拦截处理特殊业务场景\n // 如果, 重定向路由包含__双下划线, 为临时添加路由\n if (/__.*/.test(to.redirectedFrom)) {\n return next(to.redirectedFrom.replace(/__.*/, ''));\n }\n\n next();\n }\n}, {\n path: '/login',\n component: function component() {\n return import('@/views/pages/login');\n },\n name: 'login',\n meta: {\n title: '登录'\n }\n}]; // 模块路由(基于主入口布局页面)\n\nexport var moduleRoutes = {\n path: '/',\n component: function component() {\n return import('@/views/main');\n },\n name: 'main',\n redirect: {\n name: 'home'\n },\n meta: {\n title: '主入口布局'\n },\n children: [{\n path: '/home',\n component: function component() {\n return import('@/views/modules/home');\n },\n name: 'home',\n meta: {\n title: '首页',\n isTab: true\n }\n }]\n};\nexport function addDynamicRoute(routeParams, router) {\n // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转\n var routeName = routeParams.routeName;\n var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter(function (item) {\n return item.name === routeName;\n })[0];\n\n if (dynamicRoute) {\n return router.push({\n name: routeName,\n params: routeParams.params\n });\n } // 否则: 添加并全局变量保存, 再跳转\n\n\n dynamicRoute = {\n path: routeName,\n component: function component() {\n return import(\"@/views/modules/\".concat(routeParams.path));\n },\n name: routeName,\n meta: _objectSpread({}, window.SITE_CONFIG['contentTabDefault'], {\n menuId: routeParams.menuId,\n title: \"\".concat(routeParams.title)\n })\n };\n router.addRoutes([_objectSpread({}, moduleRoutes, {\n name: \"main-dynamic__\".concat(dynamicRoute.name),\n children: [dynamicRoute]\n })]);\n window.SITE_CONFIG['dynamicRoutes'].push(dynamicRoute);\n router.push({\n name: dynamicRoute.name,\n params: routeParams.params\n });\n}\nvar router = new Router({\n mode: 'hash',\n scrollBehavior: function scrollBehavior() {\n return {\n y: 0\n };\n },\n routes: pageRoutes.concat(moduleRoutes)\n});\nrouter.beforeEach(function (to, from, next) {\n // 添加动态(菜单)路由\n // 已添加或者当前路由为页面路由, 可直接访问\n if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) {\n return next();\n } //行政区域\n\n\n getPersonRegion(); //字典\n\n getDictDataListAll(); // 获取字典列表, 添加并全局变量保存\n\n /* http.get('/sys/dict/type/all').then(({ data: res }) => {\n if (res.code !== 0) {\n return\n }\n window.SITE_CONFIG['dictList'] = res.data\n }).catch(() => {}) */\n // 获取菜单列表, 添加并全局变量保存\n\n http.get('/sys/menu/nav').then(function (_ref) {\n var res = _ref.data;\n\n if (res.code !== 0) {\n Vue.prototype.$message.error(res.msg);\n return next({\n name: 'login'\n });\n }\n\n window.SITE_CONFIG['menuList'] = res.data;\n fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList']);\n next(_objectSpread({}, to, {\n replace: true\n }));\n }).catch(function () {\n next({\n name: 'login'\n });\n });\n});\n/**\n * 判断当前路由是否为页面路由\n * @param {*} route 当前路由\n * @param {*} pageRoutes 页面路由\n */\n\nfunction fnCurrentRouteIsPageRoute(route) {\n var pageRoutes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var temp = [];\n\n for (var i = 0; i < pageRoutes.length; i++) {\n if (route.path === pageRoutes[i].path) {\n return true;\n }\n\n if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) {\n temp = temp.concat(pageRoutes[i].children);\n }\n }\n\n return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false;\n}\n/**\n * 添加动态(菜单)路由\n * @param {*} menuList 菜单列表\n * @param {*} routes 递归创建的动态(菜单)路由\n */\n\n\nfunction fnAddDynamicMenuRoutes() {\n var menuList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var routes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var temp = [];\n\n var _loop = function _loop() {\n if (menuList[i].children && menuList[i].children.length >= 1) {\n temp = temp.concat(menuList[i].children);\n return \"continue\";\n } // 组装路由\n\n\n route = {\n path: '',\n component: null,\n name: '',\n meta: _objectSpread({}, window.SITE_CONFIG['contentTabDefault'], {\n menuId: menuList[i].id,\n title: menuList[i].name\n }) // eslint-disable-next-line\n\n };\n var URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, function (s1, s2) {\n return eval(s2);\n }); // URL支持{{ window.xxx }}占位符变量\n\n if (isURL(URL)) {\n route['path'] = route['name'] = \"i-\".concat(menuList[i].id);\n route['meta']['iframeURL'] = URL;\n } else {\n URL = URL.replace(/^\\//, '').replace(/_/g, '-');\n route['path'] = route['name'] = URL.replace(/\\//g, '-');\n\n route['component'] = function () {\n return import(\"@/views/modules/\".concat(URL));\n };\n }\n\n routes.push(route);\n };\n\n for (var i = 0; i < menuList.length; i++) {\n var route;\n\n var _ret = _loop();\n\n if (_ret === \"continue\") continue;\n }\n\n if (temp.length >= 1) {\n return fnAddDynamicMenuRoutes(temp, routes);\n } // 添加路由\n\n\n router.addRoutes([_objectSpread({}, moduleRoutes, {\n name: 'main-dynamic-menu',\n children: routes\n }), {\n path: '*',\n redirect: {\n name: '404'\n }\n }]);\n window.SITE_CONFIG['dynamicMenuRoutes'] = routes;\n window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true;\n}\n\nexport default router;",{"version":3,"sources":["C:\\Users\\27446\\Desktop\\up\\front\\dkha-web-sz-main\\src\\router\\index.js"],"names":["Vue","Router","http","isURL","getPersonRegion","getDictDataListAll","use","pageRoutes","path","component","name","meta","title","beforeEnter","to","from","next","test","redirectedFrom","replace","moduleRoutes","redirect","children","isTab","addDynamicRoute","routeParams","router","routeName","dynamicRoute","window","SITE_CONFIG","filter","item","push","params","menuId","addRoutes","mode","scrollBehavior","y","routes","concat","beforeEach","fnCurrentRouteIsPageRoute","get","then","res","data","code","prototype","$message","error","msg","fnAddDynamicMenuRoutes","catch","route","temp","i","length","menuList","id","URL","url","s1","s2","eval"],"mappings":";;;;;;;;;;;AAAA,OAAOA,GAAP,MAAgB,KAAhB;AACA,OAAOC,MAAP,MAAmB,YAAnB;AACA,OAAOC,IAAP,MAAiB,iBAAjB;AACA,SAAQC,KAAR,QAAqB,kBAArB;AACA,SAASC,eAAT,EAAyBC,kBAAzB,QAAmD,eAAnD;AAEAL,GAAG,CAACM,GAAJ,CAAQL,MAAR,E,CAEA;;AACA,OAAO,IAAMM,UAAU,GAAG,CACxB;AACEC,EAAAA,IAAI,EAAE,MADR;AAEEC,EAAAA,SAAS,EAAE;AAAA,WAAM,OAAO,mBAAP,CAAN;AAAA,GAFb;AAGEC,EAAAA,IAAI,EAAE,KAHR;AAIEC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,KAAK,EAAE;AAAT,GAJR;AAKEC,EAAAA,WALF,uBAKeC,EALf,EAKmBC,IALnB,EAKyBC,IALzB,EAK+B;AAC3B;AACA;AACA,QAAI,OAAOC,IAAP,CAAYH,EAAE,CAACI,cAAf,CAAJ,EAAoC;AAClC,aAAOF,IAAI,CAACF,EAAE,CAACI,cAAH,CAAkBC,OAAlB,CAA0B,MAA1B,EAAkC,EAAlC,CAAD,CAAX;AACD;;AACDH,IAAAA,IAAI;AACL;AAZH,CADwB,EAexB;AAAER,EAAAA,IAAI,EAAE,QAAR;AAAkBC,EAAAA,SAAS,EAAE;AAAA,WAAM,OAAO,qBAAP,CAAN;AAAA,GAA7B;AAAkEC,EAAAA,IAAI,EAAE,OAAxE;AAAiFC,EAAAA,IAAI,EAAE;AAAEC,IAAAA,KAAK,EAAE;AAAT;AAAvF,CAfwB,CAAnB,C,CAkBP;;AACA,OAAO,IAAMQ,YAAY,GAAG;AAC1BZ,EAAAA,IAAI,EAAE,GADoB;AAE1BC,EAAAA,SAAS,EAAE;AAAA,WAAM,OAAO,cAAP,CAAN;AAAA,GAF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AHD,MAGO;AACLA,MAAAA,GAAG,GAAGA,GAAG,CAAC1C,OAAJ,CAAY,KAAZ,EAAmB,EAAnB,EAAuBA,OAAvB,CAA+B,IAA/B,EAAqC,GAArC,CAAN;AACAoC,MAAAA,KAAK,CAAC,MAAD,CAAL,GAAgBA,KAAK,CAAC,MAAD,CAAL,GAAgBM,GAAG,CAAC1C,OAAJ,CAAY,KAAZ,EAAmB,GAAnB,CAAhC;;AACAoC,MAAAA,KAAK,CAAC,WAAD,CAAL,GAAqB;AAAA,eAAM,iCAA0BM,GAA1B,EAAN;AAAA,OAArB;AACD;;AACDrB,IAAAA,MAAM,CAACP,IAAP,CAAYsB,KAAZ;AA5ByD;;AAE3D,OAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGE,QAAQ,CAACD,MAA7B,EAAqCD,CAAC,EAAtC,EAA0C;AAAA,QAMpCF,KANoC;;AAAA;;AAAA,6BAGtC;AAwBH;;AACD,MAAIC,IAAI,CAACE,MAAL,IAAe,CAAnB,EAAsB;AACpB,WAAOL,sBAAsB,CAACG,IAAD,EAAOhB,MAAP,CAA7B;AACD,GAhC0D,CAiC3D;;;AACAd,EAAAA,MAAM,CAACU,SAAP,CAAiB,mBAEVhB,YAFU;AAGbV,IAAAA,IAAI,EAAE,mBAHO;AAIbY,IAAAA,QAAQ,EAAEkB;AAJG,MAMf;AAAEhC,IAAAA,IAAI,EAAE,GAAR;AAAaa,IAAAA,QAAQ,EAAE;AAAEX,MAAAA,IAAI,EAAE;AAAR;AAAvB,GANe,CAAjB;AAQAmB,EAAAA,MAAM,CAACC,WAAP,CAAmB,mBAAnB,IAA0CU,MAA1C;AACAX,EAAAA,MAAM,CAACC,WAAP,CAAmB,2BAAnB,IAAkD,IAAlD;AACD;;AAED,eAAeJ,MAAf","sourcesContent":["import Vue from 'vue'\nimport Router from 'vue-router'\nimport http from '@/utils/request'\nimport {isURL } from '@/utils/validate'\nimport { getPersonRegion,getDictDataListAll } from '@/utils/index'\n\nVue.use(Router)\n\n// 页面路由(独立页面)\nexport const pageRoutes = [\n {\n path: '/404',\n component: () => import('@/views/pages/404'),\n name: '404',\n meta: { title: '404未找到' },\n beforeEnter (to, from, next) {\n // 拦截处理特殊业务场景\n // 如果, 重定向路由包含__双下划线, 为临时添加路由\n if (/__.*/.test(to.redirectedFrom)) {\n return next(to.redirectedFrom.replace(/__.*/, ''))\n }\n next()\n }\n },\n { path: '/login', component: () => import('@/views/pages/login'), name: 'login', meta: { title: '登录' } }\n]\n\n// 模块路由(基于主入口布局页面)\nexport const moduleRoutes = {\n path: '/',\n component: () => import('@/views/main'),\n name: 'main',\n redirect: { name: 'home' },\n meta: { title: '主入口布局' },\n children: [\n { path: '/home', component: () => import('@/views/modules/home'), name: 'home', meta: { title: '首页', isTab: true } }\n ]\n}\n\nexport function addDynamicRoute (routeParams, router) {\n // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转\n var routeName = routeParams.routeName\n var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter(item => item.name === routeName)[0]\n if (dynamicRoute) {\n return router.push({ name: routeName, params: routeParams.params })\n }\n // 否则: 添加并全局变量保存, 再跳转\n dynamicRoute = {\n path: routeName,\n component: () => import(`@/views/modules/${routeParams.path}`),\n name: routeName,\n meta: {\n ...window.SITE_CONFIG['contentTabDefault'],\n menuId: routeParams.menuId,\n title: `${routeParams.title}`\n }\n }\n router.addRoutes([\n {\n ...moduleRoutes,\n name: `main-dynamic__${dynamicRoute.name}`,\n children: [dynamicRoute]\n }\n ])\n window.SITE_CONFIG['dynamicRoutes'].push(dynamicRoute)\n router.push({ name: dynamicRoute.name, params: routeParams.params })\n}\n\nconst router = new Router({\n mode: 'hash',\n scrollBehavior: () => ({ y: 0 }),\n routes: pageRoutes.concat(moduleRoutes)\n})\n\nrouter.beforeEach((to, from, next) => {\n // 添加动态(菜单)路由\n // 已添加或者当前路由为页面路由, 可直接访问\n if (window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || fnCurrentRouteIsPageRoute(to, pageRoutes)) {\n return next()\n }\n //行政区域\n getPersonRegion()\n //字典\n getDictDataListAll()\n // 获取字典列表, 添加并全局变量保存\n /* http.get('/sys/dict/type/all').then(({ data: res }) => {\n if (res.code !== 0) {\n return\n }\n window.SITE_CONFIG['dictList'] = res.data\n }).catch(() => {}) */\n // 获取菜单列表, 添加并全局变量保存\n http.get('/sys/menu/nav').then(({ data: res }) => {\n if (res.code !== 0) {\n Vue.prototype.$message.error(res.msg)\n return next({ name: 'login' })\n }\n window.SITE_CONFIG['menuList'] = res.data\n fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])\n next({ ...to, replace: true })\n }).catch(() => {\n next({ name: 'login' })\n })\n})\n\n/**\n * 判断当前路由是否为页面路由\n * @param {*} route 当前路由\n * @param {*} pageRoutes 页面路由\n */\nfunction fnCurrentRouteIsPageRoute (route, pageRoutes = []) {\n var temp = []\n for (var i = 0; i < pageRoutes.length; i++) {\n if (route.path === pageRoutes[i].path) {\n return true\n }\n if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) {\n temp = temp.concat(pageRoutes[i].children)\n }\n }\n return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false\n}\n\n/**\n * 添加动态(菜单)路由\n * @param {*} menuList 菜单列表\n * @param {*} routes 递归创建的动态(菜单)路由\n */\nfunction fnAddDynamicMenuRoutes (menuList = [], routes = []) {\n var temp = []\n for (var i = 0; i < menuList.length; i++) {\n if (menuList[i].children && menuList[i].children.length >= 1) {\n temp = temp.concat(menuList[i].children)\n continue\n }\n // 组装路由\n var route = {\n path: '',\n component: null,\n name: '',\n meta: {\n ...window.SITE_CONFIG['contentTabDefault'],\n menuId: menuList[i].id,\n title: menuList[i].name\n }\n }\n // eslint-disable-next-line\n let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2)) // URL支持{{ window.xxx }}占位符变量\n if (isURL(URL)) {\n route['path'] = route['name'] = `i-${menuList[i].id}`\n route['meta']['iframeURL'] = URL\n } else {\n URL = URL.replace(/^\\//, '').replace(/_/g, '-')\n route['path'] = route['name'] = URL.replace(/\\//g, '-')\n route['component'] = () => import(`@/views/modules/${URL}`)\n }\n routes.push(route)\n }\n if (temp.length >= 1) {\n return fnAddDynamicMenuRoutes(temp, routes)\n }\n // 添加路由\n router.addRoutes([\n {\n ...moduleRoutes,\n name: 'main-dynamic-menu',\n children: routes\n },\n { path: '*', redirect: { name: '404' } }\n ])\n window.SITE_CONFIG['dynamicMenuRoutes'] = routes\n window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true\n}\n\nexport default router\n"]}]}