hz-zhhq-web/node_modules/.cache/babel-loader/a6037f8181cc258ca954f6886d5...

1 line
4.4 KiB
JSON

{"remainingRequest":"E:\\hz-zhhq-web\\node_modules\\thread-loader\\dist\\cjs.js!E:\\hz-zhhq-web\\node_modules\\babel-loader\\lib\\index.js!E:\\hz-zhhq-web\\src\\store\\modules\\permission.js","dependencies":[{"path":"E:\\hz-zhhq-web\\src\\store\\modules\\permission.js","mtime":1737610069395},{"path":"E:\\hz-zhhq-web\\babel.config.js","mtime":1737610069371},{"path":"E:\\hz-zhhq-web\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"E:\\hz-zhhq-web\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"E:\\hz-zhhq-web\\node_modules\\babel-loader\\lib\\index.js","mtime":456789000000}],"contextDependencies":[],"result":["import _regeneratorRuntime from \"E:/hz-zhhq-web/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js\";\nimport _objectSpread from \"E:/hz-zhhq-web/node_modules/@babel/runtime/helpers/esm/objectSpread2.js\";\nimport \"regenerator-runtime/runtime\";\nimport _asyncToGenerator from \"E:/hz-zhhq-web/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport \"core-js/modules/web.dom.iterable\";\nimport \"core-js/modules/es7.array.includes\";\nimport \"core-js/modules/es6.string.includes\";\nimport { asyncRoutes, constantRoutes, a } from '@/router';\n// import { asyncRoutes } from '@/router'\n\n/**\r\n * Use meta.role to determine if the current user has permission\r\n * @param roles\r\n * @param route\r\n */\n\nfunction hasPermission(roles, route) {\n // console.log(roles,route,'角色大大')\n if (route.meta && route.meta.role) {\n return roles.some(function (role) {\n return route.meta.roles.includes(role);\n });\n } else {\n return true;\n }\n}\n// console.log(asyncRoutes,constantRoutes,100)\n\n/**\r\n * Filter asynchronous routing tables by recursion\r\n * @param routes asyncRoutes\r\n * @param roles\r\n */\nexport function filterAsyncRoutes(routes, roles) {\n var res = [];\n routes.forEach(/*#__PURE__*/function () {\n var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(route) {\n var tmp, _res;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n tmp = _objectSpread({}, route);\n if (!hasPermission(roles, tmp)) {\n _context.next = 8;\n break;\n }\n if (tmp.children) {\n tmp.children = filterAsyncRoutes(tmp.children, roles);\n }\n _res.push(tmp);\n _context.next = 6;\n return a;\n case 6:\n _res = _context.sent;\n // console.log(res,52)\n\n accessedRoutes = _res || [];\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }());\n // console.log(res,37)\n return res;\n}\nvar state = {\n routes: [],\n addRoutes: []\n};\nvar mutations = {\n SET_ROUTES: function SET_ROUTES(state, routes) {\n state.addRoutes = routes;\n state.routes = constantRoutes.concat(routes);\n }\n};\nvar actions = {\n generateRoutes: function () {\n var _generateRoutes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2, roles) {\n var commit, res;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n commit = _ref2.commit;\n _context2.next = 3;\n return a;\n case 3:\n res = _context2.sent;\n return _context2.abrupt(\"return\", new Promise(function (resolve) {\n var accessedRoutes;\n if (roles.includes('adxxmin')) {\n accessedRoutes = res || [];\n } else {\n accessedRoutes = filterAsyncRoutes(res, roles);\n }\n commit('SET_ROUTES', accessedRoutes);\n resolve(accessedRoutes);\n }));\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n function generateRoutes(_x2, _x3) {\n return _generateRoutes.apply(this, arguments);\n }\n return generateRoutes;\n }()\n};\nexport default {\n namespaced: true,\n state: state,\n mutations: mutations,\n actions: actions\n};",null]}