{"remainingRequest":"D:\\phpstudy_pro\\WWW\\travel\\admin\\node_modules\\babel-loader\\lib\\index.js!D:\\phpstudy_pro\\WWW\\travel\\admin\\node_modules\\eslint-loader\\index.js??ref--13-0!D:\\phpstudy_pro\\WWW\\travel\\admin\\src\\store\\modules\\permission.js","dependencies":[{"path":"D:\\phpstudy_pro\\WWW\\travel\\admin\\src\\store\\modules\\permission.js","mtime":1718070786031},{"path":"D:\\phpstudy_pro\\WWW\\travel\\admin\\babel.config.js","mtime":1718070785981},{"path":"D:\\phpstudy_pro\\WWW\\travel\\admin\\node_modules\\cache-loader\\dist\\cjs.js","mtime":1718764957200},{"path":"D:\\phpstudy_pro\\WWW\\travel\\admin\\node_modules\\babel-loader\\lib\\index.js","mtime":1718764959024},{"path":"D:\\phpstudy_pro\\WWW\\travel\\admin\\node_modules\\eslint-loader\\index.js","mtime":1718764957746}],"contextDependencies":[],"result":[{"type":"Buffer","data":"base64:aW1wb3J0IF9vYmplY3RTcHJlYWQgZnJvbSAiRDovcGhwc3R1ZHlfcHJvL1dXVy90cmF2ZWwvYWRtaW4vbm9kZV9tb2R1bGVzL0BiYWJlbC9ydW50aW1lL2hlbHBlcnMvZXNtL29iamVjdFNwcmVhZDIuanMiOwppbXBvcnQgImNvcmUtanMvbW9kdWxlcy9lcy5hcnJheS5jb25jYXQuanMiOwppbXBvcnQgImNvcmUtanMvbW9kdWxlcy9lcy5hcnJheS5pbmNsdWRlcy5qcyI7CmltcG9ydCAiY29yZS1qcy9tb2R1bGVzL2VzLm9iamVjdC50by1zdHJpbmcuanMiOwppbXBvcnQgImNvcmUtanMvbW9kdWxlcy9lcy5zdHJpbmcuaW5jbHVkZXMuanMiOwppbXBvcnQgImNvcmUtanMvbW9kdWxlcy93ZWIuZG9tLWNvbGxlY3Rpb25zLmZvci1lYWNoLmpzIjsKaW1wb3J0IHsgYXN5bmNSb3V0ZXMsIGNvbnN0YW50Um91dGVzIH0gZnJvbSAnQC9yb3V0ZXInOwoKLyoqDQog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5jdGlvbiBTRVRfUk9VVEVTKHN0YXRlLCByb3V0ZXMpIHsKICAgIHN0YXRlLmFkZFJvdXRlcyA9IHJvdXRlczsKICAgIHN0YXRlLnJvdXRlcyA9IGNvbnN0YW50Um91dGVzLmNvbmNhdChyb3V0ZXMpOwogIH0KfTsKdmFyIGFjdGlvbnMgPSB7CiAgZ2VuZXJhdGVSb3V0ZXM6IGZ1bmN0aW9uIGdlbmVyYXRlUm91dGVzKF9yZWYsIHJvbGVzKSB7CiAgICB2YXIgY29tbWl0ID0gX3JlZi5jb21taXQ7CiAgICByZXR1cm4gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUpIHsKICAgICAgdmFyIGFjY2Vzc2VkUm91dGVzOwogICAgICBpZiAocm9sZXMuaW5jbHVkZXMoJ2FkbWluJykpIHsKICAgICAgICBhY2Nlc3NlZFJvdXRlcyA9IGFzeW5jUm91dGVzIHx8IFtdOwogICAgICB9IGVsc2UgewogICAgICAgIGFjY2Vzc2VkUm91dGVzID0gZmlsdGVyQXN5bmNSb3V0ZXMoYXN5bmNSb3V0ZXMsIHJvbGVzKTsKICAgICAgfQogICAgICBjb21taXQoJ1NFVF9ST1VURVMnLCBhY2Nlc3NlZFJvdXRlcyk7CiAgICAgIHJlc29sdmUoYWNjZXNzZWRSb3V0ZXMpOwogICAgfSk7CiAgfQp9OwpleHBvcnQgZGVmYXVsdCB7CiAgbmFtZXNwYWNlZDogdHJ1ZSwKICBzdGF0ZTogc3RhdGUsCiAgbXV0YXRpb25zOiBtdXRhdGlvbnMsCiAgYWN0aW9uczogYWN0aW9ucwp9Ow=="},{"version":3,"names":["asyncRoutes","constantRoutes","hasPermission","roles","route","meta","some","role","includes","filterAsyncRoutes","routes","res","forEach","tmp","_objectSpread","children","push","state","addRoutes","mutations","SET_ROUTES","concat","actions","generateRoutes","_ref","commit","Promise","resolve","accessedRoutes","namespaced"],"sources":["D:/phpstudy_pro/WWW/travel/admin/src/store/modules/permission.js"],"sourcesContent":["import { asyncRoutes, constantRoutes } from '@/router'\r\n\r\n/**\r\n * Use meta.role to determine if the current user has permission\r\n * @param roles\r\n * @param route\r\n */\r\nfunction hasPermission(roles, route) {\r\n if (route.meta && route.meta.roles) {\r\n return roles.some(role => route.meta.roles.includes(role))\r\n } else {\r\n return true\r\n }\r\n}\r\n\r\n/**\r\n * Filter asynchronous routing tables by recursion\r\n * @param routes asyncRoutes\r\n * @param roles\r\n */\r\nexport function filterAsyncRoutes(routes, roles) {\r\n const res = []\r\n\r\n routes.forEach(route => {\r\n const tmp = { ...route }\r\n if (hasPermission(roles, tmp)) {\r\n if (tmp.children) {\r\n tmp.children = filterAsyncRoutes(tmp.children, roles)\r\n }\r\n res.push(tmp)\r\n }\r\n })\r\n\r\n return res\r\n}\r\n\r\nconst state = {\r\n routes: [],\r\n addRoutes: []\r\n}\r\n\r\nconst mutations = {\r\n SET_ROUTES: (state, routes) => {\r\n state.addRoutes = routes\r\n state.routes = constantRoutes.concat(routes)\r\n }\r\n}\r\n\r\nconst actions = {\r\n generateRoutes({ commit }, roles) {\r\n return new Promise(resolve => {\r\n let accessedRoutes\r\n if (roles.includes('admin')) {\r\n accessedRoutes = asyncRoutes || []\r\n } else {\r\n accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)\r\n }\r\n commit('SET_ROUTES', accessedRoutes)\r\n resolve(accessedRoutes)\r\n })\r\n }\r\n}\r\n\r\nexport default {\r\n namespaced: true,\r\n state,\r\n mutations,\r\n actions\r\n}\r\n"],"mappings":";;;;;;AAAA,SAASA,WAAW,EAAEC,cAAc,QAAQ,UAAU;;AAEtD;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAACC,KAAK,EAAEC,KAAK,EAAE;EACnC,IAAIA,KAAK,CAACC,IAAI,IAAID,KAAK,CAACC,IAAI,CAACF,KAAK,EAAE;IAClC,OAAOA,KAAK,CAACG,IAAI,CAAC,UAAAC,IAAI;MAAA,OAAIH,KAAK,CAACC,IAAI,CAACF,KAAK,CAACK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