import React, { PureComponent } from 'react'; import { Time, API_BASE } from './Common'; import { get_json } from './infrastructure/functions'; import './Message.css'; export class MessageViewer extends PureComponent { constructor(props) { super(props); this.state = { loading_status: 'idle', msg: [], }; this.input_suf_ref = React.createRef(); } componentDidMount() { this.load(); } load() { if (this.state.loading_status === 'loading') return; this.setState( { loading_status: 'loading', }, () => { fetch(API_BASE + '/systemlog', { headers: { 'User-Token': this.props.token }, }) .then(get_json) .then((json) => { this.setState({ loading_status: 'done', msg: json.data, start_time: json.start_time, salt: json.salt, tmp_token: json.tmp_token, }); }) .catch((err) => { console.error(err); alert('' + err); this.setState({ loading_status: 'failed', }); }); }, ); } do_set_token() { if (this.state.loading_status === 'loading') return; if (!this.input_suf_ref.current.value) { alert('不建议后缀为空'); return; } let tt = this.state.tmp_token + '_' + this.input_suf_ref.current.value; console.log(tt); localStorage['TOKEN'] = tt; alert('已登录为临时用户,过期后需注销重新登陆'); window.location.reload(); } render() { if (this.state.loading_status === 'loading') return

加载中……

; else if (this.state.loading_status === 'failed') return (
{ this.load(); }} > 重新加载
); else if (this.state.loading_status === 'done') return ( <>

最近一次重置

随机盐 {this.state.salt}


15分钟临时token:

{this.state.tmp_token}_
{this.state.msg.map((msg) => (
{msg.detail}
))} ); else return null; } }