forked from newthuhole/hole_thu_frontend
优化导出方式
This commit is contained in:
@@ -312,3 +312,10 @@
|
|||||||
padding: 0 .5em;
|
padding: 0 .5em;
|
||||||
opacity: .4;
|
opacity: .4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.export-textarea {
|
||||||
|
resize: none;
|
||||||
|
width: 100%;
|
||||||
|
height: 50vh;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|||||||
39
src/Flows.js
39
src/Flows.js
@@ -1112,6 +1112,7 @@ export class Flow extends PureComponent {
|
|||||||
title: '',
|
title: '',
|
||||||
data: [],
|
data: [],
|
||||||
},
|
},
|
||||||
|
can_export: false,
|
||||||
export_text: '',
|
export_text: '',
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
error_msg: null,
|
error_msg: null,
|
||||||
@@ -1257,7 +1258,7 @@ export class Flow extends PureComponent {
|
|||||||
},
|
},
|
||||||
mode: 'attention_finished',
|
mode: 'attention_finished',
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
export_text: json.data.map(post => `#${post.pid}`).join('\n'),
|
can_export: !use_search,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(failed);
|
.catch(failed);
|
||||||
@@ -1293,18 +1294,40 @@ export class Flow extends PureComponent {
|
|||||||
window.removeEventListener('resize', this.on_scroll_bound);
|
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() {
|
render() {
|
||||||
const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on';
|
const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on';
|
||||||
return (
|
return (
|
||||||
<div className="flow-container">
|
<div className="flow-container">
|
||||||
{this.state.export_text && (
|
{this.state.can_export && (
|
||||||
<button type="button" onClick={() => {
|
<button type="button" onClick={this.gen_export.bind(this)}>导出</button>
|
||||||
if (copy(this.state.export_text))
|
|
||||||
alert('导出成功,已复制到剪切板');
|
|
||||||
}}>
|
|
||||||
导出
|
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{this.state.export_text && (
|
||||||
|
<div className="box">
|
||||||
|
<textarea
|
||||||
|
className="export-textarea"
|
||||||
|
value={this.state.export_text}
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<FlowChunk
|
<FlowChunk
|
||||||
title={this.state.chunks.title}
|
title={this.state.chunks.title}
|
||||||
list={this.state.chunks.data}
|
list={this.state.chunks.data}
|
||||||
|
|||||||
@@ -2715,9 +2715,9 @@ caniuse-api@^3.0.0:
|
|||||||
lodash.uniq "^4.5.0"
|
lodash.uniq "^4.5.0"
|
||||||
|
|
||||||
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001111:
|
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001111:
|
||||||
version "1.0.30001122"
|
version "1.0.30001286"
|
||||||
resolved "https://registry.npm.taobao.org/caniuse-lite/download/caniuse-lite-1.0.30001122.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcaniuse-lite%2Fdownload%2Fcaniuse-lite-1.0.30001122.tgz#2c8ff631330d986a07a7ba7125cce77a1373b475"
|
resolved "https://registry.npmmirror.com/caniuse-lite/download/caniuse-lite-1.0.30001286.tgz"
|
||||||
integrity sha1-LI/2MTMNmGoHp7pxJcznehNztHU=
|
integrity sha512-zaEMRH6xg8ESMi2eQ3R4eZ5qw/hJiVsO/HlLwniIwErij0JDr9P+8V4dtx1l+kLq6j3yy8l8W4fst1lBnat5wQ==
|
||||||
|
|
||||||
capture-exit@^2.0.0:
|
capture-exit@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user