mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Set org's document title and favicon.
This commit is contained in:
parent
cfe1eb9d50
commit
5779d57960
@ -53,6 +53,7 @@ type Response struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
|
Data2 interface{} `json:"data2"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title Signup
|
// @Title Signup
|
||||||
@ -145,7 +146,8 @@ func (c *ApiController) GetAccount() {
|
|||||||
|
|
||||||
username := c.GetSessionUser()
|
username := c.GetSessionUser()
|
||||||
user := object.GetUser(username)
|
user := object.GetUser(username)
|
||||||
resp = Response{Status: "ok", Msg: "", Data: user}
|
organization := object.GetOrganization(util.GetId(user.Owner))
|
||||||
|
resp = Response{Status: "ok", Msg: "", Data: user, Data2: organization}
|
||||||
|
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
|
@ -16,6 +16,7 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@ -33,3 +34,7 @@ func GetOwnerAndNameFromId(id string) (string, string) {
|
|||||||
func GenerateId() string {
|
func GenerateId() string {
|
||||||
return uuid.NewString()
|
return uuid.NewString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetId(name string) string {
|
||||||
|
return fmt.Sprintf("admin/%s", name)
|
||||||
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"react-device-detect": "^1.14.0",
|
"react-device-detect": "^1.14.0",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-github-corner": "^2.5.0",
|
"react-github-corner": "^2.5.0",
|
||||||
|
"react-helmet": "^6.1.0",
|
||||||
"react-i18next": "^11.8.7",
|
"react-i18next": "^11.8.7",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-scripts": "4.0.3",
|
"react-scripts": "4.0.3",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
|
<!-- <link rel="icon" href="%PUBLIC_URL%/favicon.png" />-->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta
|
<meta
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import './App.less';
|
import './App.less';
|
||||||
|
import {Helmet} from "react-helmet";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
import {DownOutlined, LogoutOutlined, SettingOutlined} from '@ant-design/icons';
|
import {DownOutlined, LogoutOutlined, SettingOutlined} from '@ant-design/icons';
|
||||||
import {Avatar, BackTop, Dropdown, Layout, Menu} from 'antd';
|
import {Avatar, BackTop, Dropdown, Layout, Menu} from 'antd';
|
||||||
@ -123,8 +124,14 @@ class App extends Component {
|
|||||||
}
|
}
|
||||||
AuthBackend.getAccount(accessToken)
|
AuthBackend.getAccount(accessToken)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
let account = null;
|
||||||
|
if (res.status === "ok") {
|
||||||
|
account = res.data;
|
||||||
|
account.organization = res.data2;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
account: res.status === "ok" ? res.data : null,
|
account: account,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -389,7 +396,7 @@ class App extends Component {
|
|||||||
return window.location.pathname.startsWith("/login/oauth/authorize");
|
return window.location.pathname.startsWith("/login/oauth/authorize");
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
renderPage() {
|
||||||
if (this.isDoorPages()) {
|
if (this.isDoorPages()) {
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
@ -413,6 +420,34 @@ class App extends Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.account === undefined || this.state.account === null) {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Helmet>
|
||||||
|
<link rel="icon" href={"https://cdn.casbin.com/static/favicon.ico"} />
|
||||||
|
</Helmet>
|
||||||
|
{
|
||||||
|
this.renderPage()
|
||||||
|
}
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const organization = this.state.account.organization;
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Helmet>
|
||||||
|
<title>{organization.displayName}</title>
|
||||||
|
<link rel="icon" href={organization.websiteUrl} />
|
||||||
|
</Helmet>
|
||||||
|
{
|
||||||
|
this.renderPage()
|
||||||
|
}
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(App);
|
export default withRouter(App);
|
||||||
|
@ -48,7 +48,7 @@ class OrganizationListPage extends React.Component {
|
|||||||
name: `organization_${this.state.organizations.length}`,
|
name: `organization_${this.state.organizations.length}`,
|
||||||
createdTime: moment().format(),
|
createdTime: moment().format(),
|
||||||
displayName: `New Organization - ${this.state.organizations.length}`,
|
displayName: `New Organization - ${this.state.organizations.length}`,
|
||||||
websiteUrl: "https://example.com",
|
websiteUrl: "https://cdn.casbin.com/static/favicon.ico",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9790,11 +9790,26 @@ react-error-overlay@^6.0.9:
|
|||||||
resolved "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
|
resolved "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
|
||||||
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
|
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
|
||||||
|
|
||||||
|
react-fast-compare@^3.1.1:
|
||||||
|
version "3.2.0"
|
||||||
|
resolved "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
|
||||||
|
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==
|
||||||
|
|
||||||
react-github-corner@^2.5.0:
|
react-github-corner@^2.5.0:
|
||||||
version "2.5.0"
|
version "2.5.0"
|
||||||
resolved "https://registry.npmjs.org/react-github-corner/-/react-github-corner-2.5.0.tgz#e350d0c69f69c075bc0f1d2a6f1df6ee91da31f2"
|
resolved "https://registry.npmjs.org/react-github-corner/-/react-github-corner-2.5.0.tgz#e350d0c69f69c075bc0f1d2a6f1df6ee91da31f2"
|
||||||
integrity sha512-ofds9l6n61LJc6ML+jSE6W9ZSQvATcMR9evnHPXua1oDYj289HKODnVqFUB/g2a4ieBjDHw416iHP3MjqnU76Q==
|
integrity sha512-ofds9l6n61LJc6ML+jSE6W9ZSQvATcMR9evnHPXua1oDYj289HKODnVqFUB/g2a4ieBjDHw416iHP3MjqnU76Q==
|
||||||
|
|
||||||
|
react-helmet@^6.1.0:
|
||||||
|
version "6.1.0"
|
||||||
|
resolved "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726"
|
||||||
|
integrity sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==
|
||||||
|
dependencies:
|
||||||
|
object-assign "^4.1.1"
|
||||||
|
prop-types "^15.7.2"
|
||||||
|
react-fast-compare "^3.1.1"
|
||||||
|
react-side-effect "^2.1.0"
|
||||||
|
|
||||||
react-i18next@^11.8.7:
|
react-i18next@^11.8.7:
|
||||||
version "11.8.12"
|
version "11.8.12"
|
||||||
resolved "https://registry.npmjs.org/react-i18next/-/react-i18next-11.8.12.tgz#6a9f57277062fb6a6129cad4db5e6198d5c60b58"
|
resolved "https://registry.npmjs.org/react-i18next/-/react-i18next-11.8.12.tgz#6a9f57277062fb6a6129cad4db5e6198d5c60b58"
|
||||||
@ -9913,6 +9928,11 @@ react-scripts@4.0.3:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents "^2.1.3"
|
fsevents "^2.1.3"
|
||||||
|
|
||||||
|
react-side-effect@^2.1.0:
|
||||||
|
version "2.1.1"
|
||||||
|
resolved "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.1.tgz#66c5701c3e7560ab4822a4ee2742dee215d72eb3"
|
||||||
|
integrity sha512-2FoTQzRNTncBVtnzxFOk2mCpcfxQpenBMbk5kSVBg5UcPqV9fRbgY2zhb7GTWWOlpFmAxhClBDlIq8Rsubz1yQ==
|
||||||
|
|
||||||
react-social-login-buttons@^3.4.0:
|
react-social-login-buttons@^3.4.0:
|
||||||
version "3.4.0"
|
version "3.4.0"
|
||||||
resolved "https://registry.npmjs.org/react-social-login-buttons/-/react-social-login-buttons-3.4.0.tgz#7b3f249c661624435e01881cf163ef4c4a960409"
|
resolved "https://registry.npmjs.org/react-social-login-buttons/-/react-social-login-buttons-3.4.0.tgz#7b3f249c661624435e01881cf163ef4c4a960409"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user