1 |
- {"remainingRequest":"/Users/lihai/jolijoli/pad_spa/node_modules/babel-loader/lib/index.js!/Users/lihai/jolijoli/pad_spa/node_modules/eslint-loader/index.js??ref--13-0!/Users/lihai/jolijoli/pad_spa/src/common/auth.js","dependencies":[{"path":"/Users/lihai/jolijoli/pad_spa/src/common/auth.js","mtime":1652252745533},{"path":"/Users/lihai/jolijoli/pad_spa/babel.config.js","mtime":1649813268617},{"path":"/Users/lihai/jolijoli/pad_spa/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/lihai/jolijoli/pad_spa/node_modules/babel-loader/lib/index.js","mtime":315532800000},{"path":"/Users/lihai/jolijoli/pad_spa/node_modules/eslint-loader/index.js","mtime":499162500000}],"contextDependencies":[],"result":["import { logFlag, logPath } from '@/config/env';\nvar isFirst = false;\nexport default (function (router, hasLogin) {\n router.beforeEach(function (to, from, next) {\n if (to.meta.title) {\n document.title = to.meta.title;\n }\n\n isFirst = globalVue ? false : true;\n\n if (to.meta.auth && !hasLogin) {\n //需要登录而未登录\n var backUrl = _getTargetUrl(to, from);\n\n tool.toLogin(backUrl); //如果不加backUrl则登录回调会跳转到前一个页面\n } else {\n next();\n }\n });\n});\n\nfunction _getTargetUrl(to, from) {\n var backUrl = location.href.split(\"?\")[0];\n\n if (!isFirst) {\n //只有非首次进入才做处理\n if (from.path === '/' && to.path != '/') {\n //首页到其它页\n backUrl += to.path.slice(1);\n } else {\n //其它页互相跳(包括跳到首页)\n backUrl = backUrl.replace(from.path, to.path);\n }\n }\n\n if (location.search) {\n backUrl += location.search;\n }\n\n return backUrl;\n}",{"version":3,"sources":["/Users/lihai/jolijoli/pad_spa/src/common/auth.js"],"names":["logFlag","logPath","isFirst","router","hasLogin","beforeEach","to","from","next","meta","title","document","globalVue","auth","backUrl","_getTargetUrl","tool","toLogin","location","href","split","path","slice","replace","search"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,OAAlB,QAAiC,cAAjC;AACA,IAAIC,OAAO,GAAG,KAAd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env'\nlet isFirst = false;\nexport default (router, hasLogin) => {\n router.beforeEach((to, from, next) => {\n if (to.meta.title) {\n document.title = to.meta.title;\n }\n isFirst = globalVue ? false : true;\n if (to.meta.auth && !hasLogin) { //需要登录而未登录\n let backUrl = _getTargetUrl(to, from);\n tool.toLogin(backUrl);//如果不加backUrl则登录回调会跳转到前一个页面\n } else {\n next()\n }\n })\n}\n\nfunction _getTargetUrl (to, from) {\n let backUrl = location.href.split(\"?\")[0];\n if (!isFirst) { //只有非首次进入才做处理\n if (from.path === '/' && to.path != '/') { //首页到其它页\n backUrl += to.path.slice(1);\n } else { //其它页互相跳(包括跳到首页)\n backUrl = backUrl.replace(from.path, to.path);\n }\n }\n\n if (location.search) {\n backUrl += location.search;\n }\n return backUrl;\n}"]}]}
|