feature update
- add sidebar breadcrumb - do not show dot when latest_post_id is not set
This commit is contained in:
12
src/App.js
12
src/App.js
@@ -8,7 +8,7 @@ import {TokenCtx,ISOP_APPKEY} from './UserAction';
|
|||||||
import ImasuguApp from './imasugu/src/App';
|
import ImasuguApp from './imasugu/src/App';
|
||||||
|
|
||||||
function DeprecatedAlert(props) {
|
function DeprecatedAlert(props) {
|
||||||
if(['pkuhelper.pku.edu.cn','127.0.0.1','localhostx'].indexOf(document.domain)===-1)
|
if(['pkuhelper.pku.edu.cn','127.0.0.1','localhost'].indexOf(document.domain)===-1)
|
||||||
return (
|
return (
|
||||||
<div className="flow-item-row">
|
<div className="flow-item-row">
|
||||||
<div className="box box-tip aux-margin">
|
<div className="box box-tip aux-margin">
|
||||||
@@ -31,16 +31,6 @@ function DeprecatedAlert(props) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
if(props.token && props.token.startsWith('isop_'))
|
|
||||||
return (
|
|
||||||
<div className="flow-item-row">
|
|
||||||
<div className="box box-tip box-danger aux-margin">
|
|
||||||
<p>树洞于2019年3月更新登录方式,原先登录已失效。</p>
|
|
||||||
<p>请按右上角的按钮,点“注销”,然后重新登录。</p>
|
|
||||||
<p><b>好消息:更新后支持客户端和网页同时使用了!</b></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
54
src/Flows.js
54
src/Flows.js
@@ -19,11 +19,12 @@ const PREVIEW_REPLY_COUNT=10;
|
|||||||
|
|
||||||
window.LATEST_POST_ID=parseInt(localStorage['_LATEST_POST_ID'],10)||0;
|
window.LATEST_POST_ID=parseInt(localStorage['_LATEST_POST_ID'],10)||0;
|
||||||
|
|
||||||
function load_single_meta(show_sidebar,token) {
|
function load_single_meta(show_sidebar,token,parents) {
|
||||||
return (pid)=>{
|
return (pid)=>{
|
||||||
|
let title_elem=<FlowSidebarTitle pid={pid} parents={parents} show_sidebar={show_sidebar} token={token} />;
|
||||||
const color_picker=new ColorPicker();
|
const color_picker=new ColorPicker();
|
||||||
show_sidebar(
|
show_sidebar(
|
||||||
'帖子详情',
|
title_elem,
|
||||||
<div className="box box-tip">
|
<div className="box box-tip">
|
||||||
正在加载 #{pid}
|
正在加载 #{pid}
|
||||||
</div>
|
</div>
|
||||||
@@ -36,20 +37,20 @@ function load_single_meta(show_sidebar,token) {
|
|||||||
const [single,replies]=res;
|
const [single,replies]=res;
|
||||||
single.data.variant={};
|
single.data.variant={};
|
||||||
show_sidebar(
|
show_sidebar(
|
||||||
'帖子详情',
|
title_elem,
|
||||||
<FlowSidebar
|
<FlowSidebar
|
||||||
info={single.data} replies={replies.data} attention={replies.attention}
|
info={single.data} replies={replies.data} attention={replies.attention}
|
||||||
token={token} show_sidebar={show_sidebar} color_picker={color_picker}
|
token={token} show_sidebar={show_sidebar} color_picker={color_picker}
|
||||||
deletion_detect={localStorage['DELETION_DETECT']==='on'}
|
deletion_detect={localStorage['DELETION_DETECT']==='on'} parents={parents}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
console.error(e);
|
console.error(e);
|
||||||
show_sidebar(
|
show_sidebar(
|
||||||
'帖子详情',
|
title_elem,
|
||||||
<div className="box box-tip">
|
<div className="box box-tip">
|
||||||
<p><a onClick={()=>load_single_meta(show_sidebar,token)()}>重新加载</a></p>
|
<p><a onClick={()=>load_single_meta(show_sidebar,token,parents)(pid)}>重新加载</a></p>
|
||||||
<p>{''+e}</p>
|
<p>{''+e}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -115,7 +116,9 @@ class FlowItem extends PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div className="box">
|
<div className="box">
|
||||||
{parseInt(props.info.pid,10)>window.LATEST_POST_ID && <div className="flow-item-dot" /> }
|
{!!window.LATEST_POST_ID && parseInt(props.info.pid,10)>window.LATEST_POST_ID &&
|
||||||
|
<div className="flow-item-dot" />
|
||||||
|
}
|
||||||
<div className="box-header">
|
<div className="box-header">
|
||||||
{!!parseInt(props.info.likenum,10) &&
|
{!!parseInt(props.info.likenum,10) &&
|
||||||
<span className="box-header-badge">
|
<span className="box-header-badge">
|
||||||
@@ -165,7 +168,6 @@ class FlowSidebar extends PureComponent {
|
|||||||
error_msg: null,
|
error_msg: null,
|
||||||
};
|
};
|
||||||
this.color_picker=props.color_picker;
|
this.color_picker=props.color_picker;
|
||||||
this.show_pid=load_single_meta(this.props.show_sidebar,this.props.token);
|
|
||||||
this.syncState=props.sync_state||(()=>{});
|
this.syncState=props.sync_state||(()=>{});
|
||||||
this.reply_ref=React.createRef();
|
this.reply_ref=React.createRef();
|
||||||
}
|
}
|
||||||
@@ -282,6 +284,9 @@ class FlowSidebar extends PureComponent {
|
|||||||
render() {
|
render() {
|
||||||
if(this.state.loading_status==='loading')
|
if(this.state.loading_status==='loading')
|
||||||
return (<p className="box box-tip">加载中……</p>);
|
return (<p className="box box-tip">加载中……</p>);
|
||||||
|
|
||||||
|
let show_pid=load_single_meta(this.props.show_sidebar,this.props.token,this.props.parents.concat([this.state.info.pid]));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flow-item-row sidebar-flow-item">
|
<div className="flow-item-row sidebar-flow-item">
|
||||||
<div className="box box-tip">
|
<div className="box box-tip">
|
||||||
@@ -308,7 +313,7 @@ class FlowSidebar extends PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
<ClickHandler callback={(e)=>{this.show_reply_bar('',e);}}>
|
<ClickHandler callback={(e)=>{this.show_reply_bar('',e);}}>
|
||||||
<FlowItem info={this.state.info} attention={this.state.attention} img_clickable={true}
|
<FlowItem info={this.state.info} attention={this.state.attention} img_clickable={true}
|
||||||
color_picker={this.color_picker} show_pid={this.show_pid} replies={this.state.replies}
|
color_picker={this.color_picker} show_pid={show_pid} replies={this.state.replies}
|
||||||
set_variant={(variant)=>{this.set_variant(null,variant);}}
|
set_variant={(variant)=>{this.set_variant(null,variant);}}
|
||||||
/>
|
/>
|
||||||
</ClickHandler>
|
</ClickHandler>
|
||||||
@@ -327,7 +332,7 @@ class FlowSidebar extends PureComponent {
|
|||||||
<LazyLoad key={reply.cid} offset={1500} height="5em" overflow={true} once={true}>
|
<LazyLoad key={reply.cid} offset={1500} height="5em" overflow={true} once={true}>
|
||||||
<ClickHandler callback={(e)=>{this.show_reply_bar(reply.name,e);}}>
|
<ClickHandler callback={(e)=>{this.show_reply_bar(reply.name,e);}}>
|
||||||
<Reply
|
<Reply
|
||||||
info={reply} color_picker={this.color_picker} show_pid={this.show_pid}
|
info={reply} color_picker={this.color_picker} show_pid={show_pid}
|
||||||
set_variant={(variant)=>{this.set_variant(reply.cid,variant);}}
|
set_variant={(variant)=>{this.set_variant(reply.cid,variant);}}
|
||||||
/>
|
/>
|
||||||
</ClickHandler>
|
</ClickHandler>
|
||||||
@@ -344,6 +349,24 @@ class FlowSidebar extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FlowSidebarTitle(props) {
|
||||||
|
let last_pid=props.parents.length ? props.parents[props.parents.length-1] : null;
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
树洞
|
||||||
|
{!!last_pid &&
|
||||||
|
<span>
|
||||||
|
<a onClick={()=>load_single_meta(props.show_sidebar,props.token,props.parents.slice(0,-1))(last_pid)}>
|
||||||
|
#{last_pid}
|
||||||
|
</a>
|
||||||
|
→
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
#{props.pid}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class FlowItemRow extends PureComponent {
|
class FlowItemRow extends PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -354,7 +377,6 @@ class FlowItemRow extends PureComponent {
|
|||||||
attention: false,
|
attention: false,
|
||||||
};
|
};
|
||||||
this.color_picker=new ColorPicker();
|
this.color_picker=new ColorPicker();
|
||||||
this.show_pid=load_single_meta(this.props.show_sidebar,this.props.token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -393,16 +415,18 @@ class FlowItemRow extends PureComponent {
|
|||||||
|
|
||||||
show_sidebar() {
|
show_sidebar() {
|
||||||
this.props.show_sidebar(
|
this.props.show_sidebar(
|
||||||
'帖子详情',
|
<FlowSidebarTitle pid={this.state.info.pid} parents={[]} show_sidebar={this.props.show_sidebar} token={this.props.token} />,
|
||||||
<FlowSidebar
|
<FlowSidebar
|
||||||
info={this.state.info} replies={this.state.replies} attention={this.state.attention} sync_state={this.setState.bind(this)}
|
info={this.state.info} replies={this.state.replies} attention={this.state.attention} sync_state={this.setState.bind(this)}
|
||||||
token={this.props.token} show_sidebar={this.props.show_sidebar} color_picker={this.color_picker}
|
token={this.props.token} show_sidebar={this.props.show_sidebar} color_picker={this.color_picker}
|
||||||
deletion_detect={this.props.deletion_detect}
|
deletion_detect={this.props.deletion_detect} parents={[]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let show_pid=load_single_meta(this.props.show_sidebar,this.props.token,[this.state.info.pid]);
|
||||||
|
|
||||||
let hl_rules=[
|
let hl_rules=[
|
||||||
['url',URL_RE],
|
['url',URL_RE],
|
||||||
['pid',PID_RE],
|
['pid',PID_RE],
|
||||||
@@ -429,14 +453,14 @@ class FlowItemRow extends PureComponent {
|
|||||||
this.show_sidebar();
|
this.show_sidebar();
|
||||||
}}>
|
}}>
|
||||||
<FlowItem parts={parts} info={this.state.info} attention={this.state.attention} img_clickable={false} is_quote={this.props.is_quote}
|
<FlowItem parts={parts} info={this.state.info} attention={this.state.attention} img_clickable={false} is_quote={this.props.is_quote}
|
||||||
color_picker={this.color_picker} show_pid={this.show_pid} replies={this.state.replies} />
|
color_picker={this.color_picker} show_pid={show_pid} replies={this.state.replies} />
|
||||||
<div className="flow-reply-row">
|
<div className="flow-reply-row">
|
||||||
{this.state.reply_status==='loading' && <div className="box box-tip">加载中</div>}
|
{this.state.reply_status==='loading' && <div className="box box-tip">加载中</div>}
|
||||||
{this.state.reply_status==='failed' &&
|
{this.state.reply_status==='failed' &&
|
||||||
<div className="box box-tip"><a onClick={()=>{this.load_replies()}}>重新加载</a></div>
|
<div className="box box-tip"><a onClick={()=>{this.load_replies()}}>重新加载</a></div>
|
||||||
}
|
}
|
||||||
{this.state.replies.slice(0,PREVIEW_REPLY_COUNT).map((reply)=>(
|
{this.state.replies.slice(0,PREVIEW_REPLY_COUNT).map((reply)=>(
|
||||||
<Reply key={reply.cid} info={reply} color_picker={this.color_picker} show_pid={this.show_pid} />
|
<Reply key={reply.cid} info={reply} color_picker={this.color_picker} show_pid={show_pid} />
|
||||||
))}
|
))}
|
||||||
{this.state.replies.length>PREVIEW_REPLY_COUNT &&
|
{this.state.replies.length>PREVIEW_REPLY_COUNT &&
|
||||||
<div className="box box-tip">还有 {this.state.replies.length-PREVIEW_REPLY_COUNT} 条</div>
|
<div className="box box-tip">还有 {this.state.replies.length-PREVIEW_REPLY_COUNT} 条</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function Sidebar(props) {
|
|||||||
<div className="sidebar-shadow" onClick={props.do_close} />
|
<div className="sidebar-shadow" onClick={props.do_close} />
|
||||||
<div className="sidebar">
|
<div className="sidebar">
|
||||||
<p className="sidebar-title">
|
<p className="sidebar-title">
|
||||||
<a onClick={props.do_close}> × </a>
|
<a onClick={props.do_close}> <span className="icon icon-back" /> </a>
|
||||||
{props.title}
|
{props.title}
|
||||||
</p>
|
</p>
|
||||||
{props.content}
|
{props.content}
|
||||||
|
|||||||
Reference in New Issue
Block a user