-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
197 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
.comment { | ||
width: 420px; | ||
position: relative; | ||
margin-bottom: 80px; | ||
} | ||
|
||
.comment-item { | ||
box-sizing: border-box; | ||
padding: 10px; | ||
display: flex; | ||
} | ||
|
||
.comment-block{ | ||
flex: 1; | ||
} | ||
|
||
.comment-item .avatar{ | ||
margin: 0; | ||
display: block; | ||
padding: 5px 10px; | ||
} | ||
|
||
.comment-item p{ | ||
padding: 5px; | ||
} | ||
|
||
.comment-item p:nth-child(1){ | ||
color: #ddd; | ||
} | ||
|
||
.comment-item p:nth-child(3){ | ||
color: #888; | ||
font-size: 12px; | ||
} | ||
|
||
.comment h1 { | ||
font-weight: normal; | ||
font-size: 12px!important; | ||
color: #ddd!important; | ||
padding: 10px; | ||
} | ||
|
||
.comment-item li { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.comment-input { | ||
display: flex; | ||
align-items: center; | ||
padding: 20px; | ||
position: fixed; | ||
z-index: 99999; | ||
bottom: 0; | ||
width: 400px; | ||
background: #111; | ||
box-sizing: border-box; | ||
} | ||
|
||
.comment-input input { | ||
background: var(--primary-bg); | ||
color: #fff; | ||
height: 30px; | ||
border: 0px; | ||
border-radius: 30px; | ||
padding: 0 10px; | ||
flex: 1; | ||
} | ||
|
||
.comment-input button { | ||
position: absolute; | ||
right: 20px; | ||
height: 30px; | ||
padding: 0 10px; | ||
} | ||
|
||
.rate ul { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.comment-item ul { | ||
display: flex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useEffect, useState, Fragment } from 'fre' | ||
import Avatar from '../component/avatar/avatar' | ||
import { push } from '../use-route' | ||
import { addDanmaku, getDanmakus, getUser } from '../util/api' | ||
import './comment.css' | ||
|
||
export default function Danmaku({ post,p }) { | ||
const [comment, setDanmaku] = useState('') | ||
const [comments, setDanmakus] = useState([]) | ||
useEffect(() => { | ||
|
||
getDanmakus(post.id, 0).then(res => { | ||
setDanmakus((res as any).comments || []) | ||
}) | ||
|
||
}, []) | ||
|
||
function submit() { | ||
if (comment.length < 1) { | ||
return | ||
} | ||
addDanmaku({ | ||
pid: post.id, | ||
p: 0, | ||
pos:0, | ||
color:'#fffff', | ||
content: comment, | ||
} as any).then((res: any) => { | ||
alert(res.msg) | ||
}) | ||
|
||
} | ||
const user = getUser() || {} | ||
return <div> | ||
<div class="comment"> | ||
<div className="comment-input"> | ||
<Avatar uqq={user.qq} uname={user.name} noname={true}></Avatar> | ||
<input type="text" placeholder="Duang~" onInput={(e) => setDanmaku(e.target.value)} /> | ||
{user.id ? <button onClick={submit}>发送</button> : <button onclick={() => push('/login')}>登录</button>} | ||
</div> | ||
|
||
<h1>共有{comments ? comments.length : 0}条讨论</h1> | ||
|
||
|
||
{comments && comments.map(item => { | ||
//@ts-ignore | ||
const time = dayjs(item.time).format('MM-DD-YYYY') | ||
return <div className="comment-item"> | ||
<div className="comment-block"> | ||
<p><a href={`https://www.clicli.cc/comment/delete/${item.id}?token=${window.localStorage.getItem('token')}`} target="_blank"><del>#{item.id}</del></a></p> | ||
<p>{item.content}</p> | ||
<p>{time}</p> | ||
</div> | ||
|
||
</div> | ||
})} | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters