props.show_sidebar(
- 'P大树洞',
+ 'T大树洞',
)}>
- P大树洞
+ T大树洞
diff --git a/src/UserAction.js b/src/UserAction.js
index 7b311fa..9203c03 100644
--- a/src/UserAction.js
+++ b/src/UserAction.js
@@ -6,7 +6,7 @@ import {ConfigUI} from './Config';
import fixOrientation from 'fix-orientation';
import copy from 'copy-to-clipboard';
import {cache} from './cache';
-import {API_VERSION_PARAM, PKUHELPER_ROOT, API, get_json, token_param} from './flows_api';
+import {API_VERSION_PARAM, THUHOLE_API_ROOT, API, get_json, token_param} from './flows_api';
import './UserAction.css';
@@ -20,179 +20,179 @@ export const TokenCtx=React.createContext({
set_value: ()=>{},
});
-class LifeInfoBox extends Component {
- constructor(props) {
- super(props);
- if(!window._life_info_cache)
- window._life_info_cache={};
- this.CACHE_TIMEOUT_S=15;
- this.state={
- today_info: this.cache_get('today_info'),
- card_balance: this.cache_get('card_balance'),
- net_balance: this.cache_get('net_balance'),
- mail_count: this.cache_get('mail_count'),
- };
- this.INTERNAL_NETWORK_FAILURE='_network_failure';
- this.API_NAME={
- today_info: 'hole/today_info',
- card_balance: 'isop/card_balance',
- net_balance: 'isop/net_balance',
- mail_count: 'isop/mail_count',
- };
- }
-
- cache_get(key) {
- let cache_item=window._life_info_cache[key];
- if(!cache_item || (+new Date())-cache_item[0]>1000*this.CACHE_TIMEOUT_S)
- return null;
- else
- return cache_item[1];
- }
- cache_set(key,value) {
- if(!window._life_info_cache[key] || window._life_info_cache[key][1]!==value)
- window._life_info_cache[key]=[+new Date(),value];
- }
-
- load(state_key) {
- this.setState({
- [state_key]: null,
- },()=>{
- fetch(
- PKUHELPER_ROOT+'api_xmcp/'+this.API_NAME[state_key]
- +'?user_token='+encodeURIComponent(this.props.token)
- +API_VERSION_PARAM()
- )
- .then(get_json)
- .then((json)=>{
- //console.log(json);
- this.setState({
- [state_key]: json,
- });
- })
- .catch((e)=>{
- this.setState({
- [state_key]: {
- errMsg: '网络错误 '+e,
- errCode: this.INTERNAL_NETWORK_FAILURE,
- success: false,
- }
- });
- })
- });
- }
-
- componentDidMount() {
- ['today_info','card_balance','net_balance','mail_count'].forEach((k)=>{
- if(!this.state[k])
- this.load(k);
- });
- }
-
- reload_all() {
- ['today_info','card_balance','net_balance','mail_count'].forEach((k)=>{
- this.load(k);
- });
- }
-
- render_line(state_key,title,value_fn,action,url_fn,do_login) {
- let s=this.state[state_key];
- if(!s)
- return (
-
- {title} |
- 加载中…… |
- |
-
- );
- else if(!s.success) {
- let type='加载失败';
- if(s.errCode===this.INTERNAL_NETWORK_FAILURE)
- type='网络错误';
- else if(['E01','E02','E03'].indexOf(s.errCode)!==-1)
- type='授权失效';
-
- let details=JSON.stringify(s);
- if(s.errMsg)
- details=s.errMsg;
- else if(s.error)
- details=s.error;
-
- return (
-
- {title} |
-
- alert(details)}>{type}
- |
-
- {type==='授权失效' ?
-
- 重新登录
- :
- this.load(state_key)}>
- 重试
-
- }
- |
-
- )
- }
- else {
- this.cache_set(state_key,s);
-
- return (
-
- {title} |
- {value_fn(s)} |
-
-
- {action}
-
- |
-
- );
- }
- }
-
- render() {
- return (
-
{
- this.props.set_token(t);
- this.reload_all();
- }}>{(do_login)=>(
-
-
-
- {this.render_line(
- 'today_info',
- '今日',(s)=>s.info,
- '校历',(s)=>s.schedule_url,
- do_login,
- )}
- {this.render_line(
- 'card_balance',
- '校园卡',(s)=>`余额¥${s.balance.toFixed(2)}`,
- '充值',()=>'https://virtualprod.alipay.com/educate/educatePcRecharge.htm?schoolCode=PKU&schoolName=',
- do_login,
- )}
- {this.render_line(
- 'net_balance',
- '网费',(s)=>`余额¥${s.balance.toFixed(2)}`,
- '充值',()=>'https://its.pku.edu.cn/epay.jsp',
- do_login,
- )}
- {this.render_line(
- 'mail_count',
- '邮件',(s)=>`未读 ${s.count} 封`,
- '查看',()=>'https://mail.pku.edu.cn/',
- do_login,
- )}
-
-
-
- )}
- )
- }
-}
+// class LifeInfoBox extends Component {
+// constructor(props) {
+// super(props);
+// if(!window._life_info_cache)
+// window._life_info_cache={};
+// this.CACHE_TIMEOUT_S=15;
+// this.state={
+// today_info: this.cache_get('today_info'),
+// card_balance: this.cache_get('card_balance'),
+// net_balance: this.cache_get('net_balance'),
+// mail_count: this.cache_get('mail_count'),
+// };
+// this.INTERNAL_NETWORK_FAILURE='_network_failure';
+// this.API_NAME={
+// today_info: 'hole/today_info',
+// card_balance: 'isop/card_balance',
+// net_balance: 'isop/net_balance',
+// mail_count: 'isop/mail_count',
+// };
+// }
+//
+// cache_get(key) {
+// let cache_item=window._life_info_cache[key];
+// if(!cache_item || (+new Date())-cache_item[0]>1000*this.CACHE_TIMEOUT_S)
+// return null;
+// else
+// return cache_item[1];
+// }
+// cache_set(key,value) {
+// if(!window._life_info_cache[key] || window._life_info_cache[key][1]!==value)
+// window._life_info_cache[key]=[+new Date(),value];
+// }
+//
+// load(state_key) {
+// this.setState({
+// [state_key]: null,
+// },()=>{
+// fetch(
+// PKUHELPER_ROOT+'api_xmcp/'+this.API_NAME[state_key]
+// +'?user_token='+encodeURIComponent(this.props.token)
+// +API_VERSION_PARAM()
+// )
+// .then(get_json)
+// .then((json)=>{
+// //console.log(json);
+// this.setState({
+// [state_key]: json,
+// });
+// })
+// .catch((e)=>{
+// this.setState({
+// [state_key]: {
+// errMsg: '网络错误 '+e,
+// errCode: this.INTERNAL_NETWORK_FAILURE,
+// success: false,
+// }
+// });
+// })
+// });
+// }
+//
+// componentDidMount() {
+// ['today_info','card_balance','net_balance','mail_count'].forEach((k)=>{
+// if(!this.state[k])
+// this.load(k);
+// });
+// }
+//
+// reload_all() {
+// ['today_info','card_balance','net_balance','mail_count'].forEach((k)=>{
+// this.load(k);
+// });
+// }
+//
+// render_line(state_key,title,value_fn,action,url_fn,do_login) {
+// let s=this.state[state_key];
+// if(!s)
+// return (
+//
+// {title} |
+// 加载中…… |
+// |
+//
+// );
+// else if(!s.success) {
+// let type='加载失败';
+// if(s.errCode===this.INTERNAL_NETWORK_FAILURE)
+// type='网络错误';
+// else if(['E01','E02','E03'].indexOf(s.errCode)!==-1)
+// type='授权失效';
+//
+// let details=JSON.stringify(s);
+// if(s.errMsg)
+// details=s.errMsg;
+// else if(s.error)
+// details=s.error;
+//
+// return (
+//
+// {title} |
+//
+// alert(details)}>{type}
+// |
+//
+// {type==='授权失效' ?
+//
+// 重新登录
+// :
+// this.load(state_key)}>
+// 重试
+//
+// }
+// |
+//
+// )
+// }
+// else {
+// this.cache_set(state_key,s);
+//
+// return (
+//
+// {title} |
+// {value_fn(s)} |
+//
+//
+// {action}
+//
+// |
+//
+// );
+// }
+// }
+//
+// render() {
+// return (
+//
{
+// this.props.set_token(t);
+// this.reload_all();
+// }}>{(do_login)=>(
+//
+//
+//
+// {this.render_line(
+// 'today_info',
+// '今日',(s)=>s.info,
+// '校历',(s)=>s.schedule_url,
+// do_login,
+// )}
+// {this.render_line(
+// 'card_balance',
+// '校园卡',(s)=>`余额¥${s.balance.toFixed(2)}`,
+// '充值',()=>'https://virtualprod.alipay.com/educate/educatePcRecharge.htm?schoolCode=PKU&schoolName=',
+// do_login,
+// )}
+// {this.render_line(
+// 'net_balance',
+// '网费',(s)=>`余额¥${s.balance.toFixed(2)}`,
+// '充值',()=>'https://its.pku.edu.cn/epay.jsp',
+// do_login,
+// )}
+// {this.render_line(
+// 'mail_count',
+// '邮件',(s)=>`未读 ${s.count} 封`,
+// '查看',()=>'https://mail.pku.edu.cn/',
+// do_login,
+// )}
+//
+//
+//
+// )}
+// )
+// }
+// }
export function InfoSidebar(props) {
return (
@@ -207,23 +207,25 @@ export function InfoSidebar(props) {
-
-
-
-
-
+ {/**/}
+ {/* */}
+ {/**/}
+ {/* */}
+
- PKUHelper 网页版树洞 by @xmcp,
+ T大树洞 网页版 by @thuhole,
基于
GPLv3
- 协议在 GitHub 开源
+ 协议在 GitHub 开源
- PKUHelper 网页版的诞生离不开
+ T大树洞 网页版的诞生离不开
+ P大树洞
+ 、
React
、
IcoMoon
@@ -280,7 +282,7 @@ class ResetUsertokenWidget extends Component {
this.setState({
loading_status: 'loading',
},()=>{
- fetch(PKUHELPER_ROOT+'api_xmcp/hole/reset_usertoken', {
+ fetch(THUHOLE_API_ROOT+'api_xmcp/hole/reset_usertoken', {
method: 'post',
headers: {
'Content-Type': 'application/json',
@@ -329,9 +331,9 @@ export class LoginForm extends Component {
return (
{(token)=>
- {!!token.value &&
-
- }
+ {/*{!!token.value &&*/}
+ {/*
*/}
+ {/*}*/}
{token.value ?
@@ -354,7 +356,7 @@ export class LoginForm extends Component {
复制 User Token
- User Token 用于迁移登录状态,切勿告知他人,若怀疑被盗号请尽快
+ User Token 用于迁移登录状态,切勿告知他人{/*,若怀疑被盗号请尽快 */}
:
{(do_popup)=>(
@@ -366,7 +368,7 @@ export class LoginForm extends Component {
- PKU Helper 面向北京大学学生,通过 ISOP(北京大学数据共享开放服务平台)验证您的身份并提供服务。
+ T大树洞 面向清华大学学生,通过清华邮箱验证您的身份并提供服务。
)}
diff --git a/src/flows_api.js b/src/flows_api.js
index 4ed5384..f897d64 100644
--- a/src/flows_api.js
+++ b/src/flows_api.js
@@ -1,9 +1,9 @@
import {get_json, API_VERSION_PARAM} from './infrastructure/functions';
-import {PKUHELPER_ROOT} from './infrastructure/const';
+import {THUHOLE_API_ROOT} from './infrastructure/const';
import {API_BASE} from './Common';
import {cache} from './cache';
-export {PKUHELPER_ROOT, API_VERSION_PARAM};
+export {THUHOLE_API_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 9901aa8..e24cf98 160000
--- a/src/infrastructure
+++ b/src/infrastructure
@@ -1 +1 @@
-Subproject commit 9901aa83dfa8ee01da9e9480cc9524b18e29c40c
+Subproject commit e24cf980948f63cc1535a6d2eb69319c5b3b055e
diff --git a/src/text_splitter.js b/src/text_splitter.js
index 02f1b16..713bdb2 100644
--- a/src/text_splitter.js
+++ b/src/text_splitter.js
@@ -1,6 +1,9 @@
// regexp should match the WHOLE segmented part
-export const PID_RE=/(^|[^\d\u20e3\ufe0e\ufe0f])([2-9]\d{4,5}|1\d{4,6})(?![\d\u20e3\ufe0e\ufe0f])/g;
-export const URL_PID_RE=/((?:https?:\/\/)?pkuhelper\.pku\.edu\.cn\/hole\/?#(?:#|%23)([2-9]\d{4,5}|1\d{4,6}))(?!\d|\u20e3|\ufe0e|\ufe0f)/g;
+// export const PID_RE=/(^|[^\d\u20e3\ufe0e\ufe0f])([2-9]\d{4,5}|1\d{4,6})(?![\d\u20e3\ufe0e\ufe0f])/g;
+export const PID_RE=/(^|[^\d\u20e3\ufe0e\ufe0f])(#\d{1,7})(?![\d\u20e3\ufe0e\ufe0f])/g;
+// TODO: fix this re
+// export const URL_PID_RE=/((?:https?:\/\/)?thuhole\.tech\/?#(?:#|%23)([2-9]\d{4,5}|1\d{4,6}))(?!\d|\u20e3|\ufe0e|\ufe0f)/g;
+export const URL_PID_RE=/((?:https?:\/\/)?thuhole\.tech\/?#(?:#|%23)(\d{1,7}))(?!\d|\u20e3|\ufe0e|\ufe0f)/g;
export const NICKNAME_RE=/(^|[^A-Za-z])((?:(?:Angry|Baby|Crazy|Diligent|Excited|Fat|Greedy|Hungry|Interesting|Jolly|Kind|Little|Magic|Naïve|Old|Powerful|Quiet|Rich|Superman|THU|Undefined|Valuable|Wifeless|Xiangbuchulai|Young|Zombie)\s)?(?:Alice|Bob|Carol|Dave|Eve|Francis|Grace|Hans|Isabella|Jason|Kate|Louis|Margaret|Nathan|Olivia|Paul|Queen|Richard|Susan|Thomas|Uma|Vivian|Winnie|Xander|Yasmine|Zach)|You Win(?: \d+)?|洞主)(?![A-Za-z])/gi;
export const URL_RE=/(^|[^.@a-zA-Z0-9_])((?:https?:\/\/)?(?:(?:[\w-]+\.)+[a-zA-Z]{2,3}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::\d{1,5})?(?:\/[\w~!@#$%^&*()\-_=+[\]{};:,./?|]*)?)(?![a-zA-Z0-9])/gi;