mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
Improve non-oauth logos.
This commit is contained in:
@ -111,7 +111,7 @@ class ProviderListPage extends React.Component {
|
||||
title: i18next.t("general:Created time"),
|
||||
dataIndex: 'createdTime',
|
||||
key: 'createdTime',
|
||||
width: '160px',
|
||||
width: '180px',
|
||||
sorter: (a, b) => a.createdTime.localeCompare(b.createdTime),
|
||||
render: (text, record, index) => {
|
||||
return Setting.getFormattedDate(text);
|
||||
@ -136,16 +136,22 @@ class ProviderListPage extends React.Component {
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
width: '80px',
|
||||
align: 'center',
|
||||
sorter: (a, b) => a.type.localeCompare(b.type),
|
||||
render: (text, record, index) => {
|
||||
if (record.category !== "OAuth") {
|
||||
return text;
|
||||
const url = Provider.getProviderUrl(record);
|
||||
if (url !== "") {
|
||||
return (
|
||||
<Tooltip title={record.type}>
|
||||
<a target="_blank" rel="noreferrer" href={Provider.getProviderUrl(record)}>
|
||||
<img width={36} height={36} src={Provider.getProviderLogo(record)} alt={record.displayName} />
|
||||
</a>
|
||||
</Tooltip>
|
||||
)
|
||||
} else {
|
||||
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} />
|
||||
</a>
|
||||
<img width={36} height={36} src={Provider.getProviderLogo(record)} alt={record.displayName} />
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class LoginPage extends React.Component {
|
||||
if (size === "small") {
|
||||
return (
|
||||
<a key={provider.displayName} href={Provider.getAuthUrl(application, provider, "signup")}>
|
||||
<img width={width} height={width} src={Provider.getAuthLogo(provider)} alt={provider.displayName} style={{margin: margin}} />
|
||||
<img width={width} height={width} src={Provider.getProviderLogo(provider)} alt={provider.displayName} style={{margin: margin}} />
|
||||
</a>
|
||||
)
|
||||
} else {
|
||||
|
@ -65,24 +65,69 @@ const authInfo = {
|
||||
scope: "read_user+profile",
|
||||
endpoint: "https://gitlab.com/oauth/authorize",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export function getAuthLogo(provider) {
|
||||
return `${StaticBaseUrl}/img/social_${provider.type.toLowerCase()}.png`;
|
||||
}
|
||||
const otherProviderInfo = {
|
||||
SMS: {
|
||||
"Aliyun SMS": {
|
||||
logo: `${StaticBaseUrl}/img/social_aliyun.png`,
|
||||
url: "https://aliyun.com/product/sms",
|
||||
},
|
||||
"Tencent Cloud SMS": {
|
||||
logo: `${StaticBaseUrl}/img/social_tencent_cloud.jpg`,
|
||||
url: "https://cloud.tencent.com/product/sms",
|
||||
},
|
||||
"Volc Engine SMS": {
|
||||
logo: `${StaticBaseUrl}/img/social_volc_engine.jpg`,
|
||||
url: "https://www.volcengine.com/products/cloud-sms",
|
||||
},
|
||||
},
|
||||
Email: {
|
||||
"Default": {
|
||||
logo: `${StaticBaseUrl}/img/social_default.png`,
|
||||
url: "",
|
||||
},
|
||||
},
|
||||
Storage: {
|
||||
"Local File System": {
|
||||
logo: `${StaticBaseUrl}/img/social_file.png`,
|
||||
url: "",
|
||||
},
|
||||
"AWS S3": {
|
||||
logo: `${StaticBaseUrl}/img/social_aws.png`,
|
||||
url: "https://aws.amazon.com/s3",
|
||||
},
|
||||
"Aliyun OSS": {
|
||||
logo: `${StaticBaseUrl}/img/social_aliyun.png`,
|
||||
url: "https://aliyun.com/product/oss",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
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);
|
||||
export function getProviderLogo(provider) {
|
||||
if (provider.category === "OAuth") {
|
||||
return `${StaticBaseUrl}/img/social_${provider.type.toLowerCase()}.png`;
|
||||
} else {
|
||||
return otherProviderInfo[provider.category][provider.type].logo;
|
||||
}
|
||||
host = tokens.join(".");
|
||||
}
|
||||
|
||||
return `${urlObj.protocol}//${host}`;
|
||||
export function getProviderUrl(provider) {
|
||||
if (provider.category === "OAuth") {
|
||||
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}`;
|
||||
} else {
|
||||
return otherProviderInfo[provider.category][provider.type].url;
|
||||
}
|
||||
}
|
||||
|
||||
export function getAuthUrl(application, provider, method) {
|
||||
|
Reference in New Issue
Block a user