diff --git a/src/Common.js b/src/Common.js index ddd0a38..a282400 100644 --- a/src/Common.js +++ b/src/Common.js @@ -9,6 +9,8 @@ import './Common.css'; const chinese_format=buildFormatter(chineseStrings); +export const API_BASE=window.location.protocol==='https:' ? '/api_proxy' : 'http://www.pkuhelper.com/services/pkuhole'; + const PID_RE=/(^|[^\d])([1-9]\d{4,5})(?!\d)/g; const NICKNAME_RE=/(^|[^A-Za-z])((?:(?:Angry|Baby|Crazy|Diligent|Excited|Fat|Greedy|Hungry|Interesting|Japanese|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|洞主)(?![A-Za-z])/gi; @@ -54,3 +56,42 @@ export class HighlightedText extends PureComponent { ) } } + +window.TEXTAREA_BACKUP={}; + +export class SafeTextarea extends Component { + constructor(props) { + super(props); + this.state={ + text: window.TEXTAREA_BACKUP[props.id]||'', + }; + this.on_change_bound=this.on_change.bind(this); + this.clear=this.clear.bind(this); + this.area_ref=React.createRef(); + this.change_callback=props.on_change; + } + + componentWillUnmount() { + window.TEXTAREA_BACKUP[this.props.id]=this.state.text; + this.change_callback(this.state.text); + } + + on_change(event) { + this.setState({ + text: event.target.value, + }); + this.change_callback(event.target.value); + } + + clear() { + this.setState({ + text: '', + }); + } + + render() { + return ( + + ) + } +} \ No newline at end of file diff --git a/src/Flows.css b/src/Flows.css index 5c59a70..0222f48 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -97,11 +97,13 @@ .flow-item-row p.img { text-align: center; } -p.img img { +.flow-item-row p.img img { max-width: 100%; - max-height: 100vh; box-shadow: 0 1px 5px rgba(0,0,0,.4); } +.left-container .flow-item-row p.img img { + max-height: 80vh; +} .box-header-badge { float: right; diff --git a/src/Flows.js b/src/Flows.js index b023a20..def2c0b 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -1,14 +1,14 @@ import React, {Component, PureComponent} from 'react'; import {ColorPicker} from './color_picker'; -import {Time, TitleLine, HighlightedText} from './Common.js'; +import {Time, TitleLine, HighlightedText} from './Common'; import './Flows.css'; import LazyLoad from 'react-lazyload'; -import {AudioWidget} from './AudioWidget.js'; -import {TokenCtx} from './UserAction'; +import {AudioWidget} from './AudioWidget'; +import {TokenCtx, ReplyForm} from './UserAction'; +import {API_BASE} from './Common'; const IMAGE_BASE='http://www.pkuhelper.com/services/pkuhole/images/'; const AUDIO_BASE='/audio_proxy/'; -const API_BASE=window.location.protocol==='https:' ? '/api_proxy' : 'http://www.pkuhelper.com/services/pkuhole'; const SEARCH_PAGESIZE=50; const CLICKABLE_TAGS={a: true, audio: true}; @@ -145,15 +145,17 @@ class FlowItemRow extends PureComponent { }); } + reload_sidebar() { + this.props.show_sidebar('帖子详情',
加载中……
); + this.load_replies(this.show_sidebar.bind(this)); + } + show_sidebar() { this.props.show_sidebar( '帖子详情',加载中……
); - this.load_replies(this.show_sidebar.bind(this)); - }}>刷新回复 + 刷新回复 {this.props.token && / @@ -175,6 +177,9 @@ class FlowItemRow extends PureComponent {localStorage['REPLACE_ERIRI_WITH_URL']