From e81e7ad64f76ac33584eeb5c7db96de1709a222c Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 29 Jun 2023 01:06:37 +0800 Subject: [PATCH] feat: github oauth login view --- client/web/src/plugin/common/reg.ts | 8 +++ client/web/src/routes/Entry/LoginView.tsx | 9 +++- .../routes/Entry/components/PrimaryBtn.tsx | 3 +- .../services/fim.service.dev.ts | 21 +++++--- .../com.msgbyte.fim/strategies/github.ts | 7 ++- .../com.msgbyte.fim/strategies/types.ts | 1 + .../plugins/com.msgbyte.fim/src/FimAction.tsx | 54 +++++++++++++++++++ .../web/plugins/com.msgbyte.fim/src/index.tsx | 8 +++ .../plugins/com.msgbyte.fim/src/request.ts | 3 ++ 9 files changed, 103 insertions(+), 11 deletions(-) create mode 100644 server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/FimAction.tsx create mode 100644 server/plugins/com.msgbyte.fim/web/plugins/com.msgbyte.fim/src/request.ts diff --git a/client/web/src/plugin/common/reg.ts b/client/web/src/plugin/common/reg.ts index 5c2cb0a0..55391271 100644 --- a/client/web/src/plugin/common/reg.ts +++ b/client/web/src/plugin/common/reg.ts @@ -314,3 +314,11 @@ export const [pluginGroupConfigItems, regPluginGroupConfigItem] = buildRegList<{ loading: boolean; }) => ReactElement; }>(); + +/** + * 注册登录操作 + */ +export const [pluginLoginAction, regLoginAction] = buildRegList<{ + name: string; + component: React.ComponentType; +}>(); diff --git a/client/web/src/routes/Entry/LoginView.tsx b/client/web/src/routes/Entry/LoginView.tsx index d4b7b1ed..c17d6631 100644 --- a/client/web/src/routes/Entry/LoginView.tsx +++ b/client/web/src/routes/Entry/LoginView.tsx @@ -4,12 +4,10 @@ import { isValidStr, loginWithEmail, t, - useAppSelector, useAsyncFn, useGlobalConfigStore, } from 'tailchat-shared'; import React, { useEffect, useState } from 'react'; -import { Spinner } from '../../components/Spinner'; import { string } from 'yup'; import { useLocation, useNavigate } from 'react-router'; import { setUserJWT } from '../../utils/jwt-helper'; @@ -23,6 +21,7 @@ import { LanguageSelect } from '@/components/LanguageSelect'; import { EntryInput } from './components/Input'; import { SecondaryBtn } from './components/SecondaryBtn'; import { PrimaryBtn } from './components/PrimaryBtn'; +import { pluginLoginAction } from '@/plugin/common'; /** * TODO: @@ -156,6 +155,12 @@ export const LoginView: React.FC = React.memo(() => { )} + + {pluginLoginAction.map((item) => { + const { name, component: Component } = item; + + return ; + })}
diff --git a/client/web/src/routes/Entry/components/PrimaryBtn.tsx b/client/web/src/routes/Entry/components/PrimaryBtn.tsx index 06c75971..3ac3a4fa 100644 --- a/client/web/src/routes/Entry/components/PrimaryBtn.tsx +++ b/client/web/src/routes/Entry/components/PrimaryBtn.tsx @@ -1,6 +1,7 @@ import { Spinner } from '@/components/Spinner'; import clsx from 'clsx'; import React, { ButtonHTMLAttributes } from 'react'; +import _omit from 'lodash/omit'; export const PrimaryBtn: React.FC< ButtonHTMLAttributes & { @@ -10,7 +11,7 @@ export const PrimaryBtn: React.FC< return (