Skip to content

Commit

Permalink
fix: 修复portal跳转兔小巢在某些情况下直接跳转的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Feb 2, 2021
1 parent 0e1d6e3 commit 718273b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
26 changes: 14 additions & 12 deletions src/portal/routes/help/txc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ import { useAsync } from 'react-use';

const TXCFeedback: React.FC = TMemo(() => {
const { loading } = useAsync(async () => {
await checkToken();
const isLogin = await checkToken();

// 跳转到兔小巢
const userInfo = await getJWTUserInfo();
openPostWindow({
url: config.url.txcUrl,
data: {
openid: userInfo.uuid,
nickname: userInfo.name,
avatar: userInfo.avatar,
},
target: '_self',
});
if (isLogin === true) {
// 跳转到兔小巢
const userInfo = await getJWTUserInfo();
openPostWindow({
url: config.url.txcUrl,
data: {
openid: userInfo.uuid,
nickname: userInfo.name,
avatar: userInfo.avatar,
},
target: '_self',
});
}
});

if (loading) {
Expand Down
5 changes: 3 additions & 2 deletions src/portal/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import { getJWTPayload, JWTUserInfoData } from '@shared/utils/jwt-helper';
* 该检查一般用于表单填写页面防止填了一堆数据后提交失败跳转到登录页的挫败感
* @param 是否自动跳转。如果为登录页则此值应该为false
*/
export const checkToken = async (autoNav = true): Promise<void> => {
export const checkToken = async (autoNav = true): Promise<boolean> => {
try {
await request.post('/player/sso/check');
return true;
} catch (err) {
if (autoNav) {
// 如果出错则跳转到登录页面
navToLoginPage();
return;
return false;
}
throw err;
}
Expand Down

0 comments on commit 718273b

Please sign in to comment.