fix(hooks): 修复toLogin函数导致登录重定向地址过多

This commit is contained in:
Soybean 2021-09-16 18:43:52 +08:00
parent c84c37d1a6
commit b4adf678a4
4 changed files with 26 additions and 16 deletions

View File

@ -1868,7 +1868,7 @@ packages:
dev: true
registry.nlark.com/@babel/helper-validator-identifier/7.14.9:
resolution: {integrity: sha1-ZlTRcbICT22O4VG/JQlpmRkTHUg=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@babel/helper-validator-identifier/download/@babel/helper-validator-identifier-7.14.9.tgz}
resolution: {integrity: sha1-ZlTRcbICT22O4VG/JQlpmRkTHUg=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@babel/helper-validator-identifier/download/@babel/helper-validator-identifier-7.14.9.tgz}
name: '@babel/helper-validator-identifier'
version: 7.14.9
engines: {node: '>=6.9.0'}
@ -3022,7 +3022,7 @@ packages:
dev: true
registry.nlark.com/call-bind/1.0.2:
resolution: {integrity: sha1-sdTonmiBGcPJqQOtMKuy9qkZvjw=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/call-bind/download/call-bind-1.0.2.tgz}
resolution: {integrity: sha1-sdTonmiBGcPJqQOtMKuy9qkZvjw=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/call-bind/download/call-bind-1.0.2.tgz}
name: call-bind
version: 1.0.2
dependencies:
@ -3913,7 +3913,7 @@ packages:
optional: true
registry.nlark.com/function-bind/1.1.1:
resolution: {integrity: sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/function-bind/download/function-bind-1.1.1.tgz}
resolution: {integrity: sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/function-bind/download/function-bind-1.1.1.tgz}
name: function-bind
version: 1.1.1
dev: true
@ -3925,7 +3925,7 @@ packages:
dev: true
registry.nlark.com/get-intrinsic/1.1.1:
resolution: {integrity: sha1-FfWfN2+FXERpY5SPDSTNNje0q8Y=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/get-intrinsic/download/get-intrinsic-1.1.1.tgz}
resolution: {integrity: sha1-FfWfN2+FXERpY5SPDSTNNje0q8Y=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/get-intrinsic/download/get-intrinsic-1.1.1.tgz}
name: get-intrinsic
version: 1.1.1
dependencies:
@ -4031,14 +4031,14 @@ packages:
dev: true
registry.nlark.com/has-symbols/1.0.2:
resolution: {integrity: sha1-Fl0wcMADCXUqEjakeTMeOsVvFCM=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/has-symbols/download/has-symbols-1.0.2.tgz}
resolution: {integrity: sha1-Fl0wcMADCXUqEjakeTMeOsVvFCM=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/has-symbols/download/has-symbols-1.0.2.tgz}
name: has-symbols
version: 1.0.2
engines: {node: '>= 0.4'}
dev: true
registry.nlark.com/has-tostringtag/1.0.0:
resolution: {integrity: sha1-fhM4GKfTlHNPlB5zw9P5KR5liyU=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/has-tostringtag/download/has-tostringtag-1.0.0.tgz}
resolution: {integrity: sha1-fhM4GKfTlHNPlB5zw9P5KR5liyU=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/has-tostringtag/download/has-tostringtag-1.0.0.tgz}
name: has-tostringtag
version: 1.0.0
engines: {node: '>= 0.4'}
@ -4270,7 +4270,7 @@ packages:
dev: true
registry.nlark.com/is-regex/1.1.4:
resolution: {integrity: sha1-7vVmPNWfpMCuM5UFMj32hUuxWVg=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-regex/download/is-regex-1.1.4.tgz}
resolution: {integrity: sha1-7vVmPNWfpMCuM5UFMj32hUuxWVg=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-regex/download/is-regex-1.1.4.tgz}
name: is-regex
version: 1.1.4
engines: {node: '>= 0.4'}
@ -4696,7 +4696,7 @@ packages:
dev: true
registry.nlark.com/object-assign/4.1.1:
resolution: {integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/object-assign/download/object-assign-4.1.1.tgz}
resolution: {integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/object-assign/download/object-assign-4.1.1.tgz}
name: object-assign
version: 4.1.1
engines: {node: '>=0.10.0'}
@ -5508,7 +5508,7 @@ packages:
dev: true
registry.nlark.com/to-fast-properties/2.0.0:
resolution: {integrity: sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/to-fast-properties/download/to-fast-properties-2.0.0.tgz}
resolution: {integrity: sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/to-fast-properties/download/to-fast-properties-2.0.0.tgz}
name: to-fast-properties
version: 2.0.0
engines: {node: '>=4'}

View File

@ -9,6 +9,7 @@
align-items: center;
width: 100%;
height: 100%;
background-color:#f5f7f9;
}
.app-loading_logo {
width: 128px;

View File

@ -1,4 +1,5 @@
import { useRouter } from 'vue-router';
import type { RouteLocationRaw } from 'vue-router';
import { router as globalRouter, RouteNameMap } from '@/router';
import type { LoginModuleType } from '@/interface';
@ -8,7 +9,7 @@ interface LoginRedirect {
* - current: 取当前的地址作为重定向地址
* - custom: 自定义地址作为重定向地址
*/
type: 'current' | 'custom';
type: 'current' | 'custom' | 'no';
/** 自定义地址 */
url: string;
}
@ -28,15 +29,23 @@ export default function useRouterChange(inSetup: boolean = true) {
/**
* (vue路由)
* @param module -
* @param addRedirect -
* @param redirect -
*/
function toLogin(module: LoginModuleType = 'pwd-login', redirect: LoginRedirect = { type: 'current', url: '' }) {
function toLogin(
module: LoginModuleType = 'pwd-login',
addRedirect: boolean = false,
redirect: LoginRedirect = { type: 'current', url: '' }
) {
const redirectUrl = redirect.type === 'current' ? window.location.href : redirect.url;
router.push({
const routeLocation: RouteLocationRaw = {
name: RouteNameMap.get('login'),
params: { module },
query: { redirectUrl }
});
params: { module }
};
if (addRedirect) {
routeLocation.query = { redirectUrl };
}
router.push(routeLocation);
}
return {

View File

@ -52,7 +52,7 @@ function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNorm
],
// 登录状态进入需要登录权限的页面,直接通行
[
needLogin && isLogin,
isLogin && needLogin,
() => {
next();
}