1 line
12 KiB
JSON
1 line
12 KiB
JSON
{"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\\permission.js","dependencies":[{"path":"D:\\phpstudy_pro\\WWW\\travel\\admin\\src\\permission.js","mtime":1718070786028},{"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:aW1wb3J0IF9yZWdlbmVyYXRvclJ1bnRpbWUgZnJvbSAiRDovcGhwc3R1ZHlfcHJvL1dXVy90cmF2ZWwvYWRtaW4vbm9kZV9tb2R1bGVzL0BiYWJlbC9ydW50aW1lL2hlbHBlcnMvZXNtL3JlZ2VuZXJhdG9yUnVudGltZS5qcyI7CmltcG9ydCBfb2JqZWN0U3ByZWFkIGZyb20gIkQ6L3BocHN0dWR5X3Byby9XV1cvdHJhdmVsL2FkbWluL25vZGVfbW9kdWxlcy9AYmFiZWwvcnVudGltZS9oZWxwZXJzL2VzbS9vYmplY3RTcHJlYWQyLmpzIjsKaW1wb3J0IF9hc3luY1RvR2VuZXJhdG9yIGZyb20gIkQ6L3BocHN0dWR5X3Byby9XV1cvdHJhdmVsL2FkbWluL25vZGVfbW9kdWxlcy9AYmFiZWwvcnVudGltZS9oZWxwZXJzL2VzbS9hc3luY1RvR2VuZXJhdG9yLmpzIjsKaW1wb3J0IHJvdXRlciBmcm9tICcuL3JvdXRlcic7CmltcG9yd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ICAvLyBzdGFydCBwcm9ncmVzcyBiYXIKICAgICAgICAgIE5Qcm9ncmVzcy5zdGFydCgpOwoKICAgICAgICAgIC8vIHNldCBwYWdlIHRpdGxlCiAgICAgICAgICBkb2N1bWVudC50aXRsZSA9IGdldFBhZ2VUaXRsZSh0by5tZXRhLnRpdGxlKTsKCiAgICAgICAgICAvLyBkZXRlcm1pbmUgd2hldGhlciB0aGUgdXNlciBoYXMgbG9nZ2VkIGluCiAgICAgICAgICBoYXNUb2tlbiA9IGdldFRva2VuKCk7CiAgICAgICAgICBpZiAoIWhhc1Rva2VuKSB7CiAgICAgICAgICAgIF9jb250ZXh0Lm5leHQgPSAzNTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoISh0by5wYXRoID09PSAnL2xvZ2luJykpIHsKICAgICAgICAgICAgX2NvbnRleHQubmV4dCA9IDk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgLy8gaWYgaXMgbG9nZ2VkIGluLCByZWRpcmVjdCB0byB0aGUgaG9tZSBwYWdlCiAgICAgICAgICBuZXh0KHsKICAgICAgICAgICAgcGF0aDogJy8nCiAgICAgICAgICB9KTsKICAgICAgICAgIE5Qcm9ncmVzcy5kb25lKCk7IC8vIGhhY2s6IGh0dHBzOi8vZ2l0aHViLmNvbS9QYW5KaWFDaGVuL3Z1ZS1lbGVtZW50LWFkbWluL3B1bGwvMjkzOQogICAgICAgICAgX2NvbnRleHQubmV4dCA9IDMzOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA5OgogICAgICAgICAgLy8gZGV0ZXJtaW5lIHdoZXRoZXIgdGhlIHVzZXIgaGFzIG9idGFpbmVkIGhpcyBwZXJtaXNzaW9uIHJvbGVzIHRocm91Z2ggZ2V0SW5mbwogICAgICAgICAgaGFzUm9sZXMgPSBzdG9yZS5nZXR0ZXJzLnJvbGVzICYmIHN0b3JlLmdldHRlcnMucm9sZXMubGVuZ3R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Swge30sIHsKICAgICAgICAgICAgcmVwbGFjZTogdHJ1ZQogICAgICAgICAgfSkpOwogICAgICAgICAgX2NvbnRleHQubmV4dCA9IDMzOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyNjoKICAgICAgICAgIF9jb250ZXh0LnByZXYgPSAyNjsKICAgICAgICAgIF9jb250ZXh0LnQwID0gX2NvbnRleHRbImNhdGNoIl0oMTQpOwogICAgICAgICAgX2NvbnRleHQubmV4dCA9IDMwOwogICAgICAgICAgcmV0dXJuIHN0b3JlLmRpc3BhdGNoKCd1c2VyL3Jlc2V0VG9rZW4nKTsKICAgICAgICBjYXNlIDMwOgogICAgICAgICAgTWVzc2FnZS5lcnJvcihfY29udGV4dC50MCB8fCAnSGFzIEVycm9yJyk7CiAgICAgICAgICBuZXh0KCIvbG9naW4/cmVkaXJlY3Q9Ii5jb25jYXQodG8ucGF0aCkpOwogICAgICAgICAgTlByb2dyZXNzLmRvbmUoKTsKICAgICAgICBjYXNlIDMzOgogICAgICAgICAgX2NvbnRleHQubmV4dCA9IDM2OwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAzNToKICAgICAgICAgIC8qIGhhcyBubyB0b2tlbiovCgogICAgICAgICAgaWYgKHdoaXRlTGlzdC5pbmRleE9mKHRvLnBhdGgpICE9PSAtMSkgewogICAgICAgICAgICAvLyBpbiB0aGUgZnJlZSBsb2dpbiB3aGl0ZWxpc3QsIGdvIGRpcmVjdGx5CiAgICAgICAgICAgIG5leHQoKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIG90aGVyIHBhZ2VzIHRoYXQgZG8gbm90IGhhdmUgcGVybWlzc2lvbiB0byBhY2Nlc3MgYXJlIHJlZGlyZWN0ZWQgdG8gdGhlIGxvZ2luIHBhZ2UuCiAgICAgICAgICAgIG5leHQoIi9sb2dpbj9yZWRpcmVjdD0iLmNvbmNhdCh0by5wYXRoKSk7CiAgICAgICAgICAgIE5Qcm9ncmVzcy5kb25lKCk7CiAgICAgICAgICB9CiAgICAgICAgY2FzZSAzNjoKICAgICAgICBjYXNlICJlbmQiOgogICAgICAgICAgcmV0dXJuIF9jb250ZXh0LnN0b3AoKTsKICAgICAgfQogICAgfSwgX2NhbGxlZSwgbnVsbCwgW1sxNCwgMjZdXSk7CiAgfSkpOwogIHJldHVybiBmdW5jdGlvbiAoX3gsIF94MiwgX3gzKSB7CiAgICByZXR1cm4gX3JlZi5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogIH07Cn0oKSk7CnJvdXRlci5hZnRlckVhY2goZnVuY3Rpb24gKCkgewogIC8vIGZpbmlzaCBwcm9ncmVzcyBiYXIKICBOUHJvZ3Jlc3MuZG9uZSgpOwp9KTs="},{"version":3,"names":["router","store","Message","NProgress","getToken","getPageTitle","configure","showSpinner","whiteList","beforeEach","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","to","from","next","hasToken","hasRoles","_yield$store$dispatch","roles","accessRoutes","wrap","_callee$","_context","prev","start","document","title","meta","path","done","getters","length","dispatch","sent","addRoutes","_objectSpread","replace","t0","error","concat","indexOf","stop","_x","_x2","_x3","apply","arguments","afterEach"],"sources":["D:/phpstudy_pro/WWW/travel/admin/src/permission.js"],"sourcesContent":["import router from './router'\r\nimport store from './store'\r\nimport { Message } from 'element-ui'\r\nimport NProgress from 'nprogress' // progress bar\r\nimport 'nprogress/nprogress.css' // progress bar style\r\nimport { getToken } from '@/utils/auth' // get token from cookie\r\nimport getPageTitle from '@/utils/get-page-title'\r\n\r\nNProgress.configure({ showSpinner: false }) // NProgress Configuration\r\n\r\nconst whiteList = ['/login', '/auth-redirect'] // no redirect whitelist\r\n\r\nrouter.beforeEach(async(to, from, next) => {\r\n // start progress bar\r\n NProgress.start()\r\n\r\n // set page title\r\n document.title = getPageTitle(to.meta.title)\r\n\r\n // determine whether the user has logged in\r\n const hasToken = getToken()\r\n\r\n if (hasToken) {\r\n if (to.path === '/login') {\r\n // if is logged in, redirect to the home page\r\n next({ path: '/' })\r\n NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939\r\n } else {\r\n // determine whether the user has obtained his permission roles through getInfo\r\n const hasRoles = store.getters.roles && store.getters.roles.length > 0\r\n if (hasRoles) {\r\n next()\r\n } else {\r\n try {\r\n // get user info\r\n // note: roles must be a object array! such as: ['admin'] or ,['developer','editor']\r\n const { roles } = await store.dispatch('user/getInfo')\r\n\r\n // generate accessible routes map based on roles\r\n const accessRoutes = await store.dispatch('permission/generateRoutes', roles)\r\n\r\n // dynamically add accessible routes\r\n router.addRoutes(accessRoutes)\r\n\r\n // hack method to ensure that addRoutes is complete\r\n // set the replace: true, so the navigation will not leave a history record\r\n next({ ...to, replace: true })\r\n } catch (error) {\r\n // remove token and go to login page to re-login\r\n await store.dispatch('user/resetToken')\r\n Message.error(error || 'Has Error')\r\n next(`/login?redirect=${to.path}`)\r\n NProgress.done()\r\n }\r\n }\r\n }\r\n } else {\r\n /* has no token*/\r\n\r\n if (whiteList.indexOf(to.path) !== -1) {\r\n // in the free login whitelist, go directly\r\n next()\r\n } else {\r\n // other pages that do not have permission to access are redirected to the login page.\r\n next(`/login?redirect=${to.path}`)\r\n NProgress.done()\r\n }\r\n }\r\n})\r\n\r\nrouter.afterEach(() => {\r\n // finish progress bar\r\n NProgress.done()\r\n})\r\n"],"mappings":";;;AAAA,OAAOA,MAAM,MAAM,UAAU;AAC7B,OAAOC,KAAK,MAAM,SAAS;AAC3B,SAASC,OAAO,QAAQ,YAAY;AACpC,OAAOC,SAAS,MAAM,WAAW,EAAC;AAClC,OAAO,yBAAyB,EAAC;AACjC,SAASC,QAAQ,QAAQ,cAAc,EAAC;AACxC,OAAOC,YAAY,MAAM,wBAAwB;AAEjDF,SAAS,CAACG,SAAS,CAAC;EAAEC,WAAW,EAAE;AAAM,CAAC,CAAC,EAAC;;AAE5C,IAAMC,SAAS,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,EAAC;;AAE/CR,MAAM,CAACS,U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