Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
23a38b15
提交
23a38b15
authored
4月 08, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
用户退出登录 删除数据库和缓存数据
上级
59b05681
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
25 行增加
和
11 行删除
+25
-11
view.dart
lib/pages/user_set/view.dart
+1
-0
http.dart
lib/services/http.dart
+1
-0
sql.dart
lib/utils/sql.dart
+16
-10
tools.dart
lib/utils/tools.dart
+7
-1
没有找到文件。
lib/pages/user_set/view.dart
浏览文件 @
23a38b15
...
...
@@ -162,6 +162,7 @@ class _UserSetPageState extends State<UserSetPage> {
// Toast.show('退出成功');
CustomToast
.
loading
();
await
UserStore
.
to
.
logout
();
await
Tools
.
clearData
();
CustomToast
.
dismiss
();
if
(
context
.
mounted
)
{
context
.
goNamed
(
Routes
.
splash
);
...
...
lib/services/http.dart
浏览文件 @
23a38b15
...
...
@@ -270,6 +270,7 @@ class _RequestInterceptor extends Interceptor {
}
else
{
UserStore
.
to
.
logout
();
await
Tools
.
clearData
();
CustomToast
.
fail
(
'该账号已在其他设备登录,请重新登录'
);
Console
.
log
(
'-------------------access_token-------------------------
${UserStore.to.accessToken}
--------------------'
);
...
...
lib/utils/sql.dart
浏览文件 @
23a38b15
...
...
@@ -71,14 +71,14 @@ class SqlManager {
Map
<
String
,
dynamic
>
returnMap
=
{};
// 划线
List
<
Map
<
String
,
dynamic
>>?
lineResult
=
await
db
?.
query
(
'members_book_notes'
,
kNoteTable
,
columns:
[
'types'
,
'chapter_id'
,
'positioning'
,
'content'
,
'color'
,
'id'
],
where:
'book_id = ? and chapter_id = ? and types = ? and del = ?'
,
whereArgs:
[
bookId
,
chapterId
,
1
,
0
],
);
// 高亮
List
<
Map
<
String
,
dynamic
>>?
colorResult
=
await
db
?.
query
(
'members_book_notes'
,
kNoteTable
,
columns:
[
'types'
,
'chapter_id'
,
'positioning'
,
'content'
,
'color'
,
'id'
],
where:
'book_id = ? and chapter_id = ? and types = ? and del = ?'
,
whereArgs:
[
bookId
,
chapterId
,
2
,
0
],
...
...
@@ -93,7 +93,7 @@ class SqlManager {
static
Future
<
int
>
addLocalNote
(
Map
<
String
,
dynamic
>
data
)
async
{
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
final
result
=
await
db
?.
insert
(
'members_book_notes'
,
kNoteTable
,
data
,
conflictAlgorithm:
ConflictAlgorithm
.
replace
,
);
...
...
@@ -105,7 +105,7 @@ class SqlManager {
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
if
(
noteId
==
0
){
final
result
=
await
db
?.
update
(
'members_book_notes'
,
kNoteTable
,
{
'del'
:
1
},
where:
'id = ?'
,
whereArgs:
[
id
],
...
...
@@ -114,7 +114,7 @@ class SqlManager {
}
else
{
final
result
=
await
db
?.
update
(
'members_book_notes'
,
kNoteTable
,
{
'del'
:
1
},
where:
'notes_id = ?'
,
whereArgs:
[
noteId
],
...
...
@@ -129,7 +129,7 @@ class SqlManager {
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
if
(
notesId
==
0
){
final
result
=
await
db
?.
update
(
'members_book_notes'
,
kNoteTable
,
data
,
where:
'id = ?'
,
whereArgs:
[
id
],
...
...
@@ -138,7 +138,7 @@ class SqlManager {
}
else
{
final
result
=
await
db
?.
update
(
'members_book_notes'
,
kNoteTable
,
data
,
where:
'notes_id = ?'
,
whereArgs:
[
notesId
],
...
...
@@ -152,7 +152,7 @@ class SqlManager {
static
Future
<
List
<
Map
<
String
,
dynamic
>>>
queryNoUploadData
()
async
{
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
List
<
Map
<
String
,
dynamic
>>?
results
=
await
db
?.
query
(
'members_book_notes'
,
kNoteTable
,
where:
'upload = ? and del = ?'
,
whereArgs:
[
0
,
0
],
);
...
...
@@ -163,11 +163,12 @@ class SqlManager {
// );
return
results
??[];
}
// 将所有 upload 为 0 的数据的 upload 字段值更新为 1
static
Future
<
void
>
updateUploadStatus
()
async
{
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
final
result
=
await
db
?.
update
(
'members_book_notes'
,
kNoteTable
,
{
'upload'
:
1
},
where:
'upload = ?'
,
whereArgs:
[
0
],
...
...
@@ -199,6 +200,11 @@ class SqlManager {
await
db
?.
execute
(
sql
);
}
static
Future
<
void
>
clear
()
async
{
Database
?
db
=
await
SqlManager
.
getCurrentDatabase
();
db
?.
delete
(
kNoteTable
);
db
?.
delete
(
kReadTable
);
}
// 根据 book_id 查询当前读到的 章节
static
Future
<
String
>
queryReadHistoryByBookId
(
int
bookId
)
async
{
try
{
...
...
@@ -207,7 +213,7 @@ class SqlManager {
await
init
();
}
List
<
Map
<
String
,
dynamic
>>?
results
=
await
db
?.
query
(
'read_history'
,
kReadTable
,
where:
'book_id = ?'
,
whereArgs:
[
bookId
],
);
...
...
lib/utils/tools.dart
浏览文件 @
23a38b15
...
...
@@ -38,7 +38,7 @@ abstract class Tools {
static
Future
<
String
>
getDirectory
()
async
{
// getTemporaryDirectory
final
directory
=
await
get
ExternalStorage
Directory
();
final
directory
=
await
get
Temporary
Directory
();
return
directory
!.
path
;
}
...
...
@@ -49,6 +49,12 @@ abstract class Tools {
return
'voice_
$formattedDate
.mp4'
;
}
static
Future
<
void
>
clearData
()
async
{
await
SqlManager
.
clear
();
ClearCache
().
clearApplicationCache
();
Console
.
log
(
'-------------清除数据-------------------'
);
}
// 判断当前网络状态
static
Future
<
bool
>
checkCurrentNetStatus
()
async
{
final
connectivityResult
=
await
(
Connectivity
().
checkConnectivity
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论