From aaa8baff8f7b4393487c5fe4fbc1f0cf4ecc17cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=93=E9=BC=A0?= <71394853+hamster1963@users.noreply.github.com> Date: Mon, 30 Dec 2024 20:45:11 +0800 Subject: [PATCH] style: login button (#83) * style: login button * chore: auto-fix linting and formatting issues --------- Co-authored-by: hamster1963 --- src/api/oauth2.ts | 3 +-- src/components/ui/icon.tsx | 7 +++++++ src/routes/login.tsx | 26 +++++++++++++++++++++++--- src/routes/profile.tsx | 17 ++++++++++++++--- 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/components/ui/icon.tsx diff --git a/src/api/oauth2.ts b/src/api/oauth2.ts index 89dedc8..7ca7973 100644 --- a/src/api/oauth2.ts +++ b/src/api/oauth2.ts @@ -11,9 +11,8 @@ export const getOauth2RedirectURL = async ( provider: string, rType: Oauth2RequestType, ): Promise => { - const sType = "type" return fetcher(FetcherMethod.GET, `/api/v1/oauth2/${provider}`, { - sType: rType, + type: rType, }) } diff --git a/src/components/ui/icon.tsx b/src/components/ui/icon.tsx new file mode 100644 index 0000000..12445aa --- /dev/null +++ b/src/components/ui/icon.tsx @@ -0,0 +1,7 @@ +export function GitHubIcon(props: React.ComponentPropsWithoutRef<"svg">) { + return ( + + + + ) +} diff --git a/src/routes/login.tsx b/src/routes/login.tsx index 5e97578..8666531 100644 --- a/src/routes/login.tsx +++ b/src/routes/login.tsx @@ -8,7 +8,9 @@ import { FormLabel, FormMessage, } from "@/components/ui/form" +import { GitHubIcon } from "@/components/ui/icon" import { Input } from "@/components/ui/input" +import { Separator } from "@/components/ui/separator" import { useAuth } from "@/hooks/useAuth" import useSetting from "@/hooks/useSetting" import { zodResolver } from "@hookform/resolvers/zod" @@ -99,12 +101,30 @@ function Login() { )} /> - + +
+ +
+ OAuth2 +
+ +
-
+
{settingData?.config?.oauth2_providers?.map((p: string) => ( - + ))}
diff --git a/src/routes/profile.tsx b/src/routes/profile.tsx index 6d62616..819213c 100644 --- a/src/routes/profile.tsx +++ b/src/routes/profile.tsx @@ -118,10 +118,21 @@ export default function ProfilePage() { {settingData?.config?.oauth2_providers?.map((provider) => ( -
- {provider}: {profile.oauth2_bind?.[provider.toLowerCase()]}{" "} +
+
+

{provider}:

+ {profile.oauth2_bind?.[provider.toLowerCase()] && ( +

+ {profile.oauth2_bind?.[provider.toLowerCase()]} +

+ )} +
{profile.oauth2_bind?.[provider.toLowerCase()] ? ( - ) : (