完成系统日志

This commit is contained in:
2020-09-04 20:19:32 +08:00
parent bb008bc0fa
commit e79910b915
2 changed files with 38 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { Time } from './Common'; import { Time } from './Common';
import { get_json } from './infrastructure/functions';
export class MessageViewer extends PureComponent { export class MessageViewer extends PureComponent {
constructor(props) { constructor(props) {
@@ -22,17 +23,17 @@ export class MessageViewer extends PureComponent {
}, },
() => { () => {
fetch( fetch(
'/_api/v1/system_msg?user_token=' + '/_api/v1/systemlog?user_token=' +
encodeURIComponent(this.props.token) encodeURIComponent(this.props.token)
) )
.then(get_json) .then(get_json)
.then((json) => { .then((json) => {
if (json.error) throw new Error(json.error); this.setState({
else loading_status: 'done',
this.setState({ msg: json.data,
loading_status: 'done', start_time: json.start_time,
msg: json.result, salt: json.salt
}); });
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
@@ -61,17 +62,32 @@ export class MessageViewer extends PureComponent {
</div> </div>
); );
else if (this.state.loading_status === 'done') else if (this.state.loading_status === 'done')
return this.state.msg.map((msg) => ( return (
<div className="box" key={msg.timestamp}> <>
<div className="box-header"> <br/>
<Time stamp={msg.timestamp} short={false} /> <p>
<b>{msg.title}</b> 最近一次重置 <Time stamp={this.state.start_time} short={false} />
</div> </p>
<div className="box-content"> <p>
<pre>{msg.content}</pre> 随机盐 <b>{this.state.salt}</b>
</div> </p>
</div> {this.state.msg.map((msg) => (
)); <div className="box" key={msg.timestamp}>
<div className="box-header">
<Time stamp={msg.timestamp} short={false} />
&nbsp;
&nbsp;
<b>{msg.type}</b>
&nbsp;
<span className="box-header-name">{msg.user}</span>
</div>
<div className="box-content">
<pre>{msg.detail}</pre>
</div>
</div>
))}
</>
)
else return null; else return null;
} }
} }

View File

@@ -160,15 +160,15 @@ export class LoginForm extends Component {
<a <a
onClick={() => { onClick={() => {
this.props.show_sidebar( this.props.show_sidebar(
'系统消息', '系统日志',
<MessageViewer token={token.value} />, <MessageViewer token={token.value} />,
); );
}} }}
> >
查看系统消息 查看系统日志
</a> </a>
<br /> <br />
当您发送的内容违规时我们将用系统消息提示您 举报记录管理日志等都是公开的
</p> </p>
<p> <p>
<small>{token.value}</small> <small>{token.value}</small>
@@ -177,7 +177,7 @@ export class LoginForm extends Component {
复制 User Token 复制 User Token
</a> </a>
<br /> <br />
User Token仅用于开发bot切勿告知他人若怀疑被盗号请刷新Token User Token仅用于开发bot切勿告知他人若怀疑被盗号请刷新Token(刷新功能即将上线)
</p> </p>
</div> </div>
) : ( ) : (