Commit 17d6557f by tanghuan

优化调整H5版本处理

1 parent 4bfbbcc8
......@@ -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));
},
......
......@@ -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
......
......@@ -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());
}
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!