优化新首页回顶按钮并修复退出登录流程
This commit is contained in:
parent
a0ac8e6210
commit
fed71220cc
@ -23,7 +23,6 @@ import {
|
|||||||
Monitor,
|
Monitor,
|
||||||
Palette,
|
Palette,
|
||||||
Plus,
|
Plus,
|
||||||
Send,
|
|
||||||
Settings,
|
Settings,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
Star,
|
Star,
|
||||||
@ -562,6 +561,21 @@ export function LovartHome({
|
|||||||
const canUseDingTalkLogin = Boolean(authSettingsData?.isDingTalkEnabled);
|
const canUseDingTalkLogin = Boolean(authSettingsData?.isDingTalkEnabled);
|
||||||
const hasThirdPartyLoginOptions = canUseGoogleLogin || canUseDingTalkLogin;
|
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(() => {
|
useEffect(() => {
|
||||||
if (selectedModelId) return;
|
if (selectedModelId) return;
|
||||||
const defaultModelId = siteSettingsData?.canvasDefaultModelId || "auto";
|
const defaultModelId = siteSettingsData?.canvasDefaultModelId || "auto";
|
||||||
@ -1134,7 +1148,7 @@ export function LovartHome({
|
|||||||
icon={LogOut}
|
icon={LogOut}
|
||||||
label="退出登录"
|
label="退出登录"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
void signOut({ redirect: true, callbackUrl: "/" });
|
void handleLogout();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -1576,10 +1590,11 @@ export function LovartHome({
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
type="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"
|
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" })}
|
onClick={() => window.scrollTo({ top: 0, behavior: "smooth" })}
|
||||||
>
|
>
|
||||||
<Send className="h-4 w-4 -rotate-90" />
|
<ArrowUp className="h-4 w-4" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{loginDialogOpen ? (
|
{loginDialogOpen ? (
|
||||||
@ -1754,7 +1769,7 @@ export function LovartHome({
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="h-8 rounded-xl border border-black/10 bg-white px-3 text-[12px] text-black/75 hover:bg-black/5"
|
className="h-8 rounded-xl border border-black/10 bg-white px-3 text-[12px] text-black/75 hover:bg-black/5"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
void signOut({ redirect: true, callbackUrl: "/" });
|
void handleLogout();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
退出登录
|
退出登录
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user