Fix UI for anonymous user.

This commit is contained in:
Gucheng Wang 2021-12-02 00:27:45 +08:00
parent 116483078a
commit 7b4ff0b44a
14 changed files with 584 additions and 811 deletions

View File

@ -48,6 +48,20 @@ class Avatar extends React.Component {
src = Setting.getUserAvatar(this.props.username);
}
if (this.props.username === "" || this.props.username === "客人") {
return (
<img
src={"https://cdn.casbin.com/avatar-pool/anonymous.png"}
className="avatar"
border="0"
align="default"
style={style}
alt={"Anonymous User"}
key={this.props.key}
/>
);
}
return (
<Link to={`/member/${this.props.username}`}>
<img

View File

@ -33,7 +33,6 @@ export let ServerUrl = "";
export let ClientUrl = "";
export let CasdoorSdk;
// export const StaticBaseUrl = "https://cdn.jsdelivr.net/gh/casbin/static";
export const StaticBaseUrl = "https://cdn.casbin.org";
export function initServerUrl() {

47
web/src/UserLink.js Normal file
View File

@ -0,0 +1,47 @@
// Copyright 2021 The casbin Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import React from "react";
import { Link } from "react-router-dom";
import i18next from "i18next";
class UserLink extends React.Component {
constructor(props) {
super(props);
this.state = {
classes: props,
};
}
render() {
if (this.props.username === "" || this.props.username === "客人") {
return (
<span className={`${this.props.classNameText}`}>
{i18next.t("general:Anonymous")}
</span>
);
}
return (
<Link
to={`/member/${this.props.username}`}
className={`${this.props.classNameText}`}
>
{this.props.username}
</Link>
);
}
}
export default UserLink;

View File

@ -181,6 +181,7 @@
},
"general": {
"Admin": "Admin",
"Anonymous": "Anonymous",
"Home": "Home",
"Homepage": "Homepage",
"Language": "Language",

View File

@ -181,6 +181,7 @@
},
"general": {
"Admin": "Admin",
"Anonymous": "Anonymous",
"Home": "Home",
"Homepage": "Homepage",
"Language": "Language",

View File

@ -181,6 +181,7 @@
},
"general": {
"Admin": "Admin",
"Anonymous": "Anonymous",
"Home": "Home",
"Homepage": "Homepage",
"Language": "Language",

File diff suppressed because it is too large Load Diff

View File

@ -181,6 +181,7 @@
},
"general": {
"Admin": "Admin",
"Anonymous": "Anonymous",
"Home": "Home",
"Homepage": "Homepage",
"Language": "Language",

View File

@ -181,6 +181,7 @@
},
"general": {
"Admin": "Админ",
"Anonymous": "Anonymous",
"Home": "Домой",
"Homepage": "Домашняя страница",
"Language": "Язык",

View File

@ -181,6 +181,7 @@
},
"general": {
"Admin": "后台",
"Anonymous": "匿名",
"Home": "首页",
"Homepage": "个人主页",
"Language": "语言选择",

View File

@ -22,7 +22,6 @@ import AllCreatedTopicsBox from "./AllCreatedTopicsBox";
import LatestReplyBox from "./LatestReplyBox";
import i18next from "i18next";
import { scoreConverter } from "./Tools";
import { getProviderLogoLink } from "../Setting";
class MemberBox extends React.Component {
constructor(props) {

View File

@ -24,6 +24,7 @@ import PageColumn from "./PageColumn";
import ReactMarkdown from "react-markdown";
import Zmage from "react-zmage";
import i18next from "i18next";
import UserLink from "../UserLink";
// const pangu = require("pangu");
const maxReplyDepth = Setting.PcBrowser
@ -408,9 +409,7 @@ class ReplyBox extends React.Component {
)}
</div>
<strong>
<Link to={`/member/${reply.author}`} className="dark">
{reply.author}
</Link>
<UserLink username={reply.author} classNameText={"dark"} />
</strong>
<Link
className="ago"

View File

@ -26,6 +26,7 @@ import "../node.css";
import Zmage from "react-zmage";
import { Link } from "react-router-dom";
import i18next from "i18next";
import UserLink from "../UserLink";
require("codemirror/mode/markdown/markdown");
@ -616,9 +617,7 @@ class TopicBox extends React.Component {
<tr>
<td align="right">{i18next.t("topic:Creator")}</td>
<td align="left">
<Link to={`/member/${this.state.topic?.author}`}>
{this.state.topic?.author}
</Link>
<UserLink username={this.state.topic?.author} />
</td>
</tr>
<tr>
@ -751,12 +750,10 @@ class TopicBox extends React.Component {
</span>
) : null}
<small className="gray">
<Link
to={`/member/${this.state.topic?.author}`}
className={`${this.state.topic.nodeId}`}
>
{this.state.topic?.author}
</Link>{" "}
<UserLink
username={this.state.topic?.author}
classNameText={`${this.state.topic.nodeId}`}
/>{" "}
· {Setting.getPrettyDate(this.state.topic?.createdTime)} ·{" "}
{this.state.topic?.hitCount} {i18next.t("topic:hits")}
&nbsp;{" "}

View File

@ -19,6 +19,7 @@ import Avatar from "../Avatar";
import "../node.css";
import i18next from "i18next";
import { Link } from "react-router-dom";
import UserLink from "../UserLink";
const pangu = require("pangu");
class TopicList extends React.Component {
@ -110,9 +111,10 @@ class TopicList extends React.Component {
</Link>{" "}
&nbsp;&nbsp;{" "}
<strong>
<Link to={`/member/${topic.author}`} className="node">
{topic.author}
</Link>
<UserLink
username={topic.author}
classNameText={"node"}
/>
</strong>
</span>
) : null}
@ -145,12 +147,10 @@ class TopicList extends React.Component {
</span>
) : null}
<strong>
<Link
to={`/member/${topic.author}`}
className={`${this.props.nodeId} member`}
>
{topic.author}
</Link>
<UserLink
username={topic.author}
classNameText={`${this.props.nodeId} member`}
/>
</strong>{" "}
&nbsp;&nbsp;{" "}
{topic.lastReplyTime === "" ||
@ -164,12 +164,10 @@ class TopicList extends React.Component {
"topic:last reply from"
)}{" "}
<strong>
<Link
to={`/member/${topic.lastReplyUser}`}
className={`${this.props.nodeId} member`}
>
{topic.lastReplyUser}
</Link>
<UserLink
username={topic.lastReplyUser}
classNameText={`${this.props.nodeId} member`}
/>
</strong>
</div>
)}
@ -189,12 +187,10 @@ class TopicList extends React.Component {
"topic:last reply from"
)}{" "}
<strong>
<Link
to={`/member/${topic.lastReplyUser}`}
className={`${this.props.nodeId} member`}
>
{topic.lastReplyUser}
</Link>
<UserLink
username={topic.lastReplyUser}
classNameText={`${this.props.nodeId} member`}
/>
</strong>
</div>
)}