From 52287357d528afd74f9bb307b636e523311c8fd9 Mon Sep 17 00:00:00 2001 From: an-lee Date: Sun, 7 Apr 2024 11:38:21 +0800 Subject: [PATCH] Feat: support email login (#490) * may login with email * update login layout * update login style --- enjoy/src/api/client.ts | 5 +- enjoy/src/i18n/en.json | 3 + enjoy/src/i18n/zh-CN.json | 3 + enjoy/src/renderer/components/login-form.tsx | 342 +++++++++++++------ 4 files changed, 238 insertions(+), 115 deletions(-) diff --git a/enjoy/src/api/client.ts b/enjoy/src/api/client.ts index 3184810b..ea2e3bee 100644 --- a/enjoy/src/api/client.ts +++ b/enjoy/src/api/client.ts @@ -70,9 +70,10 @@ export class Client { } auth(params: { - provider: "mixin" | "github" | "bandu"; + provider: "mixin" | "github" | "bandu" | "email"; code: string; phoneNumber?: string; + email?: string; }): Promise { return this.api.post("/api/sessions", decamelizeKeys(params)); } @@ -81,7 +82,7 @@ export class Client { return this.api.get("/api/me"); } - loginCode(params: { phoneNumber: string }): Promise { + loginCode(params: { phoneNumber?: string; email?: string }): Promise { return this.api.post("/api/sessions/login_code", decamelizeKeys(params)); } diff --git a/enjoy/src/i18n/en.json b/enjoy/src/i18n/en.json index f2010637..b46c7331 100644 --- a/enjoy/src/i18n/en.json +++ b/enjoy/src/i18n/en.json @@ -192,6 +192,9 @@ "sendCode": "Send code", "codeSent": "Code sent, please check your SMS", "verificationCode": "Verification code", + "email": "Email", + "phoneNumber": "Phone number", + "youCanAlsoLoginWith": "You can also login with", "transcribe": "Transcribe", "stillTranscribing": "AI is still working on the transcription. Please wait for a while.", "unableToSetLibraryPath": "Unable to set library path to {{path}}", diff --git a/enjoy/src/i18n/zh-CN.json b/enjoy/src/i18n/zh-CN.json index 598c0f9a..e6cf0699 100644 --- a/enjoy/src/i18n/zh-CN.json +++ b/enjoy/src/i18n/zh-CN.json @@ -191,6 +191,9 @@ "sendCode": "发送验证码", "codeSent": "验证码已发送", "verificationCode": "验证码", + "email": "邮箱", + "phoneNumber": "手机号", + "youCanAlsoLoginWith": "您也可以使用以下方式登录", "delete": "删除", "transcribe": "语音转文本", "stillTranscribing": "语音转文本仍在进行中,请耐心等候。", diff --git a/enjoy/src/renderer/components/login-form.tsx b/enjoy/src/renderer/components/login-form.tsx index ff360faa..395beb81 100644 --- a/enjoy/src/renderer/components/login-form.tsx +++ b/enjoy/src/renderer/components/login-form.tsx @@ -6,6 +6,11 @@ import { Sheet, SheetContent, SheetTrigger, + Label, + Card, + CardContent, + CardHeader, + CardTitle, } from "@renderer/components/ui"; import { useContext, useEffect, useRef, useState } from "react"; import { AppSettingsProviderContext } from "@renderer/context"; @@ -110,62 +115,82 @@ export const LoginForm = () => { return ( <> -
- - - - - - - -
-
- -
+ + + {t('login')} + + + + + +
+ +
+ {t('youCanAlsoLoginWith')}
- - -
+
+ + + + + + + + + +
+
+ +
+
+
+
+
+
+ +
+ + +
+
+ ); +} + const PandoLoginForm = () => { const ref = useRef(null); const [iti, setIti] = useState(null); @@ -234,45 +353,23 @@ const PandoLoginForm = () => { bandu
-
-
- -
- - {phoneNumber && ( -
- +
+
+
+ +
- )} - - {codeSent && ( -
+
+ { onChange={(e) => setCode(e.target.value)} />
- )} +
- {code && ( -
- -
- )} +
+ + +
);