点击tag搜索,插图依靠图片外链

This commit is contained in:
2020-09-07 11:23:29 +08:00
parent b539919550
commit 05aad972d6
6 changed files with 95 additions and 13 deletions

View File

@@ -35,6 +35,24 @@ class ControlBar extends PureComponent {
},
);
}
window.addEventListener("hashchange",
() => {
let text = decodeURIComponent(window.location.hash).substr(1);
if(text && text[0]!='#') {
console.log('search', text);
this.setState(
{
search_text: text,
},
() => {
this.on_keypress({ key: 'Enter' });
},
);
}
},
false
);
}
on_change(event) {
@@ -116,9 +134,8 @@ class ControlBar extends PureComponent {
<input
className="control-search"
value={this.state.search_text}
placeholder={`${
this.props.mode === 'attention' ? '在关注列表中' : ''
}搜索 或 #树洞号`}
placeholder={
this.props.mode === 'attention' ? '在关注列表中搜索' : '搜tag或 #树洞号, 如: 新手导引'}
onChange={this.on_change_bound}
onKeyPress={this.on_keypress_bound}
/>