优化新首页回顶按钮并修复退出登录流程
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-15 01:03:38 +08:00
parent a0ac8e6210
commit fed71220cc

View File

@ -23,7 +23,6 @@ import {
Monitor,
Palette,
Plus,
Send,
Settings,
Sparkles,
Star,
@ -562,6 +561,21 @@ export function LovartHome({
const canUseDingTalkLogin = Boolean(authSettingsData?.isDingTalkEnabled);
const hasThirdPartyLoginOptions = canUseGoogleLogin || canUseDingTalkLogin;
const handleLogout = async () => {
try {
await fetch("/api/auth/logout", { method: "POST" });
} catch (_error) {}
try {
await signOut({
callbackUrl: "/",
redirect: false,
});
} catch (_error) {}
window.location.replace("/");
};
useEffect(() => {
if (selectedModelId) return;
const defaultModelId = siteSettingsData?.canvasDefaultModelId || "auto";
@ -1134,7 +1148,7 @@ export function LovartHome({
icon={LogOut}
label="退出登录"
onClick={() => {
void signOut({ redirect: true, callbackUrl: "/" });
void handleLogout();
}}
/>
</div>
@ -1576,10 +1590,11 @@ export function LovartHome({
<button
type="button"
title="回到顶部"
className="fixed bottom-8 right-8 z-20 flex h-11 w-11 items-center justify-center rounded-full border border-black/10 bg-white text-black/50 shadow hover:text-black"
onClick={() => window.scrollTo({ top: 0, behavior: "smooth" })}
>
<Send className="h-4 w-4 -rotate-90" />
<ArrowUp className="h-4 w-4" />
</button>
{loginDialogOpen ? (
@ -1754,7 +1769,7 @@ export function LovartHome({
variant="ghost"
className="h-8 rounded-xl border border-black/10 bg-white px-3 text-[12px] text-black/75 hover:bg-black/5"
onClick={() => {
void signOut({ redirect: true, callbackUrl: "/" });
void handleLogout();
}}
>
退出登录