-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { createClient } from "@/utils/supabase/server"; | ||
import Link from "next/link"; | ||
import { cookies } from "next/headers"; | ||
import { redirect } from "next/navigation"; | ||
import LoadingIndicator from "@/components/LoadingIndicator"; // 确保路径正确 | ||
import { insertUserProfile } from "@/utils/supabase/supabaseutils"; | ||
import React from "react"; | ||
export default async function WelcomeScreen() { | ||
const [isLoading, setIsLoading] = React.useState(true); | ||
const cookieStore = cookies(); | ||
const supabase = createClient(cookieStore); | ||
|
||
const { | ||
data, | ||
data: { user }, | ||
} = await supabase.auth.getUser(); | ||
//profiles表 插入用户信息 | ||
await insertUserProfile(data, supabase); | ||
setIsLoading(false); | ||
//2秒后跳转到首页 | ||
setTimeout(() => { | ||
redirect("/"); | ||
}, 1000); | ||
|
||
return user ? ( | ||
<div className="flex items-center gap-4"> | ||
Hey, {user.email}! | ||
<div style={{ margin: "20px", textAlign: "center" }}> | ||
<h1>welcome, {user.email}!</h1> | ||
</div> | ||
</div> | ||
) : ( | ||
<Link | ||
href="/login" | ||
className="py-2 px-3 flex rounded-md no-underline bg-btn-background hover:bg-btn-background-hover" | ||
> | ||
Login | ||
</Link> | ||
); | ||
{ | ||
isLoading ? <LoadingIndicator /> : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters