diff --git a/src/Flows.js b/src/Flows.js index 4e333ea..9dcd368 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -156,7 +156,10 @@ class Reply extends PureComponent { class FlowItem extends PureComponent { constructor(props) { super(props); - this.input_cw_ref=React.createRef(); + this.state = { + hot_score: props.info.hot_score || 0, + cw: props.info.cw || '', + } } copy_link(event) { @@ -181,8 +184,24 @@ class FlowItem extends PureComponent { ); } + on_hot_score_change(event) { + this.setState({ + hot_score: event.target.value + }); + } + + on_cw_change(event) { + this.setState({ + cw: event.target.value, + }); + } + render() { - const {info, is_quote, cached, attention, can_del, do_filter_name, do_delete, do_edit_cw, timestamp, img_clickable, color_picker, show_pid} = this.props; + const { + info, is_quote, cached, attention, can_del, do_filter_name, do_delete, + do_edit_cw, do_edit_score, timestamp, img_clickable, color_picker, show_pid + } = this.props; + const { cw, hot_score } = this.state; return (
加载中……
; @@ -587,6 +635,7 @@ class FlowSidebar extends PureComponent { } do_delete={this.make_do_delete(this.props.token, ()=>{window.location.reload();})} do_edit_cw={this.make_do_edit_cw(this.props.token)} + do_edit_score={this.make_do_edit_score(this.props.token)} /> ); @@ -1124,7 +1173,7 @@ export class Flow extends PureComponent { get_submode_names(mode) { switch(mode) { case('list'): - return ['最新', '最近回复', '近期热门']; + return ['最新', '最近回复', '近期热门', '随机']; case('attention'): return ['线上', '本地'] } @@ -1132,10 +1181,6 @@ export class Flow extends PureComponent { } set_submode(submode) { - if (this.props.mode === 'list' && submode === 2) { - alert('将在下个版本提供'); - return; - } this.setState({ submode: submode, subflow_render_key: +new Date(), diff --git a/src/flows_api.js b/src/flows_api.js index c323662..a68ba25 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -136,11 +136,29 @@ export const API = { return handle_response(response, true); }, + update_score: async (score, id, token) => { + let data = new URLSearchParams(); + data.append('score', score); + data.append('pid', id); + let response = await fetch( + API_BASE + '/update_score', + { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'User-Token': token, + }, + body: data, + }, + ); + return handle_response(response, true); + }, + get_list: async (page, token, submode) => { let response = await fetch( - API_BASE + '/getlist?p=' + page - + (window.config.no_c_post ? '&no_cw' : '') - + (submode ? '&by_c' : ''), + `${API_BASE}/getlist?p=${page}${ + window.config.no_c_post ? '&no_cw' : '' + }&order_mode=${submode}`, { headers: {'User-Token': token}, }, diff --git a/src/infrastructure/functions.js b/src/infrastructure/functions.js index d27743e..20e26a2 100644 --- a/src/infrastructure/functions.js +++ b/src/infrastructure/functions.js @@ -1,5 +1,8 @@ export function get_json(res) { - if(!res.ok) throw Error(`${res.status} ${res.statusText}`); + if(!res.ok) { + console.log('error:', res); + throw Error(`${res.status} ${res.statusText}`); + } return ( res .text()