diff --git a/src/App.js b/src/App.js
index 291fa3a..71baf3f 100644
--- a/src/App.js
+++ b/src/App.js
@@ -6,6 +6,7 @@ import {PressureHelper} from './PressureHelper';
import {TokenCtx} from './UserAction';
import {load_config,bgimg_style} from './Config';
import {listen_darkmode} from './infrastructure/functions';
+import {LoginPopup, TitleLine} from './infrastructure/widgets';
const MAX_SIDEBAR_STACK_SIZE=10;
@@ -99,7 +100,14 @@ class App extends Component {
{!token.value &&
}
@@ -107,11 +115,7 @@ class App extends Component {
:
-
+
}
diff --git a/src/UserAction.css b/src/UserAction.css
index 6e2135d..00b1c63 100644
--- a/src/UserAction.css
+++ b/src/UserAction.css
@@ -2,17 +2,9 @@
margin: 1em 0;
text-align: center;
}
-.login-form input {
- width: 8rem;
-}
.login-form button {
width: 6rem;
}
-.login-type {
- display: inline-block;
- width: 6rem;
- margin: 0 .5rem;
-}
.reply-form {
display: flex;
diff --git a/src/UserAction.js b/src/UserAction.js
index a42f946..776d17f 100644
--- a/src/UserAction.js
+++ b/src/UserAction.js
@@ -5,8 +5,7 @@ import {MessageViewer} from './Message';
import {API_VERSION_PARAM, PKUHELPER_ROOT, API, get_json, token_param} from './flows_api';
import './UserAction.css';
-
-const LOGIN_BASE=PKUHELPER_ROOT+'services/login';
+import {LoginPopup} from './infrastructure/widgets';
const BASE64_RATE=4/3;
const MAX_IMG_DIAM=8000;
@@ -73,117 +72,6 @@ class ResetUsertokenWidget extends Component {
}
export class LoginForm extends Component {
- constructor(props) {
- super(props);
- this.state={
- loading_status: 'done',
- };
-
- this.username_ref=React.createRef();
- this.password_ref=React.createRef();
- this.input_token_ref=React.createRef();
- }
-
- do_sendcode(api_name) {
- if(this.state.loading_status==='loading')
- return;
-
- this.setState({
- loading_status: 'loading',
- },()=>{
- fetch(
- PKUHELPER_ROOT+'api_xmcp/isop/'+api_name
- +'?user='+encodeURIComponent(this.username_ref.current.value)
- +API_VERSION_PARAM()
- )
- .then(get_json)
- .then((json)=>{
- console.log(json);
- if(!json.success)
- throw new Error(JSON.stringify(json));
-
- alert(json.msg);
- this.setState({
- loading_status: 'done',
- });
- })
- .catch((e)=>{
- console.error(e);
- alert('发送失败\n'+e);
- this.setState({
- loading_status: 'done',
- });
- });
-
- });
- }
-
- do_login(set_token) {
- if(this.state.loading_status==='loading')
- return;
-
- 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'+API_VERSION_PARAM(), {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body: data,
- })
- .then(get_json)
- .then((json)=>{
- if(json.code!==0) {
- if(json.msg) throw new Error(json.msg);
- throw new Error(JSON.stringify(json));
- }
-
- set_token(json.user_token);
- alert(`成功以 ${json.name} 的身份登录`);
- this.setState({
- loading_status: 'done',
- });
- })
- .catch((e)=>{
- console.error(e);
- alert('登录失败\n'+e);
- 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检验失败\n'+e);
- this.setState({
- loading_status: 'done',
- });
- console.error(e);
- });
- });
- }
-
copy_token(token) {
if(copy(token))
alert('复制成功!\n请一定不要泄露哦');
@@ -217,43 +105,19 @@ export class LoginForm extends Component {
User Token 用于迁移登录状态,切勿告知他人,若怀疑被盗号请尽快
:
-
+ {(do_popup)=>(
+
+
+
+
+
+ PKU Helper 面向北京大学学生,通过 ISOP(北京大学数据共享开放服务平台)验证您的身份并提供服务。
+
+
+ )}
}
}
diff --git a/src/flows_api.js b/src/flows_api.js
index 508726a..4ed5384 100644
--- a/src/flows_api.js
+++ b/src/flows_api.js
@@ -1,12 +1,9 @@
-import {get_json} from './infrastructure/functions';
+import {get_json, API_VERSION_PARAM} from './infrastructure/functions';
import {PKUHELPER_ROOT} from './infrastructure/const';
import {API_BASE} from './Common';
import {cache} from './cache';
-export function API_VERSION_PARAM() {
- return '&PKUHelperAPI=3.0&jsapiver='+encodeURIComponent((process.env.REACT_APP_BUILD_INFO||'null')+'-'+Math.floor(+new Date()/3600000));
-}
-export {PKUHELPER_ROOT};
+export {PKUHELPER_ROOT, API_VERSION_PARAM};
export function token_param(token) {
return API_VERSION_PARAM()+(token ? ('&user_token='+token) : '');
diff --git a/src/infrastructure b/src/infrastructure
index f1502d1..4643d70 160000
--- a/src/infrastructure
+++ b/src/infrastructure
@@ -1 +1 @@
-Subproject commit f1502d1e7b2df4a311543d25e7f484952e9d7191
+Subproject commit 4643d7039a543a9a573bc8d70ddb132fd7a864f9