Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
web-ci-test
Commits
b30fcef2
提交
b30fcef2
authored
5月 30, 2023
作者:
翁进城
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
论坛评价列表接口对接
上级
fa814afd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
121 行增加
和
42 行删除
+121
-42
index.tsx
pages/forum/api/index.tsx
+15
-4
index.page.tsx
pages/forum/index.page.tsx
+106
-38
没有找到文件。
pages/forum/api/index.tsx
浏览文件 @
b30fcef2
...
@@ -40,10 +40,9 @@ export interface CommentParams {
...
@@ -40,10 +40,9 @@ export interface CommentParams {
content
:
string
;
//评论内容
content
:
string
;
//评论内容
dynamicId
:
number
;
//动态id
dynamicId
:
number
;
//动态id
parentId
?:
number
;
//父级评论
parentId
?:
number
;
//父级评论
userId
:
number
;
//用户id
}
}
export
interface
ByDynamic
Params
{
export
interface
ByDynamic
Resp
{
id
:
number
;
id
:
number
;
dynamicId
:
number
;
dynamicId
:
number
;
parentId
:
number
;
parentId
:
number
;
...
@@ -51,7 +50,12 @@ export interface ByDynamicParams {
...
@@ -51,7 +50,12 @@ export interface ByDynamicParams {
content
:
string
;
content
:
string
;
likesCount
:
number
;
likesCount
:
number
;
createTime
:
string
;
createTime
:
string
;
children
:
ByDynamicParams
[];
children
:
ByDynamicResp
[];
userBaseInfoVO
:
{
id
:
number
,
nickName
:
string
,
userImg
:
string
}
}
}
export
default
{
export
default
{
...
@@ -70,7 +74,14 @@ export default {
...
@@ -70,7 +74,14 @@ export default {
},
},
//根据动态查看评论
//根据动态查看评论
byDynamic
(
params
:
{
dynamicId
:
number
}):
Promise
<
Response
<
Array
<
ByDynamicParams
>>>
{
byDynamic
(
params
:
{
dynamicId
:
number
;
}):
Promise
<
Response
<
Array
<
ByDynamicResp
>>>
{
return
request
(
"/release/dynamic/byDynamic"
,
"get"
,
params
);
return
request
(
"/release/dynamic/byDynamic"
,
"get"
,
params
);
},
},
//点赞或取消点赞
likeOrCancel
(
params
:
{
dynamicId
:
number
})
{
return
request
(
"/release/dynamic/likeOrCancel"
,
"get"
,
params
);
},
};
};
pages/forum/index.page.tsx
浏览文件 @
b30fcef2
...
@@ -15,14 +15,15 @@ import errImg from "~/assets/errImg";
...
@@ -15,14 +15,15 @@ import errImg from "~/assets/errImg";
import
{
RightOutlined
}
from
"@ant-design/icons"
;
import
{
RightOutlined
}
from
"@ant-design/icons"
;
import
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
{
useContext
,
useEffect
,
useState
}
from
"react"
;
import
PublishMessage
from
"./components/publishMessage"
;
import
PublishMessage
from
"./components/publishMessage"
;
import
api
,
{
ByDynamic
Params
,
Dynamic
}
from
"./api"
;
import
api
,
{
ByDynamic
Resp
,
Dynamic
}
from
"./api"
;
import
InfiniteScroll
from
"react-infinite-scroll-component"
;
import
InfiniteScroll
from
"react-infinite-scroll-component"
;
import
{
UserContext
}
from
"~/lib/userProvider"
;
import
{
UserContext
}
from
"~/lib/userProvider"
;
import
moment
from
"moment"
;
interface
Item
extends
Dynamic
{
interface
Item
extends
Dynamic
{
openComment
?:
boolean
;
//是否开启评论
openComment
?:
boolean
;
//是否开启评论
showCommentAll
?:
boolean
;
//是否展示全部评论
showCommentAll
?:
boolean
;
//是否展示全部评论
commentList
?:
Array
<
ByDynamic
Params
>
;
commentList
?:
Array
<
ByDynamic
Resp
>
;
//评论列表
}
}
export
default
function
Forum
()
{
export
default
function
Forum
()
{
...
@@ -34,6 +35,7 @@ export default function Forum() {
...
@@ -34,6 +35,7 @@ export default function Forum() {
});
});
const
[
count
,
setCount
]
=
useState
(
0
);
//动态总数
const
[
count
,
setCount
]
=
useState
(
0
);
//动态总数
const
{
userInfo
,
setNeedLogin
}
=
useContext
(
UserContext
);
const
{
userInfo
,
setNeedLogin
}
=
useContext
(
UserContext
);
const
[
form
]
=
Form
.
useForm
();
//评论区的form
useEffect
(()
=>
{
useEffect
(()
=>
{
api
api
...
@@ -78,27 +80,74 @@ export default function Forum() {
...
@@ -78,27 +80,74 @@ export default function Forum() {
item
.
openComment
=
!
item
.
openComment
;
item
.
openComment
=
!
item
.
openComment
;
const
temp
=
[...
list
];
const
temp
=
[...
list
];
setList
(
temp
);
setList
(
temp
);
getCommentList
(
item
);
};
};
//评论内容
//获取评论列表
const
onComment
=
(
values
:
any
,
id
:
number
,
i
:
number
)
=>
{
const
getCommentList
=
(
item
:
Item
)
=>
{
api
.
byDynamic
({
dynamicId
:
item
.
id
,
})
.
then
((
res
)
=>
{
if
(
res
?.
code
===
"200"
)
{
item
.
commentList
=
res
.
result
||
[];
}
const
temp
=
[...
list
];
setList
(
temp
);
});
};
//展示所有评论
const
showCommentAll
=
(
item
:
Item
)
=>
{
item
.
showCommentAll
=
true
;
const
temp
=
[...
list
];
setList
(
temp
);
};
//评论内容
const
onComment
=
(
values
:
any
,
item
:
Item
)
=>
{
if
(
userInfo
)
{
if
(
userInfo
)
{
api
api
.
comment
({
.
comment
({
content
:
values
.
content
,
content
:
values
.
content
,
dynamicId
:
id
,
dynamicId
:
item
.
id
,
userId
:
userInfo
.
id
,
})
})
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
res
.
code
===
"200"
)
{
if
(
res
.
code
===
"200"
)
{
window
.
messageApi
.
success
(
"评论成功"
);
window
.
messageApi
.
success
(
"评论成功"
);
form
.
resetFields
([
"content"
]);
item
.
commentCount
+=
1
;
getCommentList
(
item
);
}
}
});
});
}
else
{
}
else
{
setNeedLogin
(
true
);
setNeedLogin
(
true
);
}
}
};
};
//点赞或取消
const
onLike
=
(
item
:
Item
)
=>
{
if
(
userInfo
)
{
api
.
likeOrCancel
({
dynamicId
:
item
.
id
,
})
.
then
((
res
)
=>
{
if
(
res
.
code
===
"200"
)
{
item
.
likes
=
!
item
.
likes
;
if
(
item
.
likes
)
{
item
.
likesCount
++
;
}
else
{
item
.
likesCount
--
;
}
const
temp
=
[...
list
];
setList
(
temp
);
}
});
}
};
return
(
return
(
<
Layout
>
<
Layout
>
<
div
className=
{
styles
.
forum
}
>
<
div
className=
{
styles
.
forum
}
>
...
@@ -169,7 +218,10 @@ export default function Forum() {
...
@@ -169,7 +218,10 @@ export default function Forum() {
></
div
>
></
div
>
{
item
.
commentCount
}
评论
{
item
.
commentCount
}
评论
</
div
>
</
div
>
<
div
className=
{
styles
.
ctrlsItem
}
>
<
div
className=
{
styles
.
ctrlsItem
}
onClick=
{
()
=>
onLike
(
item
)
}
>
<
div
<
div
className=
{
`${styles.ctrlsItemIcon} ${
className=
{
`${styles.ctrlsItemIcon} ${
styles.iconPraise
styles.iconPraise
...
@@ -183,8 +235,9 @@ export default function Forum() {
...
@@ -183,8 +235,9 @@ export default function Forum() {
{
item
.
openComment
&&
(
{
item
.
openComment
&&
(
<
div
className=
{
styles
.
commentWrap
}
>
<
div
className=
{
styles
.
commentWrap
}
>
<
Form
<
Form
form=
{
form
}
onFinish=
{
(
values
)
=>
{
onFinish=
{
(
values
)
=>
{
onComment
(
values
,
item
.
id
,
i
);
onComment
(
values
,
item
,
i
);
}
}
}
}
>
>
<
Form
.
Item
<
Form
.
Item
...
@@ -213,38 +266,53 @@ export default function Forum() {
...
@@ -213,38 +266,53 @@ export default function Forum() {
</
Form
>
</
Form
>
<
div
className=
{
styles
.
comments
}
>
<
div
className=
{
styles
.
comments
}
>
<
div
className=
{
styles
.
commentItem
}
>
{
/* 判断是否展示所有评论 */
}
<
div
className=
{
styles
.
commentHeadImg
}
></
div
>
{
item
.
commentList
<
div
className=
{
styles
.
info
}
>
?.
filter
((
comment
,
i
)
=>
{
<
div
className=
{
styles
.
nameWrap
}
>
if
(
item
.
showCommentAll
)
{
<
div
className=
{
styles
.
commentName
}
>
return
true
;
无人机爱好者111:
}
else
{
<
div
className=
{
styles
.
date
}
>
05-16
</
div
>
if
(
i
<
2
)
{
</
div
>
return
true
;
<
div
className=
{
styles
.
commentContent
}
>
}
无人机记录生活
}
})
.
map
((
comment
)
=>
{
return
(
<
div
key=
{
comment
.
id
}
className=
{
styles
.
commentItem
}
>
<
div
className=
{
styles
.
commentHeadImg
}
>
<
Image
src=
{
comment
.
userBaseInfoVO
?.
userImg
}
></
Image
>
</
div
>
<
div
className=
{
styles
.
info
}
>
<
div
className=
{
styles
.
nameWrap
}
>
<
div
className=
{
styles
.
commentName
}
>
{
comment
.
userBaseInfoVO
?.
nickName
}
:
<
div
className=
{
styles
.
date
}
>
{
moment
(
comment
.
createTime
).
format
(
"YYYY-MM-DD"
)
}
</
div
>
</
div
>
<
div
className=
{
styles
.
commentContent
}
>
{
comment
.
content
}
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
);
</
div
>
})
}
</
div
>
<
div
className=
{
styles
.
commentItem
}
>
<
div
className=
{
styles
.
commentHeadImg
}
></
div
>
<
div
className=
{
styles
.
info
}
>
<
div
className=
{
styles
.
nameWrap
}
>
<
div
className=
{
styles
.
commentName
}
>
无人机爱好者111:
<
div
className=
{
styles
.
date
}
>
05-16
</
div
>
</
div
>
<
div
className=
{
styles
.
commentContent
}
>
无人机记录生活
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
{
!
item
.
showCommentAll
&&
(
{
!
item
.
showCommentAll
&&
item
.
commentCount
>
2
&&
(
<
div
className=
{
styles
.
showAll
}
>
<
div
查看全部15条评论
className=
{
styles
.
showAll
}
onClick=
{
()
=>
showCommentAll
(
item
)
}
>
查看全部
{
item
.
commentCount
}
条评论
<
RightOutlined
size=
{
14
}
/>
<
RightOutlined
size=
{
14
}
/>
</
div
>
</
div
>
)
}
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论