Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 17d6557f
authored
2026-06-27 19:35:19 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化调整H5版本处理
1 parent
4bfbbcc8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
lib/bloc/web_cubit.dart
lib/config/constant.dart
lib/main.dart
lib/bloc/web_cubit.dart
View file @
17d6557
...
...
@@ -250,6 +250,7 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
// 遮罩界面
emit
(
state
.
copyWith
(
isUpgrading:
true
));
await
_downloadH5Zip
(
configVersion
,
downloadUrl
);
// 此处提前设置了新的H5业务包版本号,接下来启动本地服务的时候,解压对应版本的zip包
_setH5Version
(
configVersion
);
// 下载完成后取消遮罩,继续初始化其它数据
emit
(
state
.
copyWith
(
isUpgrading:
false
));
...
...
@@ -257,6 +258,7 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
// 后台下载,完成后提示用户
_downloadH5Zip
(
configVersion
,
downloadUrl
).
then
(
(
value
)
{
// 此处提前设置了新的H5业务包版本号,下次启动本地服务的时候,解压对应版本的zip包
_setH5Version
(
configVersion
);
emit
(
state
.
copyWith
(
suggestUpgrade:
true
));
},
...
...
lib/config/constant.dart
View file @
17d6557
...
...
@@ -52,10 +52,12 @@ class Constant {
/// app 版本号规则
static
const
String
appVersion
=
EnvConfig
.
version
;
/// H5的起始终最低版本号规则
static
String
h5Version
=
'0.2.6'
;
/// 当前的H5业务包的版本
/// 从 key=h5VersionKey 的缓存中获取,获取不到时值时,说明是第一次打开APP,则从基础业务包中读取的。
static
String
h5Version
=
'0.0.0'
;
/// H5的版本号存储的key
/// 方便升级判断处理,存储H5的版本号。下载安装包之后,会提前设置版本号,启动本地服务时,解压对应版本的zip包。
static
const
String
h5VersionKey
=
'h5_version'
;
/// 用于显示的H5版本号存储的key
...
...
lib/main.dart
View file @
17d6557
...
...
@@ -45,13 +45,17 @@ Future<void> _initH5Version() async {
var
h5Version
=
json
[
'version'
]
??
Constant
.
h5Version
;
Constant
.
h5Version
=
h5Version
;
getIt
.
get
<
SharedPreferences
>().
setString
(
Constant
.
h5ShowVersionKey
,
h5Version
);
var
sharedPreferences
=
getIt
.
get
<
SharedPreferences
>();
sharedPreferences
.
setString
(
Constant
.
h5VersionKey
,
h5Version
);
sharedPreferences
.
setString
(
Constant
.
h5ShowVersionKey
,
h5Version
);
return
;
}
}
}
catch
(
e
)
{
Constant
.
h5Version
=
'0.0.0'
;
getIt
.
get
<
SharedPreferences
>().
setString
(
Constant
.
h5ShowVersionKey
,
'0.0.0'
);
var
sharedPreferences
=
getIt
.
get
<
SharedPreferences
>();
sharedPreferences
.
setString
(
Constant
.
h5VersionKey
,
'0.0.0'
);
sharedPreferences
.
setString
(
Constant
.
h5ShowVersionKey
,
'0.0.0'
);
debugPrint
(
e
.
toString
());
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment