Skip to content

Commit ba14b10

Browse files
committed
feat: add at when reply
1 parent 4e4117a commit ba14b10

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
</head>
1111
<body>
1212
<div id="root"></div>
13-
<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_610414_a2rijzwk05yaatt9.css">
13+
<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_610414_otpdqoj9jhrozuxr.css">
1414
</body>
1515
</html>

src/components/TopicDetail/index.jsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class TopicDetail extends Component {
8787
id
8888
})
8989
}
90+
reply(name) {
91+
const at = `@${name} `
92+
this.refs.textarea.value = at
93+
this.refs.textarea.focus()
94+
this.setState({
95+
reply: at
96+
})
97+
}
9098
handleInput(e) {
9199
this.setState({
92100
reply: e.target.value.trim()
@@ -140,9 +148,15 @@ class TopicDetail extends Component {
140148
<span className="time_stamp">{format(item.create_at)}</span>
141149
<span className="floor">{index + 1}</span>
142150
</div>
143-
<div className={'user_action ' + (item.is_uped ? 'liked' : '')} onClick={this.like.bind(this, item.id, item.author.loginname)}>
144-
<span className="iconfont icon-thumbup"></span>
145-
<span className="up_number">{item.ups.length}</span>
151+
{/*赞*/}
152+
<div className="user_action">
153+
<div className={'action_item' + (item.is_uped ? 'liked' : '')} onClick={this.like.bind(this, item.id, item.author.loginname)}>
154+
<span className="iconfont icon-thumbup"></span>
155+
<span className="up_number">{item.ups.length}</span>
156+
</div>
157+
<div className="action_item" onClick={this.reply.bind(this, item.author.loginname)}>
158+
<span className="iconfont icon-reply"></span>
159+
</div>
146160
</div>
147161
</div>
148162
<div className="comment_content" dangerouslySetInnerHTML={{__html: item.content}} />
@@ -168,7 +182,7 @@ class TopicDetail extends Component {
168182
<div className="topic_reply">
169183
<p>添加评论</p>
170184
<div className="form">
171-
<textarea onChange={this.handleInput.bind(this)}></textarea>
185+
<textarea ref="textarea" onChange={this.handleInput.bind(this)}></textarea>
172186
<div className="button button_info" onClick={this.submit.bind(this)}>提交</div>
173187
</div>
174188
</div>

src/components/TopicDetail/topicDetail.less

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@
6060
}
6161
.user_action {
6262
display: flex;
63-
&.liked {
63+
span {
64+
height: 14px;
65+
line-height: 14px;
66+
color: #999;
67+
font-size: 14px;
68+
}
69+
.action_item {
70+
margin-left: 5px;
71+
}
72+
.liked {
6473
.icon-thumbup,
6574
.up_number {
6675
color: #6cf;
@@ -100,13 +109,6 @@
100109
font-size: 10px;
101110
color: #999;
102111
}
103-
.icon-thumbup,
104-
.up_number {
105-
height: 14px;
106-
line-height: 14px;
107-
color: #999;
108-
font-size: 14px;
109-
}
110112
.up_number {
111113
margin-left: 3px;
112114
}

0 commit comments

Comments
 (0)