forked from newthuhole/hole_thu_frontend
login by token
... and other improvements
This commit is contained in:
@@ -400,7 +400,7 @@ function FlowChunk(props) {
|
||||
<div className="flow-chunk">
|
||||
{!!props.title && <TitleLine text={props.title} />}
|
||||
{props.list.map((info,ind)=>(
|
||||
<LazyLoad key={info.pid} offset={500} height="15em" once={true} >
|
||||
<LazyLoad key={info.pid} offset={1500} height="15em" once={true} >
|
||||
<div>
|
||||
{!!(props.deletion_detect && props.mode==='list' && ind && props.list[ind-1].pid-info.pid>1) &&
|
||||
<div className="flow-item-row">
|
||||
|
||||
@@ -86,7 +86,7 @@ class ControlBar extends PureComponent {
|
||||
}
|
||||
|
||||
const mode=this.state.search_text.startsWith('#') ? 'single' : 'search';
|
||||
this.set_mode(mode,this.state.search_text||null);
|
||||
this.set_mode(mode,this.state.search_text||'');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, {Component, PureComponent} from 'react';
|
||||
import {SafeTextarea} from './Common';
|
||||
import {API_VERSION_PARAM} from './flows_api'
|
||||
import {API_VERSION_PARAM,API} from './flows_api'
|
||||
import md5 from 'md5';
|
||||
|
||||
import './UserAction.css';
|
||||
@@ -28,6 +28,7 @@ export class LoginForm extends Component {
|
||||
|
||||
this.username_ref=React.createRef();
|
||||
this.password_ref=React.createRef();
|
||||
this.input_token_ref=React.createRef();
|
||||
}
|
||||
|
||||
do_sendcode() {
|
||||
@@ -54,7 +55,7 @@ export class LoginForm extends Component {
|
||||
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
});
|
||||
},()=>{
|
||||
let data=new URLSearchParams();
|
||||
data.append('username', this.username_ref.current.value);
|
||||
data.append('valid_code', this.password_ref.current.value);
|
||||
@@ -86,6 +87,32 @@ export class LoginForm extends Component {
|
||||
});
|
||||
console.error(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
do_input_token(set_token) {
|
||||
if(this.state.loading_status==='loading')
|
||||
return;
|
||||
|
||||
let token=this.input_token_ref.current.value;
|
||||
this.setState({
|
||||
loading_status: 'loading',
|
||||
},()=>{
|
||||
API.get_attention(token)
|
||||
.then((_)=>{
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
set_token(token);
|
||||
})
|
||||
.catch((e)=>{
|
||||
alert('Token检验失败');
|
||||
this.setState({
|
||||
loading_status: 'done',
|
||||
});
|
||||
console.error(e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -129,6 +156,15 @@ export class LoginForm extends Component {
|
||||
登录请求会被发送到北大统一验证接口和 PKU Helper 服务器 <br />
|
||||
我们不会记录或使用您的登录信息
|
||||
</p>
|
||||
<hr />
|
||||
<p>从其他设备导入登录状态</p>
|
||||
<p>
|
||||
<input ref={this.input_token_ref} placeholder="User Token" />
|
||||
<button type="button" disabled={this.state.loading_status==='loading'}
|
||||
onClick={(e)=>this.do_input_token(token.set_value)}>
|
||||
导入
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -269,7 +305,7 @@ export class PostForm extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
proc_img(file) { // http://pkuhole.chenpong.com/
|
||||
proc_img(file) {
|
||||
return new Promise((resolve,reject)=>{
|
||||
function return_url(url) {
|
||||
const idx=url.indexOf(';base64,');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
|
||||
|
||||
const golden_ratio_conjugate=0.618033988749895;
|
||||
//const golden_ratio_conjugate=0.618033988749895;
|
||||
const golden_ratio_conjugate=0.61;
|
||||
|
||||
export class ColorPicker {
|
||||
constructor() {
|
||||
|
||||
Reference in New Issue
Block a user