fix: show register entry in new login dialog
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-02-23 12:12:15 +08:00
parent 9ce3076438
commit 2c0a5379e7

View File

@ -129,6 +129,7 @@ type PublicAuthSettings = {
isDingTalkEnabled?: boolean;
isGoogleEnabled?: boolean;
isGoogleConfigured?: boolean;
isRegistrationEnabled?: boolean;
};
type ContactConfig = {
@ -643,6 +644,7 @@ export function LovartHome({
authSettingsData?.isGoogleEnabled && authSettingsData?.isGoogleConfigured
);
const canUseDingTalkLogin = Boolean(authSettingsData?.isDingTalkEnabled);
const canUseRegistration = authSettingsData?.isRegistrationEnabled !== false;
const hasThirdPartyLoginOptions = canUseGoogleLogin || canUseDingTalkLogin;
const handleLogout = async () => {
@ -892,6 +894,15 @@ export function LovartHome({
window.location.href = "/api/auth/dingtalk/login";
};
const handleRegister = () => {
if (!canUseRegistration) {
toast.error("当前未开放注册");
return;
}
setLoginDialogOpen(false);
router.push("/register");
};
const handleOpenImageEditor = () => {
if (!isAuthenticated) {
openLoginDialog();
@ -1959,7 +1970,9 @@ export function LovartHome({
<div className="mb-5 text-center">
<h3 className="text-[18px] font-semibold text-black">欢迎来到 {siteName}</h3>
<p className="mt-2 text-[13px] text-black/45">登录或注册以继续</p>
<p className="mt-2 text-[13px] text-black/45">
{canUseRegistration ? "登录或注册以继续" : "登录以继续"}
</p>
</div>
{hasThirdPartyLoginOptions ? (
@ -2029,6 +2042,19 @@ export function LovartHome({
</Button>
</form>
{canUseRegistration ? (
<div className="mt-3 text-center text-[13px] text-black/55">
还没有账号?
<button
type="button"
className="ml-1 font-medium text-black hover:underline"
onClick={handleRegister}
>
立即注册
</button>
</div>
) : null}
<p className="mt-4 text-center text-xs text-black/40">
继续即表示您同意使用条款和隐私政策
</p>