Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
07b17b5c
提交
07b17b5c
authored
1月 20, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
版本升级
上级
9dc5cafd
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
94 行增加
和
14 行删除
+94
-14
mine.dart
lib/apis/mine.dart
+3
-3
mine.dart
lib/models/mine.dart
+5
-5
index.dart
lib/pages/user_set/index.dart
+3
-0
view.dart
lib/pages/user_set/view.dart
+62
-5
access.dart
lib/utils/access.dart
+10
-0
pubspec.lock
pubspec.lock
+8
-0
pubspec.yaml
pubspec.yaml
+3
-1
没有找到文件。
lib/apis/mine.dart
浏览文件 @
07b17b5c
...
...
@@ -150,13 +150,13 @@ abstract class MineAPI {
/// 9、获取最新版本
///
static
Future
<
U
pdate
Model
>
update
()
async
{
static
Future
<
UModel
>
update
()
async
{
final
result
=
await
HttpService
.
to
.
post
(
'/v1/members/Information/getVersion'
,
params:
{},
);
if
(
result
.
data
is
!
Map
)
return
U
pdate
Model
();
return
U
pdate
Model
.
fromJson
(
result
.
data
);
if
(
result
.
data
is
!
Map
)
return
UModel
();
return
UModel
.
fromJson
(
result
.
data
);
}
/// 10、版本介绍
...
...
lib/models/mine.dart
浏览文件 @
07b17b5c
...
...
@@ -125,13 +125,13 @@ class CouponModel {
}
/// 更新模型
class
U
pdate
Model
{
U
pdate
Model
({
class
UModel
{
UModel
({
this
.
version
,
this
.
url
,
this
.
remarks
,});
U
pdate
Model
.
fromJson
(
dynamic
json
)
{
UModel
.
fromJson
(
dynamic
json
)
{
version
=
json
[
'version'
];
url
=
json
[
'url'
];
remarks
=
json
[
'remarks'
];
...
...
@@ -139,10 +139,10 @@ class UpdateModel {
String
?
version
;
String
?
url
;
String
?
remarks
;
U
pdate
Model
copyWith
({
String
?
version
,
UModel
copyWith
({
String
?
version
,
String
?
url
,
String
?
remarks
,
})
=>
U
pdate
Model
(
version:
version
??
this
.
version
,
})
=>
UModel
(
version:
version
??
this
.
version
,
url:
url
??
this
.
url
,
remarks:
remarks
??
this
.
remarks
,
);
...
...
lib/pages/user_set/index.dart
浏览文件 @
07b17b5c
library
user_set
;
import
'package:flutter/material.dart'
;
import
'package:flutter_app_update/azhon_app_update.dart'
;
import
'package:flutter_app_update/update_model.dart'
;
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_book/widgets/index.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:go_router/go_router.dart'
;
import
'package:package_info_plus/package_info_plus.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
...
...
lib/pages/user_set/view.dart
浏览文件 @
07b17b5c
...
...
@@ -8,6 +8,9 @@ class UserSetPage extends StatefulWidget {
}
class
_UserSetPageState
extends
State
<
UserSetPage
>
{
late
UModel
_getModel
;
String
url
=
"https://imtt.dd.qq.com/16891/apk/FA48766BA12A41A1D619CB4B152889C6.apk?fsname=com.estrongs.android.pop_4.2.3.3_10089.apk&csr=1bbd"
;
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
...
...
@@ -54,11 +57,7 @@ class _UserSetPageState extends State<UserSetPage> {
),
GestureDetector
(
onTap:
()
async
{
UpdateModel
model
=
await
MineAPI
.
update
();
// 有新版本
if
(
model
.
version
!=
null
){
}
_checkUpdates
();
},
child:
Container
(
color:
Colors
.
white
,
...
...
@@ -130,4 +129,62 @@ class _UserSetPageState extends State<UserSetPage> {
ClearCache
().
clearApplicationCache
();
Toast
.
show
(
'清除完成'
);
}
void
_checkUpdates
()
async
{
UModel
model
=
await
MineAPI
.
update
();
_getModel
=
model
;
final
packageInfo
=
await
PackageInfo
.
fromPlatform
();
int
getVersion
=
int
.
parse
(
model
.
version
!.
replaceAll
(
'.'
,
''
));
int
localVersion
=
int
.
parse
(
packageInfo
.
version
.
replaceAll
(
'.'
,
''
));
if
(
localVersion
<
getVersion
){
_showUpdateDialog
(
false
);
}
}
///Flutter侧处理升级对话框
///[forcedUpgrade] 是否强制升级
_showUpdateDialog
(
bool
forcedUpgrade
)
{
showDialog
(
context:
context
,
barrierDismissible:
!
forcedUpgrade
,
builder:
(
BuildContext
context
)
{
return
WillPopScope
(
onWillPop:
()
=>
Future
.
value
(!
forcedUpgrade
),
child:
AlertDialog
(
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
8.0
),
),
title:
const
Text
(
'发现新版本'
,
style:
TextStyle
(
fontSize:
16
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),),
content:
Text
(
_getModel
.
remarks
??
''
,
style:
const
TextStyle
(
fontSize:
13
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),),
actions:
<
Widget
>[
if
(!
forcedUpgrade
)
TextButton
(
child:
const
Text
(
'取消'
,
style:
TextStyle
(
color:
Colours
.
c3
),),
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(),
),
TextButton
(
child:
const
Text
(
'升级'
),
onPressed:
()
{
_appUpdate
();
if
(!
forcedUpgrade
)
{
Navigator
.
of
(
context
).
pop
();
}
},
),
],
),
);
},
);
}
/// TODO: 苹果市场app地址
_appUpdate
()
{
UpdateModel
model
=
UpdateModel
(
_getModel
.
url
!,
"zijing.apk"
,
"ic_launcher"
,
'https://itunes.apple.com/cn/app/抖音/id1142110895'
,
);
AzhonAppUpdate
.
update
(
model
).
then
((
value
)
=>
debugPrint
(
'
$value
'
));
}
}
lib/utils/access.dart
浏览文件 @
07b17b5c
part of
utils
;
abstract
class
Access
{
/// 图片权限
static
Future
<
bool
>
photos
()
async
{
if
(
Platform
.
isIOS
)
{
final
result
=
await
[
Permission
.
photos
].
request
();
...
...
@@ -14,5 +16,13 @@ abstract class Access {
return
false
;
}
/// 打开设置
static
Future
<
void
>
setting
()
async
=>
await
openAppSettings
();
/// 存储权限
static
Future
<
bool
>
storage
()
async
{
final
result
=
await
[
Permission
.
storage
].
request
();
return
result
[
Permission
.
storage
]
==
PermissionStatus
.
granted
;
}
}
pubspec.lock
浏览文件 @
07b17b5c
...
...
@@ -166,6 +166,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_app_update:
dependency: "direct main"
description:
name: flutter_app_update
sha256: "2202e6e6d49eacc571304e5a6a5404f893382b492029d01d33b3bfb9af1c2f25"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.4"
flutter_easyloading:
dependency: "direct main"
description:
...
...
pubspec.yaml
浏览文件 @
07b17b5c
...
...
@@ -93,8 +93,10 @@ dependencies:
fluwx
:
^4.4.9
#
image_picker
:
0.8.7+5
#
#
获取package 信息
package_info_plus
:
^4.2.0
# 版本更新
flutter_app_update
:
^3.0.4
dev_dependencies
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论