Skip to content

Commit 4014b7a

Browse files
committed
feat: 添加社交登录和注册链接
核心改动: - 将社交登录/注册按钮改为实际可跳转的外部链接 - 新增 SOCIAL_LINKS 配置对象 * GitHub 链接指向项目仓库 * Google 链接指向文档站点 (https://halolight-docs.h7ml.cn) * WeChat 链接指向组织主页 (https://github.com/halolight) - 添加安全属性: target="_blank" + rel="noopener noreferrer" - 改进代码可维护性:移除占位函数,使用配置化管理 修改文件: - 登录页面: login.tsx/vue/astro 等 - 注册页面: register.tsx/vue/astro 等
1 parent 2d73e34 commit 4014b7a

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

src/pages/auth/login.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ export default function LoginPage() {
6262
}
6363
}
6464

65-
const handleSocialLogin = (provider: string) => {
66-
console.log(`使用 ${provider} 登录`)
65+
const SOCIAL_LINKS = {
66+
github: "https://github.com/halolight/halolight-react",
67+
google: "https://halolight-docs.h7ml.cn",
68+
wechat: "https://github.com/halolight",
6769
}
6870

6971
React.useEffect(() => {
@@ -182,11 +184,18 @@ export default function LoginPage() {
182184
transition={{ delay: 0.5 + index * 0.1 }}
183185
>
184186
<Button
187+
asChild
185188
variant="outline"
186189
className="w-full h-11 sm:h-12 border-border/50 hover:border-primary/50 hover:bg-primary/5 transition-all duration-300 group"
187-
onClick={() => handleSocialLogin(provider.name)}
188190
>
189-
<provider.icon className="h-5 w-5 group-hover:scale-110 transition-transform" />
191+
<a
192+
href={SOCIAL_LINKS[provider.name as keyof typeof SOCIAL_LINKS]}
193+
target="_blank"
194+
rel="noopener noreferrer"
195+
aria-label={`使用 ${provider.label} 登录`}
196+
>
197+
<provider.icon className="h-5 w-5 group-hover:scale-110 transition-transform" />
198+
</a>
190199
</Button>
191200
</motion.div>
192201
))}

src/pages/auth/register.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ const registerBackground = {
5555
],
5656
}
5757

58+
const SOCIAL_LINKS = {
59+
github: "https://github.com/halolight/halolight-react",
60+
google: "https://halolight-docs.h7ml.cn",
61+
wechat: "https://github.com/halolight",
62+
}
63+
5864
export default function RegisterPage() {
5965
const navigate = useNavigate()
6066
const { register, isLoading, error, clearError } = useAuthStore()
@@ -108,10 +114,6 @@ export default function RegisterPage() {
108114
}
109115
}
110116

111-
const handleSocialLogin = (provider: string) => {
112-
console.log(`使用 ${provider} 注册`)
113-
}
114-
115117
React.useEffect(() => {
116118
clearError()
117119
}, [clearError])
@@ -230,13 +232,14 @@ export default function RegisterPage() {
230232
animate={{ y: 0, opacity: 1 }}
231233
transition={{ delay: 0.5 + index * 0.1 }}
232234
>
233-
<Button
234-
variant="outline"
235-
className="w-full h-11 sm:h-12 border-border/50 hover:border-primary/50 hover:bg-primary/5 transition-all duration-300 group"
236-
onClick={() => handleSocialLogin(provider.name)}
235+
<a
236+
href={SOCIAL_LINKS[provider.name as keyof typeof SOCIAL_LINKS]}
237+
target="_blank"
238+
rel="noopener noreferrer"
239+
className="inline-flex items-center justify-center w-full h-11 sm:h-12 border border-border/50 hover:border-primary/50 hover:bg-primary/5 transition-all duration-300 group rounded-md"
237240
>
238241
<provider.icon className="h-5 w-5 group-hover:scale-110 transition-transform" />
239-
</Button>
242+
</a>
240243
</motion.div>
241244
))}
242245
</div>

0 commit comments

Comments
 (0)