feat: 支持 github 登录

This commit is contained in:
hzm
2026-03-22 22:28:45 +08:00
parent 7beac75160
commit d07146b819
4 changed files with 106 additions and 4 deletions

View File

@@ -1,7 +1,9 @@
'use client';
import Image from 'next/image';
import { InputOTP, InputOTPGroup, InputOTPSlot } from '@/components/ui/input-otp';
import { MailIcon } from './Icons';
import githubImg from "../assets/github.svg";
export default function LoginModal({
onClose,
@@ -13,7 +15,8 @@ export default function LoginModal({
loginError,
loginSuccess,
handleSendOtp,
handleVerifyEmailOtp
handleVerifyEmailOtp,
handleGithubLogin
}) {
return (
<div
@@ -84,7 +87,6 @@ export default function LoginModal({
type="button"
className="button secondary"
onClick={onClose}
disabled={loginLoading}
>
取消
</button>
@@ -98,6 +100,53 @@ export default function LoginModal({
</button>
</div>
</form>
{handleGithubLogin && (
<>
<div
className="login-divider"
style={{
display: 'flex',
alignItems: 'center',
margin: '20px 0',
gap: 12,
}}
>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
<span className="muted" style={{ fontSize: '12px', whiteSpace: 'nowrap' }}>或使用</span>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
</div>
<button
type="button"
className="github-login-btn"
onClick={handleGithubLogin}
disabled={loginLoading}
style={{
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 10,
padding: '12px 16px',
border: '1px solid var(--border)',
borderRadius: 8,
background: 'var(--bg)',
color: 'var(--text)',
cursor: loginLoading ? 'not-allowed' : 'pointer',
fontSize: '14px',
fontWeight: 500,
opacity: loginLoading ? 0.6 : 1,
transition: 'all 0.2s ease',
}}
>
<span className="github-icon-wrap">
<Image unoptimized alt="项目Github地址" src={githubImg} style={{ width: '24px', height: '24px', cursor: 'pointer' }} onClick={() => window.open("https://github.com/hzm0321/real-time-fund")} />
</span>
<span>使用 GitHub 登录</span>
</button>
</>
)}
</div>
</div>
);