Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
eb0b5081
提交
eb0b5081
authored
2月 24, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
离线的笔记保存的是本地url 上传笔记的时候先要直传获取oss地址
上级
96ee11be
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
108 行增加
和
21 行删除
+108
-21
controller.dart
lib/pages/library/controller.dart
+45
-1
controller.dart
lib/pages/read_web/controller.dart
+57
-18
sql.dart
lib/utils/sql.dart
+6
-2
没有找到文件。
lib/pages/library/controller.dart
浏览文件 @
eb0b5081
...
@@ -94,7 +94,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
...
@@ -94,7 +94,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
'content'
:
'This is a note content'
,
'content'
:
'This is a note content'
,
'upload'
:
0
,
'upload'
:
0
,
'positioning'
:
'top'
,
'positioning'
:
'top'
,
'note'
:
'This is a note'
,
'note
_content
'
:
'This is a note'
,
'node_id'
:
0
,
'node_id'
:
0
,
};
};
...
@@ -246,6 +246,38 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
...
@@ -246,6 +246,38 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
Console
.
log
(
'查询到的数据----------------------------------------------------
$data
'
);
Console
.
log
(
'查询到的数据----------------------------------------------------
$data
'
);
if
(
data
.
isNotEmpty
){
if
(
data
.
isNotEmpty
){
for
(
Map
<
String
,
dynamic
>
temp
in
data
){
// 如果是笔记
if
(
temp
[
'type'
]
==
'3'
){
// 存储url的数组
List
<
String
>
finalAudios
=
[];
// 存储url的数组
List
<
String
>
finalImages
=
[];
Map
<
String
,
dynamic
>
contentMap
=
jsonDecode
(
temp
[
'note_content'
]);
List
<
String
>
audios
=
contentMap
[
'audio'
];
if
(
audios
.
isNotEmpty
){
for
(
String
path
in
audios
){
final
url
=
await
uploadSource
(
path:
path
);
finalAudios
.
add
(
url
);
}
}
List
<
String
>
images
=
contentMap
[
'image'
];
if
(
images
.
isNotEmpty
){
for
(
String
path
in
images
){
final
url
=
await
uploadSource
(
path:
path
);
finalImages
.
add
(
url
);
}
}
Map
<
String
,
dynamic
>
finalContentMap
=
{
'text'
:
contentMap
[
'text'
],
'audio'
:
finalAudios
,
'image'
:
finalImages
};
temp
[
'note_content'
]
=
finalContentMap
;
}
}
final
result
=
await
LibraryAPI
.
uploadOffline
(
node:
jsonEncode
(
data
));
final
result
=
await
LibraryAPI
.
uploadOffline
(
node:
jsonEncode
(
data
));
// 上传成功后 更新数据库中的字段
// 上传成功后 更新数据库中的字段
if
(
result
)
{
if
(
result
)
{
...
@@ -255,6 +287,18 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
...
@@ -255,6 +287,18 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
}
}
// 上传文件
Future
<
String
>
uploadSource
({
required
String
path
})
async
{
// String result = await CommonAPI.upload(path:path,fileTypes: 'comment');
// return result;
OssTool
tool
=
OssTool
(
'zxts-comment-file'
);
final
response
=
await
tool
.
putObjectFile
(
path
);
Console
.
log
(
'------response--------------------------
${response.realUri}
'
);
return
response
.
realUri
.
toString
();
}
/// 获取图书列表数据
/// 获取图书列表数据
Future
<
void
>
_getBooks
([
bool
isRefresh
=
false
])
async
{
Future
<
void
>
_getBooks
([
bool
isRefresh
=
false
])
async
{
...
...
lib/pages/read_web/controller.dart
浏览文件 @
eb0b5081
...
@@ -386,30 +386,47 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -386,30 +386,47 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 图片链接数组
// 图片链接数组
List
<
String
>
images
=
[];
List
<
String
>
images
=
[];
// 循环上传图片获取地址
for
(
String
path
in
discussInputImages
){
final
status
=
await
Tools
.
checkCurrentNetStatus
();
final
url
=
await
upload
(
path:
path
);
// 有网情况下 先直传oss 获取到url
images
.
add
(
url
);
if
(
status
){
// 循环上传图片获取地址
for
(
String
path
in
discussInputImages
){
final
url
=
await
upload
(
path:
path
);
images
.
add
(
url
);
}
// 循环上传音频获取地址
for
(
AudioModel
model
in
discussInputAudios
){
final
url
=
await
upload
(
path:
model
.
path
);
audios
.
add
(
url
);
}
}
}
// 没有网的情况下 存储到本地数据库
else
{
for
(
String
path
in
discussInputImages
){
images
.
add
(
path
);
}
// 循环上传音频获取地址
// 循环上传音频获取地址
for
(
AudioModel
model
in
discussInputAudios
){
for
(
AudioModel
model
in
discussInputAudios
){
final
url
=
await
upload
(
path:
model
.
path
);
audios
.
add
(
model
.
path
);
audios
.
add
(
url
);
}
}
}
Map
<
String
,
dynamic
>
contentMap
=
{
Map
<
String
,
dynamic
>
contentMap
=
{
'text'
:
contentInput
.
text
,
'text'
:
contentInput
.
text
,
'audio'
:
audios
,
'audio'
:
audios
,
'image'
:
images
'image'
:
images
};
};
// 话题
// 话题
只有有网的时候才能发起话题
if
(
chatType
==
0
){
if
(
chatType
==
0
){
final
result
=
await
addDiscuss
(
contentMap
);
final
result
=
await
addDiscuss
(
contentMap
);
return
result
;
return
result
;
}
}
// 笔记
// 笔记
有网没有网都能发起笔记
else
if
(
chatType
==
1
){
else
if
(
chatType
==
1
){
final
result
=
addNote
(
contentMap
);
final
result
=
addNote
(
contentMap
);
return
result
;
return
result
;
...
@@ -419,15 +436,37 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -419,15 +436,37 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 添加笔记
// 添加笔记
Future
<
bool
>
addNote
(
Map
<
String
,
dynamic
>
contentMap
)
async
{
Future
<
bool
>
addNote
(
Map
<
String
,
dynamic
>
contentMap
)
async
{
final
status
=
await
Tools
.
checkCurrentNetStatus
();
bool
result
;
// 有网直接上传接口
if
(
status
){
result
=
await
LibraryAPI
.
addNote
(
bookId:
bookId
,
chapterId:
chapterId
,
content:
noteTitle
,
isOpen:
isPublic
?
'1'
:
'0'
,
positioning:
notePosition
,
noteContent:
jsonEncode
(
contentMap
)
);
}
// 没有网存储本地数据库
else
{
Map
<
String
,
dynamic
>
data
=
{
'types'
:
3
,
'book_id'
:
int
.
parse
(
bookId
),
'chapter_id'
:
int
.
parse
(
chapterId
),
'is_open'
:
isPublic
?
1
:
0
,
'color'
:
'#FF0000'
,
'content'
:
noteTitle
,
'upload'
:
0
,
'positioning'
:
notePosition
,
'note_content'
:
jsonEncode
(
contentMap
),
'node_id'
:
0
,
};
result
=
await
SqlManager
.
insertData
(
data
);
}
final
result
=
await
LibraryAPI
.
addNote
(
bookId:
bookId
,
chapterId:
chapterId
,
content:
noteTitle
,
isOpen:
isPublic
?
'1'
:
'0'
,
positioning:
notePosition
,
noteContent:
jsonEncode
(
contentMap
)
);
if
(
result
){
if
(
result
){
Toast
.
show
(
'笔记发表成功'
);
Toast
.
show
(
'笔记发表成功'
);
}
}
...
...
lib/utils/sql.dart
浏览文件 @
eb0b5081
...
@@ -38,7 +38,7 @@ class SqlManager {
...
@@ -38,7 +38,7 @@ class SqlManager {
"content TEXT, "
"content TEXT, "
"upload INTEGER, "
"upload INTEGER, "
"positioning TEXT, "
"positioning TEXT, "
"note TEXT)"
"note
_content
TEXT)"
);
);
// // 阅读章节表
// // 阅读章节表
await
db
.
execute
(
"CREATE TABLE
$kReadTable
("
await
db
.
execute
(
"CREATE TABLE
$kReadTable
("
...
@@ -100,12 +100,16 @@ class SqlManager {
...
@@ -100,12 +100,16 @@ class SqlManager {
// 插入数据
// 插入数据
static
Future
<
void
>
insertData
(
Map
<
String
,
dynamic
>
data
)
async
{
static
Future
<
bool
>
insertData
(
Map
<
String
,
dynamic
>
data
)
async
{
final
result
=
await
_database
?.
insert
(
final
result
=
await
_database
?.
insert
(
'members_book_notes'
,
'members_book_notes'
,
data
,
data
,
conflictAlgorithm:
ConflictAlgorithm
.
replace
,
conflictAlgorithm:
ConflictAlgorithm
.
replace
,
);
);
if
(
result
!=
null
){
return
true
;
}
return
false
;
Console
.
log
(
'插入数据-------------------------------
$result
'
);
Console
.
log
(
'插入数据-------------------------------
$result
'
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论