diff --git a/README.md b/README.md index 5b2eb90..0f40654 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # AsHole -React版P大树洞,[hole.xmcp.ml](http://hole.xmcp.ml) - - +React 版 P大树洞,[hole.xmcp.ml](http://hole.xmcp.ml) 与 PKU Helper 客户端比较,本项目…… @@ -31,10 +29,15 @@ React版P大树洞,[hole.xmcp.ml](http://hole.xmcp.ml) - 精确显示发帖时间 - 复制树洞链接 - 3D Touch 支持 -- 自定义背景图片(没有提供相关 UI,请自行修改 `localStorage['REPLACE_ERIRI_WITH_URL']`) +- 自定义背景图片(请修改 Flag `REPLACE_ERIRI_WITH_URL=http://...`) +- 检测被删除的树洞(请修改 Flag `DELETION_DETECT=on`) +- 刷树洞负关注数(请修改 Flag `STAR_BRUSH=on`) +- 用 Token 登录(请修改 Flag `TOKEN=...`) **不支持** PKU Helper 树洞**支持**的以下功能: - 搜索时筛选有图片、语音的树洞 - 发表语音树洞 - 关注的树洞有回复时推送提醒 + +*注:设置 Flag 请在搜索框输入 `//setflag KEY=value`* \ No newline at end of file diff --git a/src/Flows.css b/src/Flows.css index e3d9bd4..036bfb4 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -12,6 +12,10 @@ text-align: center; } +.box-danger { + background-color: #faa; +} + .left-container .flow-item { display: inline-block; width: 600px; diff --git a/src/Flows.js b/src/Flows.js index e3a48a5..799710f 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -189,12 +189,36 @@ class FlowSidebar extends PureComponent { } } + star_brush() { + let count=prompt('Count:'); + if(count) { + let reqs=[]; + for(let i=parseInt(count);i;i--) + reqs.push(API.set_attention(this.state.info.pid,false,this.props.token)); + Promise.all(reqs) + .then(()=>{ + alert('Completed!') + }) + .catch((e)=>{ + alert('Failed!\n\n'+e); + }) + } + } + render() { + const star_brush=localStorage['STAR_BRUSH']==='on'; + if(this.state.loading_status==='loading') return (

加载中……

); return (
+ {star_brush && + + - +  /  + + } {this.props.token && 举报 @@ -314,9 +338,16 @@ function FlowChunk(props) { return ( {({value: token})=>(
- - {props.list.map((info)=>( + {!!props.title && } + {props.list.map((info,ind)=>( + {!!(props.deletion_detect && props.mode==='list' && ind && props.list[ind-1].pid-info.pid>1) && +
+
+ {props.list[ind-1].pid-info.pid-1} 条被删除 +
+
+ }
))} @@ -332,7 +363,10 @@ export class Flow extends PureComponent { mode: props.mode, search_param: props.search_text, loaded_pages: 0, - chunks: [], + chunks: { + title: '', + data: [], + }, loading_status: 'done', }; this.on_scroll_bound=this.on_scroll.bind(this); @@ -360,13 +394,13 @@ export class Flow extends PureComponent { localStorage['_LATEST_POST_ID']=x.pid; }); this.setState((prev,props)=>({ - chunks: prev.chunks.concat([{ - title: 'Page '+page, - data: json.data.filter((x)=>( - prev.chunks.length===0 || - !(prev.chunks[prev.chunks.length-1].data.some((p)=>p.pid===x.pid)) - )), - }]), + chunks: { + title: 'News Feed', + data: prev.chunks.data.concat(json.data.filter((x)=>( + prev.chunks.data.length===0 || + !(prev.chunks.data.slice(-100).some((p)=>p.pid===x.pid)) + ))), + }, loading_status: 'done', })); }) @@ -376,10 +410,10 @@ export class Flow extends PureComponent { .then((json)=>{ const finished=json.data.length{ this.setState({ - chunks: [{ + chunks: { title: 'PID = '+pid, data: [json.data], - }], + }, mode: 'single_finished', loading_status: 'done', }); @@ -403,10 +437,10 @@ export class Flow extends PureComponent { API.get_attention(this.props.token) .then((json)=>{ this.setState({ - chunks: [{ + chunks: { title: 'Attention List', data: json.data, - }], + }, mode: 'attention_finished', loading_status: 'done', }); @@ -443,11 +477,13 @@ export class Flow extends PureComponent { } render() { + const should_deletion_detect=localStorage['DELETION_DETECT']==='on'; return (
- {this.state.chunks.map((chunk)=>( - - ))} + {this.state.loading_status==='failed' &&
{this.load_page(this.state.loaded_pages+1)}}>重新加载 diff --git a/src/Title.js b/src/Title.js index 5a12d58..7807122 100644 --- a/src/Title.js +++ b/src/Title.js @@ -5,6 +5,8 @@ import {PromotionBar} from './Common'; import './Title.css'; +const flag_re=/^\/\/setflag ([a-zA-Z0-9_]+)=(.+)$/; + const HELP_TEXT=(

使用提示:

@@ -59,7 +61,8 @@ class ControlBar extends PureComponent { componentDidMount() { if(window.location.hash) { let text=window.location.hash.substr(1); - text=text.substr(0,text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...' + if(text.lastIndexOf('?')!==-1) + text=text.substr(0,text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...' this.setState({ search_text: text, }, ()=>{ @@ -76,6 +79,13 @@ class ControlBar extends PureComponent { on_keypress(event) { if(event.key==='Enter') { + let flag_res=flag_re.exec(this.state.search_text); + if(flag_res) { + localStorage[flag_res[1]]=flag_res[2]; + alert('Set Flag '+flag_res[1]+'='+flag_res[2]); + return; + } + const mode=this.state.search_text.startsWith('#') ? 'single' : 'search'; this.set_mode(mode,this.state.search_text||null); }