Skip to content

Commit

Permalink
日常提交
Browse files Browse the repository at this point in the history
  • Loading branch information
yisar committed May 12, 2024
1 parent b85de81 commit 1340df0
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions fre/src/danmaku/danmaku.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,52 @@ 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'
import './danmaku.css'

export default function Danmaku({ post,p }) {
const [comment, setDanmaku] = useState('')
const [comments, setDanmakus] = useState([])
const [danmaku, setDanmaku] = useState('')
const [danmakus, setDanmakus] = useState([])
useEffect(() => {

getDanmakus(post.id, 0).then(res => {
setDanmakus((res as any).comments || [])
setDanmakus((res as any).danmakus || [])
})

}, [])

function submit() {
if (comment.length < 1) {
if (danmaku.length < 1) {
return
}
addDanmaku({
pid: post.id,
p: 0,
pos:0,
color:'#fffff',
content: comment,
content: danmaku,
} as any).then((res: any) => {
alert(res.msg)
})

}
const user = getUser() || {}
return <div>
<div class="comment">
<div className="comment-input">
<div class="danmaku">
<div className="danmaku-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>
<h1>共有{danmakus ? danmakus.length : 0}条讨论</h1>


{comments && comments.map(item => {
{danmakus && danmakus.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>
return <div className="danmaku-item">
<div className="danmaku-block">
<p><a href={`https://www.clicli.cc/danmaku/delete/${item.id}?token=${window.localStorage.getItem('token')}`} target="_blank"><del>#{item.id}</del></a></p>
<p>{item.content}</p>
<p>{time}</p>
</div>
Expand Down

0 comments on commit 1340df0

Please sign in to comment.