Browse Source

feature update

- search query highlight
- id quote
- add some icons
dev
xmcp 6 years ago
parent
commit
854c3a0306
  1. 3
      README.md
  2. 2
      public/index.html
  3. BIN
      public/static/fonts_2/icomoon.ttf
  4. BIN
      public/static/fonts_2/icomoon.woff
  5. 22
      public/static/fonts_5/icomoon.css
  6. 5
      public/static/fonts_5/icomoon.svg
  7. BIN
      public/static/fonts_5/icomoon.ttf
  8. BIN
      public/static/fonts_5/icomoon.woff
  9. 5
      src/Common.css
  10. 18
      src/Common.js
  11. 22
      src/Flows.css
  12. 195
      src/Flows.js

3
README.md

@ -46,4 +46,5 @@ React 版 P大树洞,[pkuhelper.pku.edu.cn/hole](http://pkuhelper.pku.edu.cn/h
- 检测瀑布流中被删除的树洞和树洞被删除的评论(`//setflag DELETION_DETECT=on`)
- 自定义背景图片(`//setflag REPLACE_ERIRI_WITH_URL=http://...`)
- 禁用 3D Touch 功能(`//setflag DISABLE_PRESSURE=on`)
- 禁用 3D Touch 功能(`//setflag DISABLE_PRESSURE=on`)
- 禁用自动显示引用树洞功能(`//setflag DISABLE_QUOTE=on`)

2
public/index.html

@ -6,7 +6,7 @@
<link rel="icon" href="%PUBLIC_URL%/static/favicon/256.png">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="%PUBLIC_URL%/static/fonts_2/icomoon.css" />
<link rel="stylesheet" href="%PUBLIC_URL%/static/fonts_5/icomoon.css" />
<meta name="mobile-web-app-capable" content="yes">
<link rel="shortcut icon" href="%PUBLIC_URL%/static/favicon/256.png">

BIN
public/static/fonts_2/icomoon.ttf

Binary file not shown.

BIN
public/static/fonts_2/icomoon.woff

Binary file not shown.

22
public/static/fonts_2/icomoon.css → public/static/fonts_5/icomoon.css

@ -1,9 +1,9 @@
@font-face {
font-family: 'icomoon';
src:
url('icomoon.ttf?y01gys') format('truetype'),
url('icomoon.woff?y01gys') format('woff'),
url('icomoon.svg?y01gys#icomoon') format('svg');
url('icomoon.ttf?gqzyp6') format('truetype'),
url('icomoon.woff?gqzyp6') format('woff'),
url('icomoon.svg?gqzyp6#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
@ -27,15 +27,28 @@
.icon-send:before {
content: "\e900";
}
.icon-history:before {
content: "\e94d";
}
.icon-reply:before {
content: "\e96b";
}
.icon-quote:before {
content: "\e977";
}
.icon-loading:before {
content: "\e979";
}
.icon-login:before {
content: "\e98d";
}
.icon-stats:before {
content: "\e99b";
}
.icon-upload:before {
content: "\e9c3";
font-size: 1.2em;
}
.icon-attention:before {
content: "\e9d3";
}
@ -54,6 +67,9 @@
.icon-refresh:before {
content: "\ea2e";
}
.icon-back:before {
content: "\ea44";
}
.icon-github:before {
content: "\eab0";
}

5
public/static/fonts_2/icomoon.svg → public/static/fonts_5/icomoon.svg

@ -8,14 +8,19 @@
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
<glyph unicode="&#xe900;" glyph-name="send" horiz-adv-x="1025" d="M1008 944.571c12-8.571 17.714-22.286 15.429-36.571l-146.286-877.714c-1.714-10.857-8.571-20-18.286-25.714-5.143-2.857-11.429-4.571-17.714-4.571-4.571 0-9.143 1.143-13.714 2.857l-258.857 105.714-138.286-168.571c-6.857-8.571-17.143-13.143-28-13.143-4 0-8.571 0.571-12.571 2.286-14.286 5.143-24 18.857-24 34.286v199.429l493.714 605.143-610.857-528.571-225.714 92.571c-13.143 5.143-21.714 17.143-22.857 31.429-0.571 13.714 6.286 26.857 18.286 33.714l950.857 548.571c5.714 3.429 12 5.143 18.286 5.143 7.429 0 14.857-2.286 20.571-6.286z" />
<glyph unicode="&#xe94d;" glyph-name="history" horiz-adv-x="1088" d="M640 896c247.424 0 448-200.576 448-448s-200.576-448-448-448v96c94.024 0 182.418 36.614 248.902 103.098s103.098 154.878 103.098 248.902c0 94.022-36.614 182.418-103.098 248.902s-154.878 103.098-248.902 103.098c-94.022 0-182.418-36.614-248.902-103.098-51.14-51.138-84.582-115.246-97.306-184.902h186.208l-224-256-224 256h164.57c31.060 217.102 217.738 384 443.43 384zM832 512v-128h-256v320h128v-192z" />
<glyph unicode="&#xe96b;" glyph-name="reply" d="M512 896c282.77 0 512-186.25 512-416 0-229.752-229.23-416-512-416-27.156 0-53.81 1.734-79.824 5.044-109.978-109.978-241.25-129.7-368.176-132.596v26.916c68.536 33.578 128 94.74 128 164.636 0 9.754-0.758 19.33-2.164 28.696-115.796 76.264-189.836 192.754-189.836 323.304 0 229.75 229.23 416 512 416z" />
<glyph unicode="&#xe977;" glyph-name="quote" d="M225 512c123.712 0 224-100.29 224-224 0-123.712-100.288-224-224-224s-224 100.288-224 224l-1 32c0 247.424 200.576 448 448 448v-128c-85.474 0-165.834-33.286-226.274-93.726-11.634-11.636-22.252-24.016-31.83-37.020 11.438 1.8 23.16 2.746 35.104 2.746zM801 512c123.71 0 224-100.29 224-224 0-123.712-100.29-224-224-224s-224 100.288-224 224l-1 32c0 247.424 200.576 448 448 448v-128c-85.474 0-165.834-33.286-226.274-93.726-11.636-11.636-22.254-24.016-31.832-37.020 11.44 1.8 23.16 2.746 35.106 2.746z" />
<glyph unicode="&#xe979;" glyph-name="loading" d="M728.992 448c137.754 87.334 231.008 255.208 231.008 448 0 21.676-1.192 43.034-3.478 64h-889.042c-2.29-20.968-3.48-42.326-3.48-64 0-192.792 93.254-360.666 231.006-448-137.752-87.334-231.006-255.208-231.006-448 0-21.676 1.19-43.034 3.478-64h889.042c2.288 20.966 3.478 42.324 3.478 64 0.002 192.792-93.252 360.666-231.006 448zM160 0c0 186.912 80.162 345.414 224 397.708v100.586c-143.838 52.29-224 210.792-224 397.706v0h704c0-186.914-80.162-345.416-224-397.706v-100.586c143.838-52.294 224-210.796 224-397.708h-704zM619.626 290.406c-71.654 40.644-75.608 93.368-75.626 125.366v64.228c0 31.994 3.804 84.914 75.744 125.664 38.504 22.364 71.808 56.348 97.048 98.336h-409.582c25.266-42.032 58.612-76.042 97.166-98.406 71.654-40.644 75.606-93.366 75.626-125.366v-64.228c0-31.992-3.804-84.914-75.744-125.664-72.622-42.18-126.738-125.684-143.090-226.336h501.67c-16.364 100.708-70.53 184.248-143.212 226.406z" />
<glyph unicode="&#xe98d;" glyph-name="login" d="M704 960c-176.73 0-320-143.268-320-320 0-20.026 1.858-39.616 5.376-58.624l-389.376-389.376v-192c0-35.346 28.654-64 64-64h64v64h128v128h128v128h128l83.042 83.042c34.010-12.316 70.696-19.042 108.958-19.042 176.73 0 320 143.268 320 320s-143.27 320-320 320zM799.874 639.874c-53.020 0-96 42.98-96 96s42.98 96 96 96 96-42.98 96-96-42.98-96-96-96z" />
<glyph unicode="&#xe99b;" glyph-name="stats" d="M128 64h896v-128h-1024v1024h128zM288 128c-53.020 0-96 42.98-96 96s42.98 96 96 96c2.828 0 5.622-0.148 8.388-0.386l103.192 171.986c-9.84 15.070-15.58 33.062-15.58 52.402 0 53.020 42.98 96 96 96s96-42.98 96-96c0-19.342-5.74-37.332-15.58-52.402l103.192-171.986c2.766 0.238 5.56 0.386 8.388 0.386 2.136 0 4.248-0.094 6.35-0.23l170.356 298.122c-10.536 15.408-16.706 34.036-16.706 54.11 0 53.020 42.98 96 96 96s96-42.98 96-96c0-53.020-42.98-96-96-96-2.14 0-4.248 0.094-6.35 0.232l-170.356-298.124c10.536-15.406 16.706-34.036 16.706-54.11 0-53.020-42.98-96-96-96s-96 42.98-96 96c0 19.34 5.74 37.332 15.578 52.402l-103.19 171.984c-2.766-0.238-5.56-0.386-8.388-0.386s-5.622 0.146-8.388 0.386l-103.192-171.986c9.84-15.068 15.58-33.060 15.58-52.4 0-53.020-42.98-96-96-96z" />
<glyph unicode="&#xe9c3;" glyph-name="upload" d="M892.268 573.51c2.444 11.11 3.732 22.648 3.732 34.49 0 88.366-71.634 160-160 160-14.222 0-28.014-1.868-41.132-5.352-24.798 77.352-97.29 133.352-182.868 133.352-87.348 0-161.054-58.336-184.326-138.17-22.742 6.622-46.792 10.17-71.674 10.17-141.384 0-256-114.616-256-256 0-141.388 114.616-256 256-256h128v-192h256v192h224c88.366 0 160 71.632 160 160 0 78.72-56.854 144.162-131.732 157.51zM576 320v-192h-128v192h-160l224 224 224-224h-160z" />
<glyph unicode="&#xe9d3;" glyph-name="attention" d="M256 832v-896l320 320 320-320v896zM768 960h-640v-896l64 64v768h576z" />
<glyph unicode="&#xe9d7;" glyph-name="star" d="M1024 562.95l-353.78 51.408-158.22 320.582-158.216-320.582-353.784-51.408 256-249.538-60.432-352.352 316.432 166.358 316.432-166.358-60.434 352.352 256.002 249.538zM512 206.502l-223.462-117.48 42.676 248.83-180.786 176.222 249.84 36.304 111.732 226.396 111.736-226.396 249.836-36.304-180.788-176.222 42.678-248.83-223.462 117.48z" />
<glyph unicode="&#xe9d9;" glyph-name="star-ok" d="M1024 562.95l-353.78 51.408-158.22 320.582-158.216-320.582-353.784-51.408 256-249.538-60.432-352.352 316.432 166.358 316.432-166.358-60.434 352.352 256.002 249.538z" />
<glyph unicode="&#xea0a;" glyph-name="plus" d="M992 576h-352v352c0 17.672-14.328 32-32 32h-192c-17.672 0-32-14.328-32-32v-352h-352c-17.672 0-32-14.328-32-32v-192c0-17.672 14.328-32 32-32h352v-352c0-17.672 14.328-32 32-32h192c17.672 0 32 14.328 32 32v352h352c17.672 0 32 14.328 32 32v192c0 17.672-14.328 32-32 32z" />
<glyph unicode="&#xea0c;" glyph-name="about" d="M448 656c0 26.4 21.6 48 48 48h32c26.4 0 48-21.6 48-48v-32c0-26.4-21.6-48-48-48h-32c-26.4 0-48 21.6-48 48v32zM640 192h-256v64h64v192h-64v64h192v-256h64zM512 960c-282.77 0-512-229.23-512-512s229.23-512 512-512 512 229.23 512 512-229.23 512-512 512zM512 32c-229.75 0-416 186.25-416 416s186.25 416 416 416 416-186.25 416-416-186.25-416-416-416z" />
<glyph unicode="&#xea2e;" glyph-name="refresh" d="M889.68 793.68c-93.608 102.216-228.154 166.32-377.68 166.32-282.77 0-512-229.23-512-512h96c0 229.75 186.25 416 416 416 123.020 0 233.542-53.418 309.696-138.306l-149.696-149.694h352v352l-134.32-134.32zM928 448c0-229.75-186.25-416-416-416-123.020 0-233.542 53.418-309.694 138.306l149.694 149.694h-352v-352l134.32 134.32c93.608-102.216 228.154-166.32 377.68-166.32 282.77 0 512 229.23 512 512h-96z" />
<glyph unicode="&#xea44;" glyph-name="back" d="M512-64c282.77 0 512 229.23 512 512s-229.23 512-512 512-512-229.23-512-512 229.23-512 512-512zM512 864c229.75 0 416-186.25 416-416s-186.25-416-416-416-416 186.25-416 416 186.25 416 416 416zM669.256 642.744l-90.512 90.512-285.254-285.256 285.256-285.254 90.508 90.508-194.744 194.746z" />
<glyph unicode="&#xeab0;" glyph-name="github" d="M512.008 947.358c-282.738 0-512.008-229.218-512.008-511.998 0-226.214 146.704-418.132 350.136-485.836 25.586-4.738 34.992 11.11 34.992 24.632 0 12.204-0.48 52.542-0.696 95.324-142.448-30.976-172.504 60.41-172.504 60.41-23.282 59.176-56.848 74.916-56.848 74.916-46.452 31.778 3.51 31.124 3.51 31.124 51.4-3.61 78.476-52.766 78.476-52.766 45.672-78.27 119.776-55.64 149.004-42.558 4.588 33.086 17.852 55.68 32.506 68.464-113.73 12.942-233.276 56.85-233.276 253.032 0 55.898 20.004 101.574 52.76 137.428-5.316 12.9-22.854 64.972 4.952 135.5 0 0 43.006 13.752 140.84-52.49 40.836 11.348 84.636 17.036 128.154 17.234 43.502-0.198 87.336-5.886 128.256-17.234 97.734 66.244 140.656 52.49 140.656 52.49 27.872-70.528 10.35-122.6 5.036-135.5 32.82-35.856 52.694-81.532 52.694-137.428 0-196.654-119.778-239.95-233.79-252.624 18.364-15.89 34.724-47.046 34.724-94.812 0-68.508-0.596-123.644-0.596-140.508 0-13.628 9.222-29.594 35.172-24.566 203.322 67.776 349.842 259.626 349.842 485.768 0 282.78-229.234 511.998-511.992 511.998z" />
</font></defs></svg>

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

BIN
public/static/fonts_5/icomoon.ttf

Binary file not shown.

BIN
public/static/fonts_5/icomoon.woff

Binary file not shown.

5
src/Common.css

@ -53,4 +53,9 @@
-1px 1px 0 #000,
0 1px 0 #000,
1px 1px 0 #000;
}
.search-query-highlight {
border-bottom: 1px solid black;
font-weight: bold;
}

18
src/Common.js

@ -1,6 +1,5 @@
import React, {Component, PureComponent} from 'react';
import {PKUHELPER_ROOT} from './flows_api';
import {split_text,NICKNAME_RE,PID_RE,URL_RE} from './text_splitter'
import TimeAgo from 'react-timeago';
import chineseStrings from 'react-timeago/lib/language-strings/zh-CN';
@ -16,6 +15,15 @@ function pad2(x) {
return x<10 ? '0'+x : ''+x;
}
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
function escape_regex(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
export function build_highlight_re(txt,split) {
return txt ? new RegExp(`(${txt.split(split).filter((x)=>!!x).map(escape_regex).join('|')})`,'g') : /^$/g;
}
export function format_time(time) {
return `${time.getMonth()+1}-${pad2(time.getDate())} ${time.getHours()}:${pad2(time.getMinutes())}:${pad2(time.getSeconds())}`;
}
@ -41,23 +49,19 @@ export function TitleLine(props) {
export class HighlightedText extends PureComponent {
render() {
let parts=split_text(this.props.text,[
['url',URL_RE],
['pid',PID_RE],
['nickname',NICKNAME_RE],
]);
function normalize_url(url) {
return /^https?:\/\//.test(url) ? url : 'http://'+url;
}
return (
<pre>
{parts.map((part,idx)=>{
{this.props.parts.map((part,idx)=>{
let [rule,p]=part;
return (
<span key={idx}>{
rule==='url' ? <a href={normalize_url(p)} target="_blank" rel="noopener">{p}</a> :
rule==='pid' ? <a href={'##'+p} onClick={(e)=>{e.preventDefault(); this.props.show_pid(p);}}>{p}</a> :
rule==='nickname' ? <span style={{backgroundColor: this.props.color_picker.get(p)}}>{p}</span> :
rule==='search' ? <span className="search-query-highlight">{p}</span> :
p
}</span>
);

22
src/Flows.css

@ -169,4 +169,26 @@
color: white;
background-color: rgba(0,0,0,.6);
pointer-events: none;
}
.flow-item-row-quote {
opacity: .8;
filter: brightness(90%);
}
.flow-item-quote>.box {
margin-left: 2.5em;
max-height: 15em;
overflow-y: hidden;
}
.quote-tip {
margin-top: .5em;
margin-bottom: -10em; /* so that it will not block reply bar */
float: left;
display: flex;
flex-direction: column;
width: 2.5em;
text-align: center;
color: white;
}

195
src/Flows.js

@ -1,7 +1,8 @@
import React, {Component, PureComponent} from 'react';
import copy from 'copy-to-clipboard';
import {ColorPicker} from './color_picker';
import {format_time, Time, TitleLine, HighlightedText, ClickHandler} from './Common';
import {split_text,NICKNAME_RE,PID_RE,URL_RE} from './text_splitter';
import {format_time, build_highlight_re, Time, TitleLine, HighlightedText, ClickHandler} from './Common';
import './Flows.css';
import LazyLoad from 'react-lazyload';
import {AudioWidget} from './AudioWidget';
@ -62,6 +63,11 @@ class Reply extends PureComponent {
}
render() {
let parts=split_text(this.props.info.text,[
['url',URL_RE],
['pid',PID_RE],
['nickname',NICKNAME_RE],
]);
return (
<div className={'flow-reply box'} style={this.props.info._display_color ? {
backgroundColor: this.props.info._display_color,
@ -71,7 +77,7 @@ class Reply extends PureComponent {
<Time stamp={this.props.info.timestamp} />
</div>
<div className="box-content">
<HighlightedText text={this.props.info.text} color_picker={this.props.color_picker} show_pid={this.props.show_pid} />
<HighlightedText parts={parts} color_picker={this.props.color_picker} show_pid={this.props.show_pid} />
</div>
</div>
);
@ -95,41 +101,54 @@ class FlowItem extends PureComponent {
render() {
let props=this.props;
let parts=props.parts||split_text(props.info.text,[
['url',URL_RE],
['pid',PID_RE],
['nickname',NICKNAME_RE],
]);
return (
<div className="flow-item box">
{parseInt(props.info.pid,10)>window.LATEST_POST_ID && <div className="flow-item-dot" /> }
<div className="box-header">
{!!parseInt(props.info.likenum,10) &&
<span className="box-header-badge">
{props.info.likenum}&nbsp;
<span className={'icon icon-'+(props.attention ? 'star-ok' : 'star')} />
</span>
}
{!!parseInt(props.info.reply,10) &&
<span className="box-header-badge">
{props.info.reply}&nbsp;
<span className="icon icon-reply" />
</span>
}
<code className="box-id"><a href={'##'+props.info.pid} onClick={this.copy_link.bind(this)}>#{props.info.pid}</a></code>
&nbsp;
<Time stamp={props.info.timestamp} />
</div>
<div className="box-content">
<HighlightedText text={props.info.text} color_picker={props.color_picker} show_pid={props.show_pid} />
{props.info.type==='image' &&
<p className="img">
{props.img_clickable ?
<a href={IMAGE_BASE+props.info.url} target="_blank"><img src={IMAGE_BASE+props.info.url} /></a> :
<img src={IMAGE_BASE+props.info.url} />
}
</p>
<div className={'flow-item'+(props.is_quote ? ' flow-item-quote' : '')}>
{!!props.is_quote &&
<div className="quote-tip black-outline">
<div><span className="icon icon-quote" /></div>
<div><small>提到</small></div>
</div>
}
<div className="box">
{parseInt(props.info.pid,10)>window.LATEST_POST_ID && <div className="flow-item-dot" /> }
<div className="box-header">
{!!parseInt(props.info.likenum,10) &&
<span className="box-header-badge">
{props.info.likenum}&nbsp;
<span className={'icon icon-'+(props.attention ? 'star-ok' : 'star')} />
</span>
}
{!!parseInt(props.info.reply,10) &&
<span className="box-header-badge">
{props.info.reply}&nbsp;
<span className="icon icon-reply" />
</span>
}
<code className="box-id"><a href={'##'+props.info.pid} onClick={this.copy_link.bind(this)}>#{props.info.pid}</a></code>
&nbsp;
<Time stamp={props.info.timestamp} />
</div>
<div className="box-content">
<HighlightedText parts={parts} color_picker={props.color_picker} show_pid={props.show_pid} />
{props.info.type==='image' &&
<p className="img">
{props.img_clickable ?
<a href={IMAGE_BASE+props.info.url} target="_blank"><img src={IMAGE_BASE+props.info.url} /></a> :
<img src={IMAGE_BASE+props.info.url} />
}
</p>
}
{props.info.type==='audio' && <AudioWidget src={AUDIO_BASE+props.info.url} />}
</div>
{!!(props.attention && props.info.variant.latest_reply) &&
<p className="box-footer">最新回复 <Time stamp={props.info.variant.latest_reply} /></p>
}
{props.info.type==='audio' && <AudioWidget src={AUDIO_BASE+props.info.url} />}
</div>
{!!(props.attention && props.info.variant.latest_reply) &&
<p className="box-footer">最新回复 <Time stamp={props.info.variant.latest_reply} /></p>
}
</div>
);
}
@ -331,10 +350,9 @@ class FlowItemRow extends PureComponent {
this.state={
replies: [],
reply_status: 'done',
info: props.info,
info: Object.assign({},props.info,{variant: {}}),
attention: false,
};
this.state.info.variant={};
this.color_picker=new ColorPicker();
this.show_pid=load_single_meta(this.props.show_sidebar,this.props.token);
}
@ -385,12 +403,32 @@ class FlowItemRow extends PureComponent {
}
render() {
return (
<div className="flow-item-row" onClick={(event)=>{
let hl_rules=[
['url',URL_RE],
['pid',PID_RE],
['nickname',NICKNAME_RE],
];
if(this.props.search_param)
hl_rules.push(['search',build_highlight_re(this.props.search_param,' ')]);
let parts=split_text(this.state.info.text,hl_rules);
let quote_id=null;
if(!this.props.is_quote && localStorage['DISABLE_QUOTE']!=='on')
for(let [mode,content] of parts)
if(mode==='pid')
if(quote_id===null)
quote_id=parseInt(content);
else {
quote_id=null;
break;
}
let res=(
<div className={'flow-item-row'+(this.props.is_quote ? ' flow-item-row-quote' : '')} onClick={(event)=>{
if(!CLICKABLE_TAGS[event.target.tagName.toLowerCase()])
this.show_sidebar();
}}>
<FlowItem info={this.state.info} attention={this.state.attention} img_clickable={false}
<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} />
<div className="flow-reply-row">
{this.state.reply_status==='loading' && <div className="box box-tip">加载中</div>}
@ -406,6 +444,78 @@ class FlowItemRow extends PureComponent {
</div>
</div>
);
return quote_id ? (
<div>
{res}
<FlowItemQuote pid={quote_id} show_sidebar={this.props.show_sidebar} token={this.props.token}
deletion_detect={this.props.deletion_detect} />
</div>
) : res;
}
}
class FlowItemQuote extends PureComponent {
constructor(props) {
super(props);
this.state={
loading_status: 'empty',
error_msg: null,
info: null,
};
}
componentDidMount() {
this.load();
}
load() {
this.setState({
loading_status: 'loading',
},()=>{
API.get_single(this.props.pid,this.props.token)
.then((json)=>{
this.setState({
loading_status: 'done',
info: json.data,
});
})
.catch((err)=>{
if((''+err).indexOf('没有这条树洞')!==-1)
this.setState({
loading_status: 'empty',
});
else
this.setState({
loading_status: 'error',
error_msg: ''+err,
});
});
});
}
render() {
if(this.state.loading_status==='empty')
return null;
else if(this.state.loading_status==='loading')
return (
<div className="box box-tip aux-margin">
<span className="icon icon-loading" />
提到了 #{this.props.pid}
</div>
);
else if(this.state.loading_status==='error')
return (
<div className="box box-tip aux-margin">
<p><a onClick={this.load.bind(this)}>重新加载</a></p>
<p>{this.state.error_msg}</p>
</div>
);
else // 'done'
return (
<FlowItemRow info={this.state.info} show_sidebar={this.props.show_sidebar} token={this.props.token}
is_quote={true} deletion_detect={this.props.deletion_detect} />
);
}
}
@ -425,7 +535,7 @@ function FlowChunk(props) {
</div>
}
<FlowItemRow info={info} show_sidebar={props.show_sidebar} token={token}
deletion_detect={props.deletion_detect} />
deletion_detect={props.deletion_detect} search_param={props.search_param} />
</div>
</LazyLoad>
))}
@ -562,8 +672,9 @@ export class Flow extends PureComponent {
return (
<div className="flow-container">
<FlowChunk
title={this.state.chunks.title} list={this.state.chunks.data}
show_sidebar={this.props.show_sidebar} mode={this.state.mode} deletion_detect={should_deletion_detect}
title={this.state.chunks.title} list={this.state.chunks.data} mode={this.state.mode}
search_param={this.state.search_param||null}
show_sidebar={this.props.show_sidebar} deletion_detect={should_deletion_detect}
/>
{this.state.loading_status==='failed' &&
<div className="box box-tip aux-margin">

Loading…
Cancel
Save