2023-12-21 20:19:25 +08:00
|
|
|
import { createContext, useContext } from 'react';
|
|
|
|
|
|
|
|
export type Authenticator = {
|
|
|
|
name: string;
|
|
|
|
authType: string;
|
|
|
|
authTypeTitle: string;
|
|
|
|
title?: string;
|
|
|
|
options?: {
|
|
|
|
[key: string]: any;
|
|
|
|
};
|
|
|
|
sort?: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const AuthenticatorsContext = createContext<Authenticator[]>([]);
|
2024-03-10 03:06:57 +08:00
|
|
|
AuthenticatorsContext.displayName = 'AuthenticatorsContext';
|
2023-12-21 20:19:25 +08:00
|
|
|
|
|
|
|
export const useAuthenticator = (name: string) => {
|
|
|
|
const authenticators = useContext(AuthenticatorsContext);
|
|
|
|
return authenticators.find((a) => a.name === name);
|
|
|
|
};
|