diff --git a/src/Flows.css b/src/Flows.css index 0e1bcf2..5ba4cc9 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -263,6 +263,26 @@ padding: 0 .25em; } +.box-header-cw-edit { + display: inline-block; + background-color: #00c; + border-radius: 5px; + padding: 3px; + margin:0 3px; +} + +.box-header-cw-edit input { + font-size: .8em; + width: 8em; + padding: 0 3px; +} + +.box-header-cw-edit button { + font-size: .8em; + margin: 0 3px; + background: white; +} + .box-header-name { color: white; background-color: #3338; diff --git a/src/Flows.js b/src/Flows.js index 2c02775..a3aa721 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -157,6 +157,7 @@ class Reply extends PureComponent { class FlowItem extends PureComponent { constructor(props) { super(props); + this.input_cw_ref=React.createRef(); } copy_link(event) { @@ -182,7 +183,7 @@ class FlowItem extends PureComponent { } render() { - const {info, is_quote, cached, attention, can_del, do_filter_name, do_delete, 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, timestamp, img_clickable, color_picker, show_pid} = this.props; return (
{!!is_quote && ( @@ -249,9 +250,27 @@ class FlowItem extends PureComponent { )}   - {info.cw !== null && ( - {info.cw} + {info.cw !== null && + (!do_edit_cw || !info.can_del) && ( + {info.cw} )} + { + !!do_edit_cw && !!info.can_del && ( +
+ + +
+ ) + }
@@ -493,6 +512,22 @@ class FlowSidebar extends PureComponent { return do_delete; } + make_do_edit_cw(token) { + const do_edit_cw = (cw, id) => { + console.log('edit cw', cw); + API.update_cw(cw, id, token) + .then((json) => { + alert('已更新\n刷新列表显示新版本'); + }) + .catch((e) => { + alert('更新失败\n' + e); + console.error(e); + }); + } + + return do_edit_cw; + } + render() { if (this.state.loading_status === 'loading') return

加载中……

; @@ -537,6 +572,7 @@ class FlowSidebar extends PureComponent { replies_cnt[DZ_NAME] > 1 ? this.set_filter_name.bind(this) : null } do_delete={this.make_do_delete(this.props.token, ()=>{window.location.reload();})} + do_edit_cw={this.make_do_edit_cw(this.props.token)} /> ); diff --git a/src/flows_api.js b/src/flows_api.js index 7b855cd..c8ae492 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -116,6 +116,23 @@ export const API = { return handle_response(response, true); }, + update_cw: async (cw, id, token) => { + let data = new URLSearchParams(); + data.append('cw', cw); + data.append('pid', id); + let response = await fetch( + API_BASE + '/editcw' + token_param(token), + { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: data, + }, + ); + return handle_response(response, true); + }, + get_list: async (page, token) => { let response = await fetch( API_BASE + '/getlist'