feat: use staticBaseUrl for all static resources (#1015)

* feat: modify system image link

* Update App.less

Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
leoshine 2022-08-15 09:18:21 +08:00 committed by GitHub
parent ca13247572
commit ba732b3075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 12 deletions

View File

@ -15,4 +15,5 @@ socks5Proxy = "127.0.0.1:10808"
verificationCodeTimeout = 10
initScore = 2000
logPostOnly = true
origin =
origin =
staticBaseUrl = "https://cdn.casbin.org"

View File

@ -16,8 +16,10 @@ package object
import (
"encoding/gob"
"fmt"
"os"
"github.com/astaxie/beego"
"github.com/casdoor/casdoor/util"
"github.com/duo-labs/webauthn/webauthn"
)
@ -36,6 +38,8 @@ func InitDb() {
initWebAuthn()
}
var staticBaseUrl = beego.AppConfig.String("staticBaseUrl")
func initBuiltInOrganization() bool {
organization := getOrganization("admin", "built-in")
if organization != nil {
@ -48,10 +52,10 @@ func initBuiltInOrganization() bool {
CreatedTime: util.GetCurrentTime(),
DisplayName: "Built-in Organization",
WebsiteUrl: "https://example.com",
Favicon: "https://cdn.casbin.com/static/favicon.ico",
Favicon: fmt.Sprintf("%s/img/casbin/favicon.ico", staticBaseUrl),
PasswordType: "plain",
PhonePrefix: "86",
DefaultAvatar: "https://casbin.org/img/casbin.svg",
DefaultAvatar: fmt.Sprintf("%s/img/casbin.svg", staticBaseUrl),
Tags: []string{},
AccountItems: []*AccountItem{
{Name: "Organization", Visible: true, ViewRule: "Public", ModifyRule: "Admin"},
@ -100,7 +104,7 @@ func initBuiltInUser() {
Type: "normal-user",
Password: "123",
DisplayName: "Admin",
Avatar: "https://casbin.org/img/casbin.svg",
Avatar: fmt.Sprintf("%s/img/casbin.svg", staticBaseUrl),
Email: "admin@example.com",
Phone: "12345678910",
Address: []string{},
@ -130,7 +134,7 @@ func initBuiltInApplication() {
Name: "app-built-in",
CreatedTime: util.GetCurrentTime(),
DisplayName: "Casdoor",
Logo: "https://cdn.casbin.com/logo/logo_1024x256.png",
Logo: fmt.Sprintf("%s/img/casdoor-logo_1185x256.png", staticBaseUrl),
HomepageUrl: "https://casdoor.org",
Organization: "built-in",
Cert: "cert-built-in",

View File

@ -1,5 +1,7 @@
@import '~antd/dist/antd.less';
@StaticBaseUrl:"https://cdn.casbin.org";
.App {
text-align: center;
}
@ -46,7 +48,7 @@
}
.language_box {
background: url("https://cdn.casbin.org/img/muti_language.svg");
background: url("@{StaticBaseUrl}/img/muti_language.svg");
background-size: 25px, 25px;
background-position: center;
background-repeat: no-repeat;

View File

@ -30,7 +30,7 @@ class ApplicationListPage extends BaseListPage {
name: `application_${randomName}`,
createdTime: moment().format(),
displayName: `New Application - ${randomName}`,
logo: "https://cdn.casdoor.com/logo/casdoor-logo_1185x256.png",
logo: `${Setting.StaticBaseUrl}/img/casdoor-logo_1185x256.png`,
enablePassword: true,
enableSignUp: true,
enableSigninSession: false,

View File

@ -30,11 +30,11 @@ class OrganizationListPage extends BaseListPage {
createdTime: moment().format(),
displayName: `New Organization - ${randomName}`,
websiteUrl: "https://door.casdoor.com",
favicon: "https://cdn.casdoor.com/static/favicon.png",
favicon: `${Setting.StaticBaseUrl}/img/favicon.png`,
passwordType: "plain",
PasswordSalt: "",
phonePrefix: "86",
defaultAvatar: "https://casbin.org/img/casbin.svg",
defaultAvatar: `${Setting.StaticBaseUrl}/img/casbin.svg`,
tags: [],
masterPassword: "",
enableSoftDeletion: false,

View File

@ -30,7 +30,7 @@ class ProductListPage extends BaseListPage {
name: `product_${randomName}`,
createdTime: moment().format(),
displayName: `New Product - ${randomName}`,
image: "https://cdn.casdoor.com/logo/casdoor-logo_1185x256.png",
image: `${Setting.StaticBaseUrl}/img/casdoor-logo_1185x256.png`,
tag: "Casdoor Summit 2022",
currency: "USD",
price: 300,

View File

@ -49,7 +49,7 @@ class UserListPage extends BaseListPage {
password: "123",
passwordSalt: "",
displayName: `New User - ${randomName}`,
avatar: "https://casbin.org/img/casbin.svg",
avatar: `${Setting.StaticBaseUrl}/img/casbin.svg`,
email: `${randomName}@example.com`,
phone: Setting.getRandomNumber(),
address: [],

View File

@ -56,7 +56,7 @@ class HomePage extends React.Component {
if (filename === "/account") {
filename = "/users";
}
items[i].logo = `https://cdn.casbin.com/static/img${filename}.png`;
items[i].logo = `${Setting.StaticBaseUrl}/img${filename}.png`;
items[i].createdTime = "";
}
} else {