|
@@ -26,13 +26,7 @@ export function useAutoLogin() {
|
|
|
|
|
|
|
|
/** 判断当前路由是否需要自动登录,本方法是同步方法,可以用于事先判断 */
|
|
/** 判断当前路由是否需要自动登录,本方法是同步方法,可以用于事先判断 */
|
|
|
function validateRoute(route: RouteLocationNormalized) {
|
|
function validateRoute(route: RouteLocationNormalized) {
|
|
|
- if (
|
|
|
|
|
- route.query &&
|
|
|
|
|
- route.query[AUTO_LOGIN_URL_QUERY.key] === AUTO_LOGIN_URL_QUERY.val &&
|
|
|
|
|
- route.query.deptId &&
|
|
|
|
|
- route.query.account &&
|
|
|
|
|
- route.query.username
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (route.query && route.query[AUTO_LOGIN_URL_QUERY.key]) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -47,23 +41,16 @@ export function useAutoLogin() {
|
|
|
async function doAutoLogin(route: RouteLocationNormalized): Promise<void> {
|
|
async function doAutoLogin(route: RouteLocationNormalized): Promise<void> {
|
|
|
if (!validateRoute(route)) return;
|
|
if (!validateRoute(route)) return;
|
|
|
|
|
|
|
|
- const { account, deptId, username } = route.query;
|
|
|
|
|
-
|
|
|
|
|
const params = {
|
|
const params = {
|
|
|
- account: account as string,
|
|
|
|
|
- deptId: deptId as string,
|
|
|
|
|
- username: username as string,
|
|
|
|
|
|
|
+ zbToken: route.query[AUTO_LOGIN_URL_QUERY.key] as string,
|
|
|
checkKey: new Date().getTime(),
|
|
checkKey: new Date().getTime(),
|
|
|
};
|
|
};
|
|
|
delete route.query[AUTO_LOGIN_URL_QUERY.key];
|
|
delete route.query[AUTO_LOGIN_URL_QUERY.key];
|
|
|
- delete route.query['account'];
|
|
|
|
|
- delete route.query['deptId'];
|
|
|
|
|
- delete route.query['username'];
|
|
|
|
|
const userStore = useUserStore();
|
|
const userStore = useUserStore();
|
|
|
try {
|
|
try {
|
|
|
await userStore.autoLogin({
|
|
await userStore.autoLogin({
|
|
|
...params,
|
|
...params,
|
|
|
- goHome: false,
|
|
|
|
|
|
|
+ goHome: true,
|
|
|
});
|
|
});
|
|
|
// delete route.query['username'];
|
|
// delete route.query['username'];
|
|
|
return;
|
|
return;
|