Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
web
Commits
38ad8abf
提交
38ad8abf
authored
2月 01, 2024
作者:
ZhangLingKun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
功能:贴子详情
上级
8befad69
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
177 行增加
和
10 行删除
+177
-10
home.ts
src/api/interface/home.ts
+50
-0
home.ts
src/api/modules/home.ts
+6
-1
index.tsx
src/components/forumItem/index.tsx
+13
-3
[id].tsx
src/pages/forum/detail/[id].tsx
+108
-6
没有找到文件。
src/api/interface/home.ts
浏览文件 @
38ad8abf
...
@@ -949,3 +949,53 @@ export type ForumDetailType = InterFunction<
...
@@ -949,3 +949,53 @@ export type ForumDetailType = InterFunction<
{
dynamicId
:
number
;
userAccountId
?:
number
},
{
dynamicId
:
number
;
userAccountId
?:
number
},
DetailType
DetailType
>
;
>
;
// 话题-所有评论
export
type
AllCommentListType
=
InterListFunction
<
{
dynamicId
:
number
;
userAccountId
:
number
},
{
/**
* 评论内容
*/
content
:
string
;
/**
* 创建时间
*/
createTime
?:
string
;
/**
* 动态id
*/
dynamicId
:
number
;
/**
* id
*/
id
:
number
;
/**
* 评论点赞数
*/
likeCount
?:
number
;
/**
* pid
*/
pid
?:
number
;
/**
* 回复id
*/
reviewId
?:
number
;
/**
* 更新时间
*/
updateTime
?:
string
;
/**
* 用户id
*/
userAccountId
?:
number
;
status
:
number
;
replyCount
:
number
;
userAccountVO
:
{
userImg
:
string
;
userName
:
string
;
nickName
:
string
;
id
:
number
;
};
}
>
;
src/api/modules/home.ts
浏览文件 @
38ad8abf
import
{
import
{
AllCommentListType
,
AppCategoryInfoType
,
AppCategoryInfoType
,
AppGambitListsType
,
AppGambitListsType
,
AppListPilotType
,
AppListPilotType
,
...
@@ -103,7 +104,11 @@ export class HomeAPI {
...
@@ -103,7 +104,11 @@ export class HomeAPI {
static
getSecondDistrictInfo
:
GetSecondDistrictInfo
=
(
params
)
=>
static
getSecondDistrictInfo
:
GetSecondDistrictInfo
=
(
params
)
=>
request
.
get
(
'/pms/webDevice/getSecondDistrictInfo'
,
params
);
request
.
get
(
'/pms/webDevice/getSecondDistrictInfo'
,
params
);
//
论坛-详情
// 论坛-详情
static
getForumDetail
:
ForumDetailType
=
(
params
,
config
)
=>
static
getForumDetail
:
ForumDetailType
=
(
params
,
config
)
=>
request
.
get
(
'/release/dynamic/dynamicDetails'
,
{
params
,
...
config
});
request
.
get
(
'/release/dynamic/dynamicDetails'
,
{
params
,
...
config
});
// 话题-所有评论
static
getAllCommentList
:
AllCommentListType
=
(
params
)
=>
request
.
post
(
'/release/gambit/allCommentList'
,
params
);
}
}
src/components/forumItem/index.tsx
浏览文件 @
38ad8abf
...
@@ -6,26 +6,36 @@ import {
...
@@ -6,26 +6,36 @@ import {
}
from
'@ant-design/icons'
;
}
from
'@ant-design/icons'
;
import
{
Image
}
from
'antd'
;
import
{
Image
}
from
'antd'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useRouter
}
from
'next/router'
;
import
{
useDispatch
}
from
'react-redux'
;
import
styled
from
'styled-components'
;
import
styled
from
'styled-components'
;
import
{
InterListType
}
from
'@/api/interface'
;
import
{
InterListType
}
from
'@/api/interface'
;
import
{
ForumListType
}
from
'@/api/interface/home'
;
import
{
ForumListType
}
from
'@/api/interface/home'
;
import
{
setGlobalData
}
from
'@/store/module/globalData'
;
// 详情类型
// 详情类型
type
DetailType
=
InterListType
<
ForumListType
>
[
0
];
type
DetailType
=
InterListType
<
ForumListType
>
[
0
];
const
ForumItemView
:
React
.
FC
<
{
detail
:
DetailType
}
>
=
({
detail
})
=>
{
const
ForumItemView
:
React
.
FC
<
{
detail
:
DetailType
;
isDetail
?:
Boolean
}
>
=
({
detail
,
isDetail
=
false
,
})
=>
{
// 路由钩子
// 路由钩子
const
router
=
useRouter
();
const
router
=
useRouter
();
// store
const
dispatch
=
useDispatch
();
// 获取帖子的媒体信息 0图片 1视频
// 获取帖子的媒体信息 0图片 1视频
const
getForumMedia
=
(
type
:
number
)
=>
{
const
getForumMedia
=
(
type
:
number
)
=>
{
return
detail
?.
mediaVO
?.
filter
((
i
)
=>
i
?.
type
===
type
)?.
slice
(
0
,
4
);
return
detail
?.
mediaVO
?.
filter
((
i
)
=>
i
?.
type
===
type
)?.
slice
(
0
,
4
);
};
};
// 帖子相关操作
// 帖子相关操作
const
handleAction
=
async
(
type
:
number
)
=>
{
const
handleAction
=
(
type
:
number
)
=>
{
// 评论
// 评论
if
(
type
===
2
)
{
if
(
type
===
2
)
{
// 如果是在详情页面则不执行跳转
if
(
isDetail
)
return
;
// 跳转到评论页
// 跳转到评论页
await
router
.
push
(
`/forum/detail/
${
detail
?.
id
}
`);
dispatch
(
setGlobalData
({
loadingSpinnerVisible
:
true
}));
router
.
push
(
`/forum/detail/
${
detail
?.
id
}
`).then();
}
}
};
};
return (
return (
...
...
src/pages/forum/detail/[id].tsx
浏览文件 @
38ad8abf
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Input
}
from
'antd'
;
import
{
useSelector
}
from
'react-redux'
;
import
styled
from
'styled-components'
;
import
styled
from
'styled-components'
;
import
{
HomeAPI
}
from
'@/api'
;
import
{
HomeAPI
}
from
'@/api'
;
import
{
InterDataType
}
from
'@/api/interface'
;
import
{
InterDataType
,
InterListType
,
PaginationProps
}
from
'@/api/interface'
;
import
{
ForumDetailType
}
from
'@/api/interface/home'
;
import
{
AllCommentListType
,
ForumDetailType
}
from
'@/api/interface/home'
;
import
ForumItemView
from
'@/components/forumItem'
;
import
ForumItemView
from
'@/components/forumItem'
;
import
LayoutView
from
'@/components/layout'
;
import
LayoutView
from
'@/components/layout'
;
import
{
wrapper
}
from
'@/store'
;
import
{
wrapper
}
from
'@/store'
;
import
{
setGlobalData
}
from
'@/store/module/globalData'
;
import
{
setGlobalData
}
from
'@/store/module/globalData'
;
import
{
UserInfoState
}
from
'@/store/module/userInfo'
;
// 详情类型
// 详情类型
type
DetailType
=
InterDataType
<
ForumDetailType
>
;
type
DetailType
=
InterDataType
<
ForumDetailType
>
;
// 评论类型
type
CommentType
=
InterListType
<
AllCommentListType
>
;
// 每次加载页面都会执行
// 每次加载页面都会执行
export
const
getServerSideProps
=
wrapper
.
getServerSideProps
(
export
const
getServerSideProps
=
wrapper
.
getServerSideProps
(
...
@@ -17,7 +22,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
...
@@ -17,7 +22,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
// 贴子id
// 贴子id
const
id
:
number
=
Number
(
ctx
.
params
?.
id
);
const
id
:
number
=
Number
(
ctx
.
params
?.
id
);
// 贴子详情
// 贴子详情
let
forumDetail
:
DetailType
|
undefined
;
let
forumDetail
:
DetailType
|
null
=
null
;
// 获取贴子详情
// 获取贴子详情
const
getForumDetail
=
async
()
=>
{
const
getForumDetail
=
async
()
=>
{
const
res
=
await
HomeAPI
.
getForumDetail
(
const
res
=
await
HomeAPI
.
getForumDetail
(
...
@@ -45,16 +50,70 @@ export const getServerSideProps = wrapper.getServerSideProps(
...
@@ -45,16 +50,70 @@ export const getServerSideProps = wrapper.getServerSideProps(
const
ForumDetailPage
:
React
.
FC
<
{
forumDetail
:
DetailType
}
>
=
({
const
ForumDetailPage
:
React
.
FC
<
{
forumDetail
:
DetailType
}
>
=
({
forumDetail
,
forumDetail
,
})
=>
{
})
=>
{
// userInfo
const
userInfo
=
useSelector
((
state
:
any
)
=>
state
.
userInfo
)
as
UserInfoState
;
// 翻页数据
const
[
pagination
,
setPagination
]
=
useState
<
{
totalPage
:
number
;
totalCount
:
number
}
&
PaginationProps
>
({
pageNo
:
1
,
pageSize
:
10
,
totalPage
:
0
,
totalCount
:
0
,
});
// 评论列表
const
[
commentList
,
setCommentList
]
=
useState
<
CommentType
>
([]);
// 获取评论列表
const
getAllCommentList
=
async
()
=>
{
const
res
=
await
HomeAPI
.
getAllCommentList
({
dynamicId
:
forumDetail
?.
id
,
userAccountId
:
userInfo
?.
id
,
pageNo
:
pagination
.
pageNo
,
pageSize
:
pagination
.
pageSize
,
});
if
(
res
&&
res
.
code
===
'200'
)
{
const
{
list
,
totalPage
,
pageNo
,
pageSize
,
totalCount
}
=
res
.
result
||
{};
console
.
log
(
'评论列表 ===>'
,
list
);
setCommentList
((
prevList
)
=>
[...
prevList
,
...(
list
||
[])]);
pagination
.
totalPage
=
totalPage
;
setPagination
({
pageNo
,
pageSize
,
totalPage
,
totalCount
});
}
};
// 组件挂载
// 组件挂载
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
forumDetail
?.
id
)
return
;
getAllCommentList
().
then
();
console
.
log
(
'组件挂载 ====>'
,
forumDetail
);
console
.
log
(
'组件挂载 ====>'
,
forumDetail
);
},
[]);
},
[
forumDetail
]);
return
(
return
(
<
LayoutView
>
<
LayoutView
>
<
ForumDetailWrap
>
<
ForumDetailWrap
>
<
div
className=
"forum-wrap"
>
<
div
className=
"forum-wrap"
>
<
div
className=
"forum-detail"
>
<
div
className=
"forum-detail"
>
<
ForumItemView
detail=
{
forumDetail
as
any
}
/>
<
ForumItemView
detail=
{
forumDetail
as
any
}
isDetail=
{
true
}
/>
<
div
className=
"detail-comment"
>
<
div
className=
"comment-title"
>
发表评论
</
div
>
<
div
className=
"comment-view"
>
<
img
className=
"image"
src=
{
userInfo
?.
userImg
}
alt=
"我的头像"
/>
<
div
className=
"content"
>
<
Input
.
TextArea
placeholder=
{
'发表评论'
}
showCount
style=
{
{
height
:
86
}
}
maxLength=
{
140
}
/>
<
div
className=
"action"
>
<
Button
type=
"primary"
shape=
"round"
>
发布
</
Button
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
className=
"detail-list"
>
<
div
className=
"list-title"
>
评论列表
</
div
>
</
div
>
</
div
>
</
div
>
<
div
className=
"forum-order"
>
45345
</
div
>
<
div
className=
"forum-order"
>
45345
</
div
>
</
div
>
</
div
>
...
@@ -83,6 +142,49 @@ const ForumDetailWrap = styled.div`
...
@@ -83,6 +142,49 @@ const ForumDetailWrap = styled.div`
position: relative;
position: relative;
width: calc(70% - 2rem);
width: calc(70% - 2rem);
margin-right: 2rem;
margin-right: 2rem;
.detail-comment {
position: relative;
width: 100%;
.comment-title {
font-size: 14px;
font-weight: bold;
margin-bottom: 1rem;
}
.comment-view {
position: relative;
width: 100%;
display: flex;
align-items: flex-start;
justify-content: flex-start;
box-sizing: border-box;
.image {
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
margin-right: 1rem;
}
.content {
position: relative;
width: calc(100% - 3.5rem);
box-sizing: border-box;
.action {
margin-top: 1.5rem;
width: 100%;
display: flex;
justify-content: flex-end;
}
}
}
}
.detail-list {
position: relative;
width: 100%;
.list-title {
font-size: 14px;
font-weight: bold;
margin-bottom: 1rem;
}
}
}
}
.forum-order {
.forum-order {
position: relative;
position: relative;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论