refactor: disable oauth login in mobile

pull/100/head
moonrailgun 2 years ago
parent a6eb722b4d
commit d2aa750152

@ -20,6 +20,7 @@ export {
openReconfirmModal,
} from '@/components/Modal';
export { Loadable } from '@/components/Loadable';
export { useIsMobile } from '@/hooks/useIsMobile';
export {
getGlobalState,
useGlobalSocketEvent,

@ -5,6 +5,7 @@ import {
useNavigate,
loginWithToken,
setUserJWT,
useIsMobile,
} from '@capital/common';
import { Divider, Image, Tooltip } from '@capital/component';
import { request } from './request';
@ -18,6 +19,7 @@ export const IAMAction: React.FC = React.memo(() => {
}, []);
const newWin = useRef<Window>();
const navigate = useNavigate();
const isMobile = useIsMobile();
useEffect(() => {
const fn = (event: MessageEvent<any>) => {
@ -59,31 +61,39 @@ export const IAMAction: React.FC = React.memo(() => {
return (
<div>
<Divider>{Translate.iamLogin}</Divider>
<div style={{ display: 'flex', justifyContent: 'center' }}>
{strategies.map((s) => (
<Tooltip key={s.name} title={s.name}>
<Image
style={{
width: 40,
height: 40,
cursor: 'pointer',
borderRadius: 20,
}}
src={s.icon}
onClick={async () => {
if (s.type === 'oauth') {
const { data: url } = await request.get(
`${s.name}.loginUrl`
);
{isMobile ? (
<div
style={{ textAlign: 'center', opacity: 0.8, fontSize: '0.75rem' }}
>
{Translate.notSupportMobile}
</div>
) : (
<div style={{ display: 'flex', justifyContent: 'center' }}>
{strategies.map((s) => (
<Tooltip key={s.name} title={s.name}>
<Image
style={{
width: 40,
height: 40,
cursor: 'pointer',
borderRadius: 20,
}}
src={s.icon}
onClick={async () => {
if (s.type === 'oauth') {
const { data: url } = await request.get(
`${s.name}.loginUrl`
);
const win = window.open(url, 'square', 'frame=true');
newWin.current = win;
}
}}
/>
</Tooltip>
))}
</div>
const win = window.open(url, 'square', 'frame=true');
newWin.current = win;
}
}}
/>
</Tooltip>
))}
</div>
)}
</div>
);
}

@ -15,4 +15,8 @@ export const Translate = {
'zh-CN': '账号已存在,请使用账号密码登录',
'en-US': 'Account Existed, please log in with account password',
}),
notSupportMobile: localTrans({
'zh-CN': '第三方登录功能暂不支持移动端使用',
'en-US': 'The third-party login function does not support mobile use',
}),
};

Loading…
Cancel
Save