Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
apk_update
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
apk_update
Commits
b1147346
提交
b1147346
authored
7月 01, 2025
作者:
史晓晨
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:①支持替换更新弹框顶部图片②优化oss下载信息判断逻辑③修改各环境oss信息获取接口传参
上级
8d5c32ae
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
48 行增加
和
9 行删除
+48
-9
update_head.png
assets/images/update_head.png
+0
-0
update_head.png
example/assets/images/update_head.png
+0
-0
main.dart
example/lib/main.dart
+2
-0
app_upgrade_control.dart
lib/app_upgrade_control.dart
+1
-0
app_upgrade_config.dart
lib/core/common/app_upgrade_config.dart
+6
-0
oss_download_impl.dart
...ore/services/download_service/impl/oss_download_impl.dart
+16
-1
image_utils.dart
lib/utils/image_utils.dart
+3
-4
utils.dart
lib/utils/utils.dart
+12
-0
update_dialog.dart
lib/widget/update_dialog.dart
+6
-1
pubspec.yaml
pubspec.yaml
+2
-3
没有找到文件。
assets/images/update_head.png
0 → 100644
浏览文件 @
b1147346
13.8 KB
example/assets/images/update_head.png
查看替换文件 @
8d5c32ae
浏览文件 @
b1147346
13.8 KB
|
W:
|
H:
37.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
example/lib/main.dart
浏览文件 @
b1147346
import
'package:apk_update/app_upgrade_factory.dart'
;
import
'package:apk_update/app_upgrade_factory.dart'
;
import
'package:apk_update/core/common/app_upgrade_config.dart'
;
import
'package:apk_update/core/common/app_upgrade_config.dart'
;
import
'package:apk_update/utils/image_utils.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
...
@@ -99,6 +100,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -99,6 +100,7 @@ class _MyAppState extends State<MyApp> {
appleId:
"1585610919"
,
appleId:
"1585610919"
,
headers:
{
"product-code"
:
"carrier-driver-app"
,
"model"
:
"TASal00"
},
headers:
{
"product-code"
:
"carrier-driver-app"
,
"model"
:
"TASal00"
},
versionNumber:
1
,
versionNumber:
1
,
topImageProvider:
ImageUtils
.
getAssetImage
(
'update_head'
)
),
),
);
);
...
...
lib/app_upgrade_control.dart
浏览文件 @
b1147346
...
@@ -43,6 +43,7 @@ class AppUpgradeControl {
...
@@ -43,6 +43,7 @@ class AppUpgradeControl {
title:
versionInfo
.
name
,
title:
versionInfo
.
name
,
content:
versionInfo
.
content
,
content:
versionInfo
.
content
,
versionForce:
versionInfo
.
versionForce
==
true
,
versionForce:
versionInfo
.
versionForce
==
true
,
topImageProvider:
config
.
topImageProvider
,
onAppMarket:
(
String
?
url
)
{
onAppMarket:
(
String
?
url
)
{
if
(
Platform
.
isIOS
)
{
if
(
Platform
.
isIOS
)
{
jumpAppStore
(
appleId
??
""
);
jumpAppStore
(
appleId
??
""
);
...
...
lib/core/common/app_upgrade_config.dart
浏览文件 @
b1147346
import
'package:flutter/material.dart'
;
/// 配置类
/// 配置类
class
AppUpgradeConfig
{
class
AppUpgradeConfig
{
/// 域名
/// 域名
...
@@ -27,6 +29,9 @@ class AppUpgradeConfig {
...
@@ -27,6 +29,9 @@ class AppUpgradeConfig {
/// 增加请求头
/// 增加请求头
final
Map
<
String
,
dynamic
>?
headers
;
final
Map
<
String
,
dynamic
>?
headers
;
/// 顶部图片
final
ImageProvider
?
topImageProvider
;
const
AppUpgradeConfig
({
const
AppUpgradeConfig
({
required
this
.
baseUrl
,
required
this
.
baseUrl
,
this
.
onceDay
=
false
,
this
.
onceDay
=
false
,
...
@@ -37,5 +42,6 @@ class AppUpgradeConfig {
...
@@ -37,5 +42,6 @@ class AppUpgradeConfig {
this
.
productNo
,
this
.
productNo
,
this
.
type
,
this
.
type
,
this
.
headers
,
this
.
headers
,
this
.
topImageProvider
,
});
});
}
}
lib/core/services/download_service/impl/oss_download_impl.dart
浏览文件 @
b1147346
...
@@ -46,8 +46,13 @@ class OSSDownloadImpl implements DownloadService {
...
@@ -46,8 +46,13 @@ class OSSDownloadImpl implements DownloadService {
onSuccess
?.
call
(
apkFile
.
path
);
onSuccess
?.
call
(
apkFile
.
path
);
return
;
return
;
}
}
// 删除历史下载文件
await
deleteFiles
(
Directory
(
path
));
var
ossInfo
=
await
getOssInfo
();
var
ossInfo
=
await
getOssInfo
();
if
(
ossInfo
==
null
)
{
ToastUtil
.
showToast
(
"oss下载失败"
);
return
;
}
// 使用OSS下载
// 使用OSS下载
var
ak
=
ossInfo
?[
'onceAccessKeyId'
];
var
ak
=
ossInfo
?[
'onceAccessKeyId'
];
var
sk
=
ossInfo
?[
"onceAccessKeySecret"
];
var
sk
=
ossInfo
?[
"onceAccessKeySecret"
];
...
@@ -118,4 +123,14 @@ class OSSDownloadImpl implements DownloadService {
...
@@ -118,4 +123,14 @@ class OSSDownloadImpl implements DownloadService {
String
getPathByObjectKey
(
String
url
)
{
String
getPathByObjectKey
(
String
url
)
{
return
p
.
dirname
(
url
);
return
p
.
dirname
(
url
);
}
}
/// 获取oss bucketName
String
getOssBucketName
()
{
if
(
baseUrl
.
contains
(
"gateway.devclx.cn"
)
||
baseUrl
.
contains
(
"gateway.testclx.cn"
))
{
return
"clx-dev"
;
}
else
{
return
"clx-prod"
;
}
}
}
}
lib/utils/image_utils.dart
浏览文件 @
b1147346
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
class
ImageUtils
{
class
ImageUtils
{
static
ImageProvider
getNetworkImage
(
String
name
,
{
String
format
=
'png'
})
{
static
ImageProvider
getNetworkImage
(
String
name
,
{
String
format
=
'png'
})
{
return
NetworkImage
(
name
);
return
NetworkImage
(
name
);
}
}
static
ImageProvider
getAssetImage
(
String
name
,
{
String
format
=
'png'
})
{
static
ImageProvider
getAssetImage
(
String
name
,
return
AssetImage
(
getImgPath
(
name
,
format:
format
));
{
String
format
=
'png'
,
String
?
package
})
{
return
AssetImage
(
getImgPath
(
name
,
format:
format
),
package:
package
);
}
}
static
String
getImgPath
(
String
?
name
,
{
String
format
=
'png'
})
{
static
String
getImgPath
(
String
?
name
,
{
String
format
=
'png'
})
{
...
...
lib/utils/utils.dart
浏览文件 @
b1147346
import
'dart:io'
;
import
'package:flustars_flutter3/flustars_flutter3.dart'
;
import
'package:flustars_flutter3/flustars_flutter3.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get.dart'
;
import
'package:url_launcher/url_launcher.dart'
;
import
'package:url_launcher/url_launcher.dart'
;
...
@@ -11,6 +13,16 @@ Future<String?> createDir() async {
...
@@ -11,6 +13,16 @@ Future<String?> createDir() async {
return
path
;
return
path
;
}
}
Future
<
void
>
deleteFiles
(
Directory
directory
,
{
String
suffix
=
".apk"
})
async
{
if
(!
await
directory
.
exists
())
return
;
await
for
(
var
entity
in
directory
.
list
(
recursive:
true
))
{
if
(
entity
is
File
&&
entity
.
path
.
toLowerCase
().
endsWith
(
suffix
))
{
await
entity
.
delete
();
}
}
}
/// 打开浏览器
/// 打开浏览器
Future
<
void
>
openBrowser
(
String
stringUrl
)
async
{
Future
<
void
>
openBrowser
(
String
stringUrl
)
async
{
final
Uri
url
=
Uri
.
parse
(
stringUrl
);
final
Uri
url
=
Uri
.
parse
(
stringUrl
);
...
...
lib/widget/update_dialog.dart
浏览文件 @
b1147346
...
@@ -24,6 +24,9 @@ class AppUpgradeDialog extends StatelessWidget {
...
@@ -24,6 +24,9 @@ class AppUpgradeDialog extends StatelessWidget {
/// 跳转应用市场
/// 跳转应用市场
final
ValueChanged
<
String
?>?
onAppMarket
;
final
ValueChanged
<
String
?>?
onAppMarket
;
/// 顶部图片
final
ImageProvider
?
topImageProvider
;
AppUpgradeDialog
({
AppUpgradeDialog
({
Key
?
key
,
Key
?
key
,
this
.
title
,
this
.
title
,
...
@@ -31,6 +34,7 @@ class AppUpgradeDialog extends StatelessWidget {
...
@@ -31,6 +34,7 @@ class AppUpgradeDialog extends StatelessWidget {
this
.
versionForce
=
false
,
this
.
versionForce
=
false
,
this
.
onDownLoad
,
this
.
onDownLoad
,
this
.
onAppMarket
,
this
.
onAppMarket
,
this
.
topImageProvider
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
@override
@override
...
@@ -119,7 +123,8 @@ class AppUpgradeDialog extends StatelessWidget {
...
@@ -119,7 +123,8 @@ class AppUpgradeDialog extends StatelessWidget {
topRight:
Radius
.
circular
(
8.0
),
topRight:
Radius
.
circular
(
8.0
),
),
),
image:
DecorationImage
(
image:
DecorationImage
(
image:
ImageUtils
.
getAssetImage
(
'update_head'
),
image:
topImageProvider
??
ImageUtils
.
getAssetImage
(
'update_head'
,
package:
"apk_update"
),
fit:
BoxFit
.
cover
,
fit:
BoxFit
.
cover
,
),
),
),
),
...
...
pubspec.yaml
浏览文件 @
b1147346
...
@@ -55,9 +55,8 @@ flutter:
...
@@ -55,9 +55,8 @@ flutter:
pluginClass
:
ApkUpdatePlugin
pluginClass
:
ApkUpdatePlugin
# To add assets to your plugin package, add an assets section, like this:
# To add assets to your plugin package, add an assets section, like this:
# assets:
assets
:
# - images/a_dot_burr.jpeg
-
assets/images/
# - images/a_dot_ham.jpeg
#
#
# For details regarding assets in packages, see
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
# https://flutter.dev/assets-and-images/#from-packages
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论