Improve provider logos.

This commit is contained in:
Yang Luo
2021-10-09 22:33:39 +08:00
parent fa3681ed75
commit 122970bb54
2 changed files with 20 additions and 2 deletions

View File

@ -14,7 +14,7 @@
import React from "react"; import React from "react";
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {Button, Popconfirm, Table} from 'antd'; import {Button, Popconfirm, Table, Tooltip} from 'antd';
import moment from "moment"; import moment from "moment";
import * as Setting from "./Setting"; import * as Setting from "./Setting";
import * as ProviderBackend from "./backend/ProviderBackend"; import * as ProviderBackend from "./backend/ProviderBackend";
@ -142,7 +142,11 @@ class ProviderListPage extends React.Component {
return text; return text;
} else { } else {
return ( return (
<Tooltip title={record.type}>
<a target="_blank" rel="noreferrer" href={Provider.getAuthHomepage(record)}>
<img width={30} height={30} src={Provider.getAuthLogo(record)} alt={record.displayName} /> <img width={30} height={30} src={Provider.getAuthLogo(record)} alt={record.displayName} />
</a>
</Tooltip>
) )
} }
} }

View File

@ -71,6 +71,20 @@ export function getAuthLogo(provider) {
return `${StaticBaseUrl}/img/social_${provider.type.toLowerCase()}.png`; return `${StaticBaseUrl}/img/social_${provider.type.toLowerCase()}.png`;
} }
export function getAuthHomepage(provider) {
const endpoint = authInfo[provider.type].endpoint;
const urlObj = new URL(endpoint);
let host = urlObj.host;
let tokens = host.split(".");
if (tokens.length > 2) {
tokens = tokens.slice(1);
}
host = tokens.join(".");
return `${urlObj.protocol}//${host}`;
}
export function getAuthUrl(application, provider, method) { export function getAuthUrl(application, provider, method) {
if (application === null || provider === null) { if (application === null || provider === null) {
return ""; return "";