diff --git a/public/static/fonts_7/icomoon.css b/public/static/fonts_7/icomoon.css index 49071f0..42842e1 100644 --- a/public/static/fonts_7/icomoon.css +++ b/public/static/fonts_7/icomoon.css @@ -108,3 +108,5 @@ .icon-eye-blocked:before { content: "\e9d1"; } +.icon-trash:before { + content: "\1f5d1"; diff --git a/src/Flows.js b/src/Flows.js index 56980d0..6436b52 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -93,26 +93,27 @@ class Reply extends PureComponent { } render() { - const author = this.props.info.name, - replyText = this.props.info.text; + const {info, color_picker, show_pid, do_filter_name, do_delete} = this.props; + const author = info.name, + replyText = info.text; return (
{'$' + this.props.info.cid}
+ {'$' + info.cid}
- #{props.info.pid}
+ #{info.pid}
+ {!!do_delete && !!info.can_del && (
+ {
+ do_delete('pid', info.pid);
+ }}
+ >
+
+
+ )}
- {props.info.cw !== null && (
- {props.info.cw}
+ {info.cw !== null && (
+ {info.cw}
)}
-
+
- {props.img_clickable ? (
+ {img_clickable ? (
{
- if (e.target.src === IMAGE_BASE + props.info.url) {
- e.target.src = IMAGE_BAK_BASE + props.info.url;
+ if (e.target.src === IMAGE_BASE + info.url) {
+ e.target.src = IMAGE_BAK_BASE + info.url;
}
}}
- alt={IMAGE_BASE + props.info.url}
+ alt={IMAGE_BASE + info.url}
/>
) : (
{
- if (e.target.src === IMAGE_BASE + props.info.url) {
- e.target.src = IMAGE_BAK_BASE + props.info.url;
+ if (e.target.src === IMAGE_BASE + info.url) {
+ e.target.src = IMAGE_BAK_BASE + info.url;
}
}}
- alt={IMAGE_BASE + props.info.url}
+ alt={IMAGE_BASE + info.url}
/>
)}
最新回复{' '} - +
)}加载中……
; @@ -484,6 +524,7 @@ class FlowSidebar extends PureComponent { do_filter_name={ replies_cnt[DZ_NAME] > 1 ? this.set_filter_name.bind(this) : null } + do_delete={this.make_do_delete(this.props.token)} /> ); @@ -598,6 +639,7 @@ class FlowSidebar extends PureComponent { ? this.set_filter_name.bind(this) : null } + do_delete={this.make_do_delete(this.props.token)} /> @@ -1036,7 +1078,7 @@ export class Flow extends PureComponent { if (page > this.state.loaded_pages + 1) throw new Error('bad page'); if (page === this.state.loaded_pages + 1) { - //console.log('fetching page', page); + console.log('fetching page', page); cache(); if (this.state.mode === 'list') { API.get_list(page, this.props.token) @@ -1046,19 +1088,20 @@ export class Flow extends PureComponent { let max_id = -1; json.data.forEach((x) => { if (parseInt(x.pid, 10) > max_id) max_id = parseInt(x.pid, 10); - if (x.comments) { - let comment_json = { - 'code': 0, - 'attention': x.attention, - 'data': x.comments - } - //console.log('My cache', comment_json, x.pid, x.reply) - cache().put(x.pid, parseInt(x.reply, 10), comment_json); - } - }); localStorage['_LATEST_POST_ID'] = '' + max_id; } + json.data.forEach((x) => { + if (x.comments) { + let comment_json = { + 'code': 0, + 'attention': x.attention, + 'data': x.comments + } + //console.log('My cache', comment_json, x.pid, x.reply) + cache().put(x.pid, parseInt(x.reply, 10), comment_json); + } + }); this.setState((prev, props) => ({ chunks: { title: 'News Feed', @@ -1105,10 +1148,10 @@ export class Flow extends PureComponent { let x = json.data; if (x.comments) { let comment_json = { - 'code': 0, - 'attention': x.attention, - 'data': x.comments - } + code: 0, + attention: x.attention, + data: x.comments, + }; //console.log('My cache', comment_json, x.pid, x.reply) cache().put(x.pid, parseInt(x.reply, 10), comment_json); } diff --git a/src/UserAction.js b/src/UserAction.js index 8c035a0..fdcbb75 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -291,7 +291,7 @@ export class ReplyForm extends Component { }) .catch((e) => { console.error(e); - alert('回复失败'); + alert('回复失败\n' + e); this.setState({ loading_status: 'done', }); diff --git a/src/flows_api.js b/src/flows_api.js index 593caf9..4f27dac 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -39,7 +39,7 @@ export const API = { ); let json = await handle_response(response); // Why delete then put ?? - console.log('Put cache', json, pid, cache_version); + //console.log('Put cache', json, pid, cache_version); cache().put(pid, cache_version, json); json.data = parse_replies(json.data, color_picker); return json; @@ -98,6 +98,24 @@ export const API = { return handle_response(response, true); }, + del: async (type, id, note, token) => { + let data = new URLSearchParams(); + data.append('type', type); + data.append('id', id); + data.append('note', note); + let response = await fetch( + API_BASE + '/delete' + 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' + token_param(token) + '&p=' + page, diff --git a/src/infrastructure/functions.js b/src/infrastructure/functions.js index ff2f2f5..d27743e 100644 --- a/src/infrastructure/functions.js +++ b/src/infrastructure/functions.js @@ -1,5 +1,5 @@ export function get_json(res) { - if(!res.ok) throw Error(`错误 ${res.status} ${res.statusText}`); + if(!res.ok) throw Error(`${res.status} ${res.statusText}`); return ( res .text()