refactor: invite link for app
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
const StyledSignInLink = styled.ul`
|
const StyledSignInLink = styled.ul`
|
||||||
@@ -26,21 +27,23 @@ const StyledSignInLink = styled.ul`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export default function SignInLink({ token }: { token?: string }) {
|
export default function SignInLink({ token }: { token?: string }) {
|
||||||
const isMobile = "ontouchstart" in document.documentElement;
|
|
||||||
const handleSignIn = () => {
|
const handleSignIn = () => {
|
||||||
location.href = "/#/login";
|
location.href = "/#/login";
|
||||||
};
|
};
|
||||||
const showAppEntry = isMobile && !!token;
|
useEffect(() => {
|
||||||
|
const isMobile = "ontouchstart" in document.documentElement;
|
||||||
|
// 直接跳转
|
||||||
|
if (isMobile && !!token) {
|
||||||
|
location.href = `https://voce.chat/download?link=${encodeURIComponent(`${location.origin}?magic_token=${token}`)}`;
|
||||||
|
}
|
||||||
|
}, [token]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledSignInLink>
|
<StyledSignInLink>
|
||||||
<li className="item">
|
<li className="item">
|
||||||
<span>Have an account?</span>
|
<span>Have an account?</span>
|
||||||
<a onClick={handleSignIn}>Sign In</a>
|
<a onClick={handleSignIn}>Sign In</a>
|
||||||
</li>
|
</li>
|
||||||
{showAppEntry && <li className="item">
|
|
||||||
<span>Using a mobile device? Open in</span>
|
|
||||||
<a href={`https://voce.chat?magic_link=${encodeURIComponent(`${location.origin}?magic_token=${token}`)}`} target={"_blank"} rel="noreferrer">VoceChat App</a>
|
|
||||||
</li>}
|
|
||||||
</StyledSignInLink>
|
</StyledSignInLink>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user