diff --git a/src/Flows.js b/src/Flows.js index d3a8900..5a4a0a2 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -400,7 +400,7 @@ function FlowChunk(props) {
{!!props.title && } {props.list.map((info,ind)=>( - +
{!!(props.deletion_detect && props.mode==='list' && ind && props.list[ind-1].pid-info.pid>1) &&
diff --git a/src/Title.js b/src/Title.js index aaa6b66..b83a932 100644 --- a/src/Title.js +++ b/src/Title.js @@ -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||''); } } diff --git a/src/UserAction.js b/src/UserAction.js index a3f0502..c3c1335 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -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,38 +55,64 @@ 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); - data.append('isnewloginflow', 'true'); - fetch(LOGIN_BASE+'/login.php?platform=webhole', { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - body: data, - }) - .then((res)=>res.json()) - .then((json)=>{ - if(json.code!==0) { - if(json.msg) alert(json.msg); - throw new Error(json); - } + },()=>{ + let data=new URLSearchParams(); + data.append('username', this.username_ref.current.value); + data.append('valid_code', this.password_ref.current.value); + data.append('isnewloginflow', 'true'); + fetch(LOGIN_BASE+'/login.php?platform=webhole', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: data, + }) + .then((res)=>res.json()) + .then((json)=>{ + if(json.code!==0) { + if(json.msg) alert(json.msg); + throw new Error(json); + } - set_token(json.user_token); - alert(`成功以 ${json.name} 的身份登录`); - this.setState({ - loading_status: 'done', + set_token(json.user_token); + alert(`成功以 ${json.name} 的身份登录`); + this.setState({ + loading_status: 'done', + }); + }) + .catch((e)=>{ + alert('登录失败'); + this.setState({ + loading_status: 'done', + }); + console.error(e); }); - }) - .catch((e)=>{ - alert('登录失败'); - this.setState({ - loading_status: 'done', + }); + } + + 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); }); - console.error(e); - }); + }); } render() { @@ -129,6 +156,15 @@ export class LoginForm extends Component { 登录请求会被发送到北大统一验证接口和 PKU Helper 服务器
我们不会记录或使用您的登录信息

+
+

从其他设备导入登录状态

+

+ + +

}
@@ -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,'); diff --git a/src/color_picker.js b/src/color_picker.js index 90f5a15..94a7edc 100644 --- a/src/color_picker.js +++ b/src/color_picker.js @@ -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() {