Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
4bf07ce1
提交
4bf07ce1
authored
3月 07, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
讨论删除 逻辑
上级
004e0834
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
198 行增加
和
12 行删除
+198
-12
library.dart
lib/apis/library.dart
+18
-0
discuss_controller.dart
lib/pages/read_web/discuss_controller.dart
+10
-1
discuss.dart
lib/pages/read_web/widgets/discuss.dart
+3
-0
controller.dart
lib/pages/user_discuss_des/controller.dart
+75
-1
index.dart
lib/pages/user_discuss_des/index.dart
+3
-0
discuss.dart
lib/pages/user_discuss_des/widgets/discuss.dart
+0
-0
list.dart
lib/pages/user_discuss_des/widgets/list.dart
+89
-10
没有找到文件。
lib/apis/library.dart
浏览文件 @
4bf07ce1
...
...
@@ -361,6 +361,23 @@ abstract class LibraryAPI {
}
return
false
;
}
/// 18、删除讨论回复
static
Future
<
bool
>
delComment
({
required
num
bookId
,
required
num
commentId
,
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/book/Information/delComment'
,
params:
{
'book_id'
:
bookId
,
'comment_id'
:
commentId
},
);
if
(
result
.
data
is
Map
&&
result
.
data
[
'is_success'
]
==
1
){
return
true
;
}
return
false
;
}
}
\ No newline at end of file
lib/pages/read_web/discuss_controller.dart
浏览文件 @
4bf07ce1
...
...
@@ -61,6 +61,7 @@ class DiscussController extends GetxController {
update
();
}
// 点赞 取消点赞
Future
<
void
>
commentLove
({
required
DiscussModel
discussModel
})
async
{
num
type
=
0
;
if
(
discussModel
.
isPraise
==
0
){
...
...
@@ -81,7 +82,15 @@ class DiscussController extends GetxController {
update
();
}
// 删除回复
Future
<
void
>
delComment
({
required
DiscussModel
discussModel
})
async
{
final
result
=
await
LibraryAPI
.
delComment
(
bookId:
bookDetailModel
.
bookId
!,
commentId:
discussModel
.
id
!);
if
(
result
){
discuss
.
remove
(
discussModel
);
Toast
.
show
(
'删除成功'
);
}
update
();
}
Future
<
bool
>
submit
()
async
{
...
...
lib/pages/read_web/widgets/discuss.dart
浏览文件 @
4bf07ce1
...
...
@@ -107,6 +107,9 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
model:
model
,
controller:
controller
,
bookId:
widget
.
bookDetailModel
.
bookId
.
toString
(),
onTapDel:
(
DiscussModel
dModel
){
controller
.
delComment
(
discussModel:
dModel
);
},
);
},
itemCount:
controller
.
discuss
.
length
,
...
...
lib/pages/user_discuss_des/controller.dart
浏览文件 @
4bf07ce1
...
...
@@ -10,24 +10,98 @@ class UserDiscussDesController extends GetxController {
controlFinishLoad:
true
,
controlFinishRefresh:
true
,
);
late
TextEditingController
replyInput
=
TextEditingController
();
final
int
_limit
=
10
;
int
_page
=
1
;
bool
_noMore
=
false
;
// 展示回复输入框
bool
showReply
=
false
;
// 当前要回复的模型
late
DiscussModel
discussModel
;
@override
void
onReady
()
{
onRefresh
();
//
onRefresh();
super
.
onReady
();
}
@override
void
onClose
()
{
refreshController
.
dispose
();
replyInput
.
dispose
();
super
.
onClose
();
}
void
setShow
()
{
showReply
=
!
showReply
;
update
();
}
void
setDiscussModel
(
DiscussModel
model
){
discussModel
=
model
;
}
// 删除回复
Future
<
void
>
delComment
({
required
DiscussModel
discussModel
})
async
{
final
result
=
await
LibraryAPI
.
delComment
(
bookId:
model
.
bookId
!,
commentId:
discussModel
.
id
!);
if
(
result
){
discuss
.
remove
(
discussModel
);
Toast
.
show
(
'删除成功'
);
}
update
();
}
Future
<
bool
>
submit
()
async
{
Map
<
String
,
dynamic
>
contentMap
=
{
'text'
:
replyInput
.
text
,
'audio'
:[],
'image'
:[]
};
final
result
=
await
LibraryAPI
.
addDiscuss
(
bookId:
model
.
bookId
.
toString
(),
chapterId:
discussModel
.
chapterId
.
toString
(),
commentId:
discussModel
.
id
.
toString
(),
quoteContent:
''
,
title:
''
,
content:
jsonEncode
(
contentMap
)
);
if
(
result
){
Toast
.
show
(
'话题发表成功'
);
}
else
{
Toast
.
show
(
'话题发表失败'
);
}
// 重置所有信息
// reset();
// setShowChat(false);
return
result
;
}
Future
<
void
>
commentLove
({
required
DiscussModel
discussModel
})
async
{
num
type
=
0
;
if
(
discussModel
.
isPraise
==
0
){
type
=
1
;
}
final
result
=
await
LibraryAPI
.
commentLove
(
bookId:
model
.
bookId
!
,
type:
type
,
commentId:
discussModel
.
id
!);
if
(
result
){
num
goodNum
=
discussModel
.
goodNum
??
0
;
if
(
type
==
0
){
goodNum
--;
}
else
{
goodNum
++;
}
discussModel
.
isPraise
=
type
;
discussModel
.
goodNum
=
goodNum
;
}
update
();
}
/// 获取讨论详情
Future
<
void
>
_getDiscuss
([
bool
isRefresh
=
false
])
async
{
...
...
lib/pages/user_discuss_des/index.dart
浏览文件 @
4bf07ce1
library
user_discuss_des
;
import
'dart:convert'
;
import
'package:easy_refresh/easy_refresh.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:flutter_slidable/flutter_slidable.dart'
;
import
'package:get/get.dart'
;
import
'package:go_router/go_router.dart'
;
...
...
lib/pages/user_discuss_des/widgets/discuss.dart
浏览文件 @
4bf07ce1
差异被折叠。
点击展开。
lib/pages/user_discuss_des/widgets/list.dart
浏览文件 @
4bf07ce1
...
...
@@ -24,16 +24,95 @@ class _BuildListPageState extends State<BuildListPage> with AutomaticKeepAliveCl
controller:
controller
.
refreshController
,
onRefresh:
controller
.
onRefresh
,
onLoading:
controller
.
onLoading
,
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
DiscussModel
model
=
controller
.
discuss
[
index
];
return
BuildDiscuss
(
model:
model
,
bookId:
widget
.
model
.
bookId
.
toString
(),
);
},
itemCount:
controller
.
discuss
.
length
,
),
child:
Stack
(
children:
[
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
DiscussModel
model
=
controller
.
discuss
[
index
];
return
BuildDiscuss
(
model:
model
,
bookId:
widget
.
model
.
bookId
.
toString
(),
userDiscussDesController:
controller
,
onTapDel:
(
DiscussModel
dModel
){
controller
.
delComment
(
discussModel:
dModel
);
},
);
},
itemCount:
controller
.
discuss
.
length
,
),
Visibility
(
visible:
controller
.
showReply
,
child:
Positioned
(
bottom:
0
,
left:
0
,
right:
0
,
top:
0
,
child:
GestureDetector
(
onTap:
(){
controller
.
setShow
();
},
child:
Container
(
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
child:
SingleChildScrollView
(
reverse:
true
,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
onTap:
(){},
child:
Container
(
color:
Colors
.
white
,
padding:
EdgeInsets
.
only
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
),
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Row
(
children:
[
Expanded
(
child:
TextField
(
autofocus:
true
,
maxLines:
null
,
controller:
controller
.
replyInput
,
decoration:
InputDecoration
(
border:
InputBorder
.
none
,
enabledBorder:
InputBorder
.
none
,
focusedBorder:
InputBorder
.
none
,
hintText:
'请输入内容'
,
hintStyle:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c9
,),
filled:
true
,
fillColor:
Colours
.
cF8
,
),
),
),
Gaps
.
hGaps10
,
GestureDetector
(
onTap:
(){
controller
.
submit
();
controller
.
setShow
();
},
child:
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
15
.
w
),
color:
AppTheme
.
primary
,
gradient:
LinearGradient
(
colors:
[
const
Color
(
0xFFD53676
).
withOpacity
(
0.9
),
AppTheme
.
primary
]
,
// 不可点击时的颜色,透明度为0.7
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
),
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
13.5
.
w
,
vertical:
4
.
w
),
child:
Text
(
'发表'
,
style:
TextStyle
(
fontSize:
14
.
w
,
fontWeight:
Fonts
.
medium
,
color:
Colors
.
white
),),
),
)
],
),
),
),
),
),
),
),
),
)
],
)
),
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论