Add StaticBaseUrl.

This commit is contained in:
Yang Luo 2021-06-12 11:52:59 +08:00
parent c4de5449af
commit e1673c1541
2 changed files with 17 additions and 14 deletions

View File

@ -23,6 +23,8 @@ import {Helmet} from "react-helmet";
export let ServerUrl = ""; export let ServerUrl = "";
export const StaticBaseUrl = "https://cdn.jsdelivr.net/gh/casbin/static";
export function initServerUrl() { export function initServerUrl() {
const hostname = window.location.hostname; const hostname = window.location.hostname;
if (hostname === "localhost") { if (hostname === "localhost") {
@ -218,7 +220,7 @@ export function getClickable(text) {
export function getProviderLogo(provider) { export function getProviderLogo(provider) {
const idp = provider.type.toLowerCase(); const idp = provider.type.toLowerCase();
const url = `https://cdn.jsdelivr.net/gh/casbin/static/img/social_${idp}.png`; const url = `${StaticBaseUrl}/img/social_${idp}.png`;
return ( return (
<img width={30} height={30} src={url} alt={idp} /> <img width={30} height={30} src={url} alt={idp} />
) )

View File

@ -13,34 +13,35 @@
// limitations under the License. // limitations under the License.
import * as Util from "./Util"; import * as Util from "./Util";
import {StaticBaseUrl} from "../Setting";
const GoogleAuthScope = "profile+email" const GoogleAuthScope = "profile+email"
const GoogleAuthUri = "https://accounts.google.com/signin/oauth"; const GoogleAuthUri = "https://accounts.google.com/signin/oauth";
const GoogleAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_google.png"; const GoogleAuthLogo = `${StaticBaseUrl}/img/social_google.png`;
const GithubAuthScope = "user:email+read:user" const GithubAuthScope = "user:email+read:user"
const GithubAuthUri = "https://github.com/login/oauth/authorize"; const GithubAuthUri = "https://github.com/login/oauth/authorize";
const GithubAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_github.png"; const GithubAuthLogo = `${StaticBaseUrl}/img/social_github.png`;
const QqAuthScope = "get_user_info" const QqAuthScope = "get_user_info"
const QqAuthUri = "https://graph.qq.com/oauth2.0/authorize"; const QqAuthUri = "https://graph.qq.com/oauth2.0/authorize";
const QqAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_qq.png"; const QqAuthLogo = `${StaticBaseUrl}/img/social_qq.png`;
const WeChatAuthScope = "snsapi_login" const WeChatAuthScope = "snsapi_login"
const WeChatAuthUri = "https://open.weixin.qq.com/connect/qrconnect"; const WeChatAuthUri = "https://open.weixin.qq.com/connect/qrconnect";
const WeChatAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_wechat.png"; const WeChatAuthLogo = `${StaticBaseUrl}/img/social_wechat.png`;
const FacebookAuthScope = "email,public_profile" const FacebookAuthScope = "email,public_profile";
const FacebookAuthUri = "https://www.facebook.com/dialog/oauth" const FacebookAuthUri = "https://www.facebook.com/dialog/oauth";
const FacebookAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_facebook.png" const FacebookAuthLogo = `${StaticBaseUrl}/img/social_facebook.png`;
// const DingTalkAuthScope = "email,public_profile" // const DingTalkAuthScope = "email,public_profile";
const DingTalkAuthUri = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize" const DingTalkAuthUri = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize";
const DingTalkAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_dingtalk.png" const DingTalkAuthLogo = `${StaticBaseUrl}/img/social_dingtalk.png`;
const WeiboAuthScope = "email" const WeiboAuthScope = "email";
const WeiboAuthUri = "https://api.weibo.com/oauth2/authorize" const WeiboAuthUri = "https://api.weibo.com/oauth2/authorize";
const WeiboAuthLogo = "https://cdn.jsdelivr.net/gh/casbin/static/img/social_weibo.png" const WeiboAuthLogo = `${StaticBaseUrl}/img/social_weibo.png`;
export function getAuthLogo(provider) { export function getAuthLogo(provider) {
if (provider.type === "Google") { if (provider.type === "Google") {