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 c0a638b5
authored
2026-04-30 09:43:09 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化版本检测
1 parent
2d28f8c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
lib/bloc/web_cubit.dart
lib/bloc/web_cubit.dart
View file @
c0a638b
...
...
@@ -1310,10 +1310,10 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
bool
_hasBeenResumed
=
false
;
/// 版本检测并发控制标志
bool
_isCheckingVersion
OfH5
=
false
;
bool
_isCheckingVersion
=
false
;
/// H5资源已下载标志(本次生命周期内)
bool
_hasDownloadedH5
=
false
;
//
bool _hasDownloadedH5 = false;
/// APP版本检测上次执行时间(2小时内只执行一次)
DateTime
?
_lastAppVersionCheckTime
;
...
...
@@ -1324,16 +1324,18 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
/// 检测或下载中时不重复处理
///
Future
<
void
>
_checkVersionUpgrade
()
async
{
if
(
_isCheckingVersion
OfH5
||
_hasDownloadedH5
)
{
if
(
_isCheckingVersion
/*|| _hasDownloadedH5*/
)
{
return
;
}
_isCheckingVersion
OfH5
=
true
;
_isCheckingVersion
=
true
;
try
{
var
curVersion
=
getIt
.
get
<
SharedPreferences
>().
getString
(
Constant
.
h5VersionKey
)
??
Constant
.
h5Version
;
var
versionConfig
=
await
_getVersionConfig
();
var
configVersion
=
versionConfig
[
'version'
]
as
String
;
var
downloadUrl
=
versionConfig
[
'zip'
]
as
String
;
var
appversionCheck
=
versionConfig
[
'appversionCheck'
]
as
String
;
var
appversionAndroid
=
versionConfig
[
'appversionAndroid'
]
as
String
;
var
appversionIos
=
versionConfig
[
'appversionIos'
]
as
String
;
...
...
@@ -1346,6 +1348,11 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
emit
(
state
.
copyWith
(
suggestAppUpgrade:
true
));
}
_lastAppVersionCheckTime
=
now
;
// 重置标志
_isCheckingVersion
=
false
;
// 提示了APP升级后,不再进行H5版本检测
return
;
}
}
...
...
@@ -1354,16 +1361,16 @@ class WebCubit extends Cubit<WebState> with WidgetsBindingObserver {
final
capturedConfigVersion
=
configVersion
;
_downloadH5Zip
(
capturedConfigVersion
,
downloadUrl
).
then
((
_
)
{
_setH5Version
(
capturedConfigVersion
);
_hasDownloadedH5
=
true
;
//
_hasDownloadedH5 = true;
emit
(
state
.
copyWith
(
suggestUpgrade:
true
));
}).
catchError
((
e
)
{
debugPrint
(
'后台H5资源下载失败
$e
'
);
}).
whenComplete
(()
{
_isCheckingVersion
OfH5
=
false
;
_isCheckingVersion
=
false
;
});
}
else
{
// 不需要下载时,立即重置标志
_isCheckingVersion
OfH5
=
false
;
_isCheckingVersion
=
false
;
}
}
catch
(
e
)
{
debugPrint
(
'后台H5版本检测失败
$e
'
);
...
...
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