增加注册强制邀请码开关、微信内登录自动获取openid开关

This commit is contained in:
孟帅
2023-05-15 10:17:04 +08:00
parent a1ca9bfafc
commit 6187fedd4e
26 changed files with 157 additions and 96 deletions

View File

@@ -1,13 +1,13 @@
import type { RouteRecordRaw } from 'vue-router';
import { isNavigationFailure, Router } from 'vue-router';
import { UserInfoState, useUserStoreWidthOut } from '@/store/modules/user';
import { useUserStoreWidthOut } from '@/store/modules/user';
import { useAsyncRouteStoreWidthOut } from '@/store/modules/asyncRoute';
import { ACCESS_TOKEN } from '@/store/mutation-types';
import { storage } from '@/utils/Storage';
import { PageEnum } from '@/enums/pageEnum';
import { ErrorPageRoute } from '@/router/base';
import { isWechatBrowser } from '@/utils/is';
import { jump } from '@/utils/http/axios';
import { getNowUrl } from '@/utils/urlUtils';
const LOGIN_PATH = PageEnum.BASE_LOGIN;
const whitePathList = [LOGIN_PATH]; // no redirect whitelist
@@ -64,21 +64,20 @@ export function createRouterGuards(router: Router) {
const redirect = decodeURIComponent(redirectPath);
const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect };
const userInfo = await userStore.GetInfo();
await userStore.LoadLoginConfig();
// 如果是微信访问,则记录本次登录的openid
if (isWechatBrowser() && (userInfo as UserInfoState).openId === '') {
// 是否允许获取微信openid
if (userStore.allowWxOpenId()) {
let path = nextData.path;
if (path === LOGIN_PATH) {
path = PageEnum.BASE_HOME_REDIRECT;
}
const w = window.location;
const URI = w.protocol + '//' + w.host + w.pathname + '#' + path;
const URI = getNowUrl() + '#' + path;
jump('/wechat/authorize', { type: 'openId', syncRedirect: URI });
return;
}
await userStore.LoadLoginConfig();
await userStore.GetConfig();
const routes = await asyncRouteStore.generateRoutes(userInfo);