Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
137e992f
提交
137e992f
authored
2月 08, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
解压
上级
7547ba58
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
97 行增加
和
57 行删除
+97
-57
controller.dart
lib/pages/read_web/controller.dart
+83
-57
index.dart
lib/pages/read_web/index.dart
+4
-0
pubspec.lock
pubspec.lock
+8
-0
pubspec.yaml
pubspec.yaml
+2
-0
没有找到文件。
lib/pages/read_web/controller.dart
浏览文件 @
137e992f
...
@@ -124,7 +124,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -124,7 +124,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 开启录音
// 开启录音
void
record
()
async
{
void
record
()
async
{
startRecording
=
true
;
startRecording
=
true
;
String
filePath
=
await
_getD
ocumentsD
irectory
();
String
filePath
=
await
_getDirectory
();
String
fileName
=
generateVoiceFileName
();
String
fileName
=
generateVoiceFileName
();
_mRecorder
.
startRecorder
(
_mRecorder
.
startRecorder
(
...
@@ -236,41 +236,41 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -236,41 +236,41 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 话题
// 话题
if
(
chatType
==
0
){
if
(
chatType
==
0
){
final
result
=
await
addDiscuss
();
final
result
=
await
addDiscuss
(
contentMap
);
return
result
;
return
result
;
}
}
// 笔记
// 笔记
else
if
(
chatType
==
1
){
else
if
(
chatType
==
1
){
final
result
=
addNote
();
final
result
=
addNote
(
contentMap
);
return
result
;
return
result
;
}
}
return
false
;
return
false
;
}
}
// 添加笔记
// 添加笔记
Future
<
bool
>
addNote
()
async
{
Future
<
bool
>
addNote
(
Map
<
String
,
dynamic
>
contentMap
)
async
{
//
// 音频链接数组
//
//
音频链接数组
List
<
String
>
audios
=
[];
//
List<String> audios = [];
// 图片链接数组
//
//
图片链接数组
List
<
String
>
images
=
[];
//
List<String> images = [];
//
// 循环上传图片获取地址
//
//
循环上传图片获取地址
for
(
String
path
in
discussInputImages
){
//
for(String path in discussInputImages){
final
url
=
await
upload
(
path:
path
);
//
final url = await upload(path: path);
images
.
add
(
url
);
//
images.add(url);
}
//
}
//
// 循环上传音频获取地址
//
//
循环上传音频获取地址
for
(
String
path
in
discussInputAudios
){
//
for(String path in discussInputAudios){
final
url
=
await
upload
(
path:
path
);
//
final url = await upload(path: path);
audios
.
add
(
url
);
//
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
};
//
};
final
result
=
await
LibraryAPI
.
addNote
(
final
result
=
await
LibraryAPI
.
addNote
(
bookId:
bookId
,
bookId:
bookId
,
...
@@ -286,29 +286,29 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -286,29 +286,29 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 发表评论
// 发表评论
// {String commentId ='0',String quoteContent ='',String title = ''}
// {String commentId ='0',String quoteContent ='',String title = ''}
Future
<
bool
>
addDiscuss
()
async
{
Future
<
bool
>
addDiscuss
(
Map
<
String
,
dynamic
>
contentMap
)
async
{
// 音频链接数组
//
//
音频链接数组
List
<
String
>
audios
=
[];
//
List<String> audios = [];
// 图片链接数组
//
//
图片链接数组
List
<
String
>
images
=
[];
//
List<String> images = [];
//
// 循环上传图片获取地址
//
//
循环上传图片获取地址
for
(
String
path
in
discussInputImages
){
//
for(String path in discussInputImages){
final
url
=
await
upload
(
path:
path
);
//
final url = await upload(path: path);
images
.
add
(
url
);
//
images.add(url);
}
//
}
//
// 循环上传音频获取地址
//
//
循环上传音频获取地址
for
(
String
path
in
discussInputAudios
){
//
for(String path in discussInputAudios){
final
url
=
await
upload
(
path:
path
);
//
final url = await upload(path: path);
audios
.
add
(
url
);
//
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
};
//
};
final
result
=
await
LibraryAPI
.
addDiscuss
(
final
result
=
await
LibraryAPI
.
addDiscuss
(
bookId:
bookId
,
bookId:
bookId
,
...
@@ -397,20 +397,46 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
...
@@ -397,20 +397,46 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
final
result
=
await
LibraryAPI
.
getbookDownloadParam
(
bookId:
bookId
);
final
result
=
await
LibraryAPI
.
getbookDownloadParam
(
bookId:
bookId
);
Console
.
log
(
'----------_getBookDown------------------
${result.download}
'
);
Console
.
log
(
'----------_getBookDown------------------
${result.download}
'
);
final
String
savePath
=
await
_getDocumentsDirectory
();
// final String savePath = await _getDirectory();
LibraryAPI
.
downBookByUrl
(
url:
result
.
download
!,
savePath:
'
$savePath$bookId
.zip'
,
onReceiveProgress:
(
int
received
,
int
total
){
// LibraryAPI.downBookByUrl(url: result.download!,savePath: '$savePath$bookId.zip',onReceiveProgress: (int received,int total){
if
(
total
!=-
1
){
// if (total !=-1){
double
progress
=
(
received
/
total
)
*
100
;
// double progress = (received / total) * 100;
Console
.
log
(
'Download progress:
$progress
%'
);
// Console.log('Download progress: $progress%');
// }
// });
extractZipFileFromCache
(
result
.
download
!);
}
Future
<
void
>
extractZipFileFromCache
(
String
url
)
async
{
// 从缓存中获取 ZIP 文件
var
file
=
await
DefaultCacheManager
().
getSingleFile
(
url
);
if
(
file
!=
null
)
{
// 读取 ZIP 文件内容
Uint8List
bytes
=
await
file
.
readAsBytes
();
// 解压缩 ZIP 文件
Archive
archive
=
ZipDecoder
().
decodeBytes
(
bytes
);
// 获取设备上的临时目录
Directory
?
tempDir
=
await
getExternalStorageDirectory
();
// 将解压缩后的文件保存到临时目录中
for
(
var
file
in
archive
)
{
if
(
file
.
isFile
)
{
String
fileName
=
file
.
name
;
String
filePath
=
'
${tempDir!.path}
/
$bookId
/
$fileName
'
;
File
(
filePath
)
..
createSync
(
recursive:
true
)
..
writeAsBytesSync
(
file
.
content
as
List
<
int
>);
print
(
'解压缩文件:
$fileName
,保存路径:
$filePath
'
);
}
}
}
});
}
else
{
print
(
'未找到缓存中的文件或文件不存在'
);
}
}
}
//获取存储目录
//获取存储目录
Future
<
String
>
_getD
ocumentsD
irectory
()
async
{
Future
<
String
>
_getDirectory
()
async
{
// getTemporaryDirectory
// getTemporaryDirectory
final
directory
=
await
getExternalStorageDirectory
();
final
directory
=
await
getExternalStorageDirectory
();
return
directory
!.
path
;
return
directory
!.
path
;
...
...
lib/pages/read_web/index.dart
浏览文件 @
137e992f
...
@@ -2,11 +2,15 @@ library web;
...
@@ -2,11 +2,15 @@ library web;
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'dart:typed_data'
;
import
'package:archive/archive.dart'
;
import
'package:audio_session/audio_session.dart'
;
import
'package:audio_session/audio_session.dart'
;
import
'package:easy_refresh/easy_refresh.dart'
;
import
'package:easy_refresh/easy_refresh.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_cache_manager/flutter_cache_manager.dart'
;
import
'package:flutter_inappwebview/flutter_inappwebview.dart'
;
import
'package:flutter_inappwebview/flutter_inappwebview.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_oss_aliyun/flutter_oss_aliyun.dart'
;
import
'package:flutter_oss_aliyun/flutter_oss_aliyun.dart'
;
...
...
pubspec.lock
浏览文件 @
137e992f
# Generated by pub
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
packages:
archive:
dependency: "direct main"
description:
name: archive
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.4.10"
args:
args:
dependency: transitive
dependency: transitive
description:
description:
...
...
pubspec.yaml
浏览文件 @
137e992f
...
@@ -109,6 +109,8 @@ dependencies:
...
@@ -109,6 +109,8 @@ dependencies:
just_audio
:
^0.9.36
just_audio
:
^0.9.36
# 缓存
# 缓存
flutter_cache_manager
:
^3.3.1
flutter_cache_manager
:
^3.3.1
# 解压
archive
:
^3.1.2
dev_dependencies
:
dev_dependencies
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论