自动识别更多oidc图标
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 591 B |
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
+27
-7
@@ -67,6 +67,32 @@ function VersionDisplay() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据按钮文本识别OIDC提供商并返回对应的图标
|
||||||
|
function getOIDCProviderIcon(buttonText: string) {
|
||||||
|
const text = buttonText.toLowerCase();
|
||||||
|
|
||||||
|
const providers = [
|
||||||
|
{ keywords: ['linuxdo'], icon: '/icons/linuxdo.png', alt: 'LinuxDo' },
|
||||||
|
{ keywords: ['github'], icon: '/icons/github.png', alt: 'GitHub' },
|
||||||
|
{ keywords: ['google'], icon: '/icons/google.png', alt: 'Google' },
|
||||||
|
{ keywords: ['microsoft', 'azure', 'entra'], icon: '/icons/microsoft.png', alt: 'Microsoft' },
|
||||||
|
{ keywords: ['gitlab'], icon: '/icons/gitlab.png', alt: 'GitLab' },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const provider of providers) {
|
||||||
|
if (provider.keywords.some(keyword => text.includes(keyword))) {
|
||||||
|
return <img src={provider.icon} alt={provider.alt} className='w-5 h-5 mr-2' />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认图标
|
||||||
|
return (
|
||||||
|
<svg className='w-5 h-5 mr-2' fill='currentColor' viewBox='0 0 20 20'>
|
||||||
|
<path fillRule='evenodd' d='M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z' clipRule='evenodd' />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function LoginPageClient() {
|
function LoginPageClient() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
@@ -392,13 +418,7 @@ function LoginPageClient() {
|
|||||||
onClick={() => window.location.href = '/api/auth/oidc/login'}
|
onClick={() => window.location.href = '/api/auth/oidc/login'}
|
||||||
className='mt-4 w-full inline-flex justify-center items-center rounded-lg border-2 border-gray-300 dark:border-gray-600 bg-white/60 dark:bg-zinc-800/60 py-3 text-base font-semibold text-gray-700 dark:text-gray-200 shadow-sm transition-all duration-200 hover:bg-gray-50 dark:hover:bg-zinc-700/60'
|
className='mt-4 w-full inline-flex justify-center items-center rounded-lg border-2 border-gray-300 dark:border-gray-600 bg-white/60 dark:bg-zinc-800/60 py-3 text-base font-semibold text-gray-700 dark:text-gray-200 shadow-sm transition-all duration-200 hover:bg-gray-50 dark:hover:bg-zinc-700/60'
|
||||||
>
|
>
|
||||||
{(siteConfig?.OIDCButtonText || '').toLowerCase().includes('linuxdo') ? (
|
{getOIDCProviderIcon(siteConfig?.OIDCButtonText || '')}
|
||||||
<img src='/icons/linuxdo.png' alt='LinuxDo' className='w-5 h-5 mr-2' />
|
|
||||||
) : (
|
|
||||||
<svg className='w-5 h-5 mr-2' fill='currentColor' viewBox='0 0 20 20'>
|
|
||||||
<path fillRule='evenodd' d='M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z' clipRule='evenodd' />
|
|
||||||
</svg>
|
|
||||||
)}
|
|
||||||
{siteConfig?.OIDCButtonText || '使用OIDC登录'}
|
{siteConfig?.OIDCButtonText || '使用OIDC登录'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user