From f5f1136a1f4610d5a81f62a9f8b3ffe2834568c6 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Thu, 16 Dec 2021 00:01:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Flows.css | 7 +++++++ src/Flows.js | 37 ++++++++++++++++++++++++++++++------- yarn.lock | 6 +++--- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/Flows.css b/src/Flows.css index 5ba4cc9..b6500df 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -312,3 +312,10 @@ padding: 0 .5em; opacity: .4; } + +.export-textarea { + resize: none; + width: 100%; + height: 50vh; + padding: 12px; +} diff --git a/src/Flows.js b/src/Flows.js index ab6b395..b1f981d 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -1112,6 +1112,7 @@ export class Flow extends PureComponent { title: '', data: [], }, + can_export: false, export_text: '', loading_status: 'done', error_msg: null, @@ -1257,7 +1258,7 @@ export class Flow extends PureComponent { }, mode: 'attention_finished', loading_status: 'done', - export_text: json.data.map(post => `#${post.pid}`).join('\n'), + can_export: !use_search, }); }) .catch(failed); @@ -1293,18 +1294,40 @@ export class Flow extends PureComponent { window.removeEventListener('resize', this.on_scroll_bound); } + trunc_string(s, max_len) { + return s.substr(0, max_len) + ( + s.length > max_len ? '...' : '' + ) + } + + gen_export() { + this.setState({ + can_export: false, + export_text: "以下是你关注的洞及摘要,复制保存到本地吧。\n\n" + this.state.chunks.data.map( + p => `#${p.pid}: ${ + this.trunc_string(p.text.replaceAll('\n', ' '), 50) + }`).join('\n\n') + }); + } + render() { const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on'; return (
+ {this.state.can_export && ( + + )} + {this.state.export_text && ( - +
+