Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
web
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
iuav
web
Commits
8befad69
提交
8befad69
authored
1月 31, 2024
作者:
ZhangLingKun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
功能:贴子详情
上级
5bd35220
流水线
#8150
已通过 于阶段
in 5 分 40 秒
变更
6
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
163 行增加
和
19 行删除
+163
-19
home.ts
src/api/interface/home.ts
+51
-0
home.ts
src/api/modules/home.ts
+5
-0
index.tsx
src/components/forumItem/index.tsx
+9
-2
[id].tsx
src/pages/course/detail/[id].tsx
+1
-3
[id].tsx
src/pages/forum/detail/[id].tsx
+93
-0
[id].tsx
src/pages/forum/topic/[id].tsx
+4
-14
没有找到文件。
src/api/interface/home.ts
浏览文件 @
8befad69
...
...
@@ -898,3 +898,54 @@ export type GetSecondDistrictInfo = InterFunction<
}
>
;
}[]
>
;
// 论坛详情
type
DetailType
=
{
id
:
number
;
commentAndReplyVO
:
DetailType
[];
description
:
string
;
likes
:
boolean
;
likesCount
:
number
;
title
:
string
;
commentCount
:
number
;
dynamicPublishTime
:
string
;
mediaVO
:
{
type
:
number
;
url
:
string
}[];
userBaseInfo
:
{
nickName
:
string
;
userImg
:
string
;
};
userAccountId
:
number
;
location
:
string
;
gambitName
?:
string
[];
forumGambitDTOList
?:
{
/**
* 话题参与讨论数量
*/
discussionCount
?:
number
;
/**
* 话题封面
*/
gambitCover
?:
string
;
/**
* 话题图标
*/
gambitIcon
?:
string
;
/**
* 话题名称
*/
gambitName
?:
string
;
/**
* 话题属性
*/
gambitProperty
?:
number
;
id
:
number
;
/**
* 贴子数
*/
postCount
?:
number
;
}[];
};
// 论坛详情
export
type
ForumDetailType
=
InterFunction
<
{
dynamicId
:
number
;
userAccountId
?:
number
},
DetailType
>
;
src/api/modules/home.ts
浏览文件 @
8befad69
...
...
@@ -3,6 +3,7 @@ import {
AppGambitListsType
,
AppListPilotType
,
AppPublishListType
,
ForumDetailType
,
ForumListType
,
GetAppGambitListType
,
GetInfoById
,
...
...
@@ -101,4 +102,8 @@ export class HomeAPI {
// 地域
static
getSecondDistrictInfo
:
GetSecondDistrictInfo
=
(
params
)
=>
request
.
get
(
'/pms/webDevice/getSecondDistrictInfo'
,
params
);
// 论坛-详情
static
getForumDetail
:
ForumDetailType
=
(
params
,
config
)
=>
request
.
get
(
'/release/dynamic/dynamicDetails'
,
{
params
,
...
config
});
}
src/components/forumItem/index.tsx
浏览文件 @
8befad69
...
...
@@ -5,6 +5,7 @@ import {
MessageOutlined
,
}
from
'@ant-design/icons'
;
import
{
Image
}
from
'antd'
;
import
{
useRouter
}
from
'next/router'
;
import
styled
from
'styled-components'
;
import
{
InterListType
}
from
'@/api/interface'
;
import
{
ForumListType
}
from
'@/api/interface/home'
;
...
...
@@ -13,13 +14,19 @@ import { ForumListType } from '@/api/interface/home';
type
DetailType
=
InterListType
<
ForumListType
>
[
0
];
const
ForumItemView
:
React
.
FC
<
{
detail
:
DetailType
}
>
=
({
detail
})
=>
{
// 路由钩子
const
router
=
useRouter
();
// 获取帖子的媒体信息 0图片 1视频
const
getForumMedia
=
(
type
:
number
)
=>
{
return
detail
?.
mediaVO
?.
filter
((
i
)
=>
i
?.
type
===
type
)?.
slice
(
0
,
4
);
};
// 帖子相关操作
const
handleAction
=
(
type
:
number
)
=>
{
console
.
log
(
type
);
const
handleAction
=
async
(
type
:
number
)
=>
{
// 评论
if
(
type
===
2
)
{
// 跳转到评论页
await
router
.
push
(
`/forum/detail/
${
detail
?.
id
}
`);
}
};
return (
<ForumItemWrap>
...
...
src/pages/course/detail/[id].tsx
浏览文件 @
8befad69
...
...
@@ -21,9 +21,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
// 获取课程详情
const
getCourseDetail
=
async
()
=>
{
const
res
=
await
CourseAPI
.
getCourseDetail
(
{
id
,
},
{
id
},
{
headers
:
{
token
:
ctx
.
req
.
cookies
[
'SHAREFLY-WEB-TOKEN'
]
}
},
);
if
(
res
&&
res
.
code
===
'200'
)
{
...
...
src/pages/forum/detail/[id].tsx
0 → 100644
浏览文件 @
8befad69
import
React
,
{
useEffect
}
from
'react'
;
import
styled
from
'styled-components'
;
import
{
HomeAPI
}
from
'@/api'
;
import
{
InterDataType
}
from
'@/api/interface'
;
import
{
ForumDetailType
}
from
'@/api/interface/home'
;
import
ForumItemView
from
'@/components/forumItem'
;
import
LayoutView
from
'@/components/layout'
;
import
{
wrapper
}
from
'@/store'
;
import
{
setGlobalData
}
from
'@/store/module/globalData'
;
// 详情类型
type
DetailType
=
InterDataType
<
ForumDetailType
>
;
// 每次加载页面都会执行
export
const
getServerSideProps
=
wrapper
.
getServerSideProps
(
(
store
)
=>
async
(
ctx
)
=>
{
// 贴子id
const
id
:
number
=
Number
(
ctx
.
params
?.
id
);
// 贴子详情
let
forumDetail
:
DetailType
|
undefined
;
// 获取贴子详情
const
getForumDetail
=
async
()
=>
{
const
res
=
await
HomeAPI
.
getForumDetail
(
{
dynamicId
:
id
},
{
headers
:
{
token
:
ctx
.
req
.
cookies
[
'SHAREFLY-WEB-TOKEN'
]
}
},
);
if
(
res
&&
res
.
code
===
'200'
)
{
forumDetail
=
res
.
result
;
}
};
// 依次获取接口数据
await
(
async
()
=>
{
// 如果未登录,则弹出登录框
if
(
!
ctx
.
req
.
cookies
[
'SHAREFLY-WEB-TOKEN'
])
{
store
.
dispatch
(
setGlobalData
({
loginModalVisible
:
true
,
loginModalBack
:
true
}),
);
}
else
{
await
getForumDetail
();
}
})();
return
{
props
:
{
forumDetail
}
};
},
);
const
ForumDetailPage
:
React
.
FC
<
{
forumDetail
:
DetailType
}
>
=
({
forumDetail
,
})
=>
{
// 组件挂载
useEffect
(()
=>
{
console
.
log
(
'组件挂载 ====>'
,
forumDetail
);
},
[]);
return
(
<
LayoutView
>
<
ForumDetailWrap
>
<
div
className=
"forum-wrap"
>
<
div
className=
"forum-detail"
>
<
ForumItemView
detail=
{
forumDetail
as
any
}
/>
</
div
>
<
div
className=
"forum-order"
>
45345
</
div
>
</
div
>
</
ForumDetailWrap
>
</
LayoutView
>
);
};
export
default
ForumDetailPage
;
// 样式
const
ForumDetailWrap
=
styled
.
div
`
position: relative;
max-width: 1190px;
box-sizing: border-box;
padding: 2rem 0 0 0;
margin: 0 auto;
.forum-wrap {
position: relative;
width: 100%;
display: flex;
align-items: flex-start;
justify-content: flex-start;
flex-wrap: nowrap;
box-sizing: border-box;
.forum-detail {
position: relative;
width: calc(70% - 2rem);
margin-right: 2rem;
}
.forum-order {
position: relative;
width: 30%;
background: lightgreen;
}
}
`
;
src/pages/forum/topic/[id].tsx
浏览文件 @
8befad69
...
...
@@ -3,7 +3,7 @@ import { PlusOutlined } from '@ant-design/icons';
import
{
App
,
Button
}
from
'antd'
;
import
{
GetServerSidePropsContext
}
from
'next'
;
import
{
useRouter
}
from
'next/router'
;
import
{
use
Dispatch
,
use
Selector
}
from
'react-redux'
;
import
{
useSelector
}
from
'react-redux'
;
import
styled
from
'styled-components'
;
import
{
HomeAPI
}
from
'@/api'
;
import
{
InterListType
,
PaginationProps
}
from
'@/api/interface'
;
...
...
@@ -12,7 +12,6 @@ import ForumItemView from '@/components/forumItem';
import
InfiniteScrollList
from
'@/components/InfiniteScrollList'
;
import
LayoutView
from
'@/components/layout'
;
import
{
RootState
}
from
'@/store'
;
import
{
setGlobalData
}
from
'@/store/module/globalData'
;
import
{
SystemState
}
from
'@/store/module/system'
;
// 详情类型
...
...
@@ -51,7 +50,7 @@ const ForumTopicDetailPage: React.FC<{ topicDetail: DetailType }> = ({
// 路由钩子
const
router
=
useRouter
();
// store
const
dispatch
=
useDispatch
();
//
const dispatch = useDispatch();
// system
const
system
=
useSelector
((
state
:
RootState
)
=>
state
.
system
)
as
SystemState
;
// 帖子列表
...
...
@@ -90,17 +89,8 @@ const ForumTopicDetailPage: React.FC<{ topicDetail: DetailType }> = ({
}
};
useEffect
(()
=>
{
if
(
!
system
?.
token
)
{
dispatch
(
setGlobalData
({
loginModalVisible
:
true
,
loginModalBack
:
true
,
}),
);
}
else
{
if
(
!
topicDetail
?.
id
)
return
;
getAppGambitLists
().
then
();
}
if
(
!
topicDetail
?.
id
)
return
;
getAppGambitLists
().
then
();
},
[
topicDetail
]);
return
(
<
LayoutView
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论