15分钟自命名临时用户

This commit is contained in:
2020-09-08 11:22:17 +08:00
parent 6d4d637585
commit e7d57c9d7a
5 changed files with 52 additions and 4 deletions

View File

@@ -142,7 +142,7 @@ export class HighlightedMarkdown extends Component {
<img
src={normalize_url(node.attribs.src)}
alt={node.alt}
referrerpolicy="no-referrer"
referrerPolicy="no-referrer"
/>
</a>
);

View File

@@ -420,7 +420,7 @@ class FlowSidebar extends PureComponent {
this.setState({
loading_status: 'done',
});
alert('设置关注失败');
alert('设置关注失败\n' + e);
console.error(e);
});
}

19
src/Message.css Normal file
View File

@@ -0,0 +1,19 @@
.input-prepend {
display: inline-block;
background-color: #c9cccf;
border: 1px solid #ced4da;
height: 28px;
padding: 3px;
vertical-align: top;
}
.input-suf {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
width: 90px;
height: 28px;
border: 1px solid #ced4da;
vertical-align: top;
padding: 3px;
}

View File

@@ -2,6 +2,8 @@ import React, { PureComponent } from 'react';
import { Time } from './Common';
import { get_json } from './infrastructure/functions';
import './Message.css';
export class MessageViewer extends PureComponent {
constructor(props) {
super(props);
@@ -9,6 +11,7 @@ export class MessageViewer extends PureComponent {
loading_status: 'idle',
msg: [],
};
this.input_suf_ref=React.createRef();
}
componentDidMount() {
@@ -32,7 +35,8 @@ export class MessageViewer extends PureComponent {
loading_status: 'done',
msg: json.data,
start_time: json.start_time,
salt: json.salt
salt: json.salt,
tmp_token: json.tmp_token,
});
})
.catch((err) => {
@@ -46,6 +50,20 @@ export class MessageViewer extends PureComponent {
);
}
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 <p className="box box-tip">加载中</p>;
@@ -71,8 +89,18 @@ export class MessageViewer extends PureComponent {
<p>
随机盐 <b>{this.state.salt}</b>
</p>
<br/>
<div>
<p>15分钟临时token:</p>
<div className="input-prepend">{this.state.tmp_token}_ </div>
<input type="text" className="input-suf" ref={this.input_suf_ref} placeholder="自定义后缀" maxLength={10}/>
<button type="button" disabled={this.state.loading_status==='loading'}
onClick={(e)=>this.do_set_token()}>
使用
</button>
</div>
{this.state.msg.map((msg) => (
<div className="box" key={msg.timestamp}>
<div className="box" key={msg.type + msg.timestamp}>
<div className="box-header">
<Time stamp={msg.timestamp} short={false} />
&nbsp;

View File

@@ -100,6 +100,7 @@ class ControlBar extends PureComponent {
search_text: '',
});
this.set_mode('list', null);
window.location.hash = '';
}
do_attention() {