forked from newthuhole/hole_thu_frontend
支持更新折叠警告
This commit is contained in:
@@ -263,6 +263,26 @@
|
|||||||
padding: 0 .25em;
|
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 {
|
.box-header-name {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #3338;
|
background-color: #3338;
|
||||||
|
|||||||
42
src/Flows.js
42
src/Flows.js
@@ -157,6 +157,7 @@ class Reply extends PureComponent {
|
|||||||
class FlowItem extends PureComponent {
|
class FlowItem extends PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.input_cw_ref=React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_link(event) {
|
copy_link(event) {
|
||||||
@@ -182,7 +183,7 @@ class FlowItem extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
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 (
|
return (
|
||||||
<div className={'flow-item' + (is_quote ? ' flow-item-quote' : '')}>
|
<div className={'flow-item' + (is_quote ? ' flow-item-quote' : '')}>
|
||||||
{!!is_quote && (
|
{!!is_quote && (
|
||||||
@@ -249,9 +250,27 @@ class FlowItem extends PureComponent {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{info.cw !== null && (
|
{info.cw !== null &&
|
||||||
<span className="box-header-cw">{info.cw}</span>
|
(!do_edit_cw || !info.can_del) && (
|
||||||
|
<span className="box-header-cw">{info.cw}</span>
|
||||||
)}
|
)}
|
||||||
|
{
|
||||||
|
!!do_edit_cw && !!info.can_del && (
|
||||||
|
<div className="box-header-cw-edit clickable">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
defaultValue={info.cw}
|
||||||
|
maxLength="32"
|
||||||
|
ref={this.input_cw_ref}
|
||||||
|
placeholder="编辑折叠警告"
|
||||||
|
/>
|
||||||
|
<button type="button"
|
||||||
|
onClick={(e)=>do_edit_cw(this.input_cw_ref.current.value, info.pid)}>
|
||||||
|
更新
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
<Time stamp={info.timestamp} short={!img_clickable} />
|
<Time stamp={info.timestamp} short={!img_clickable} />
|
||||||
</div>
|
</div>
|
||||||
<div className="box-content">
|
<div className="box-content">
|
||||||
@@ -493,6 +512,22 @@ class FlowSidebar extends PureComponent {
|
|||||||
return do_delete;
|
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() {
|
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>;
|
||||||
@@ -537,6 +572,7 @@ class FlowSidebar extends PureComponent {
|
|||||||
replies_cnt[DZ_NAME] > 1 ? this.set_filter_name.bind(this) : null
|
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_delete={this.make_do_delete(this.props.token, ()=>{window.location.reload();})}
|
||||||
|
do_edit_cw={this.make_do_edit_cw(this.props.token)}
|
||||||
/>
|
/>
|
||||||
</ClickHandler>
|
</ClickHandler>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -116,6 +116,23 @@ export const API = {
|
|||||||
return handle_response(response, true);
|
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) => {
|
get_list: async (page, token) => {
|
||||||
let response = await fetch(
|
let response = await fetch(
|
||||||
API_BASE + '/getlist'
|
API_BASE + '/getlist'
|
||||||
|
|||||||
Reference in New Issue
Block a user