Browse Source

完成系统日志

pull/6/head
hole-thu 5 years ago
parent
commit
e79910b915
  1. 32
      src/Message.js
  2. 8
      src/UserAction.js

32
src/Message.js

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

8
src/UserAction.js

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

Loading…
Cancel
Save