当前位置:网站首页>uniapp 移动端强制更新功能
uniapp 移动端强制更新功能
2022-07-07 04:56:00 【涛涛之海】
uniapp 移动端强制更新功能
背景
最近,考虑到移动端版本的迭代升级,需要有强制更新的功能,整体逻辑比较简单,我之前没有做过,于是简单记录一下。
前端
需要一打开移动端的app,就要进行版本号的判断,所以需要在app.vue 文件中的 onLaunch()方法中写代码逻辑。
// 强制更新
//#ifdef APP-PLUS
this.$u.api.update({
appid: plus.runtime.appid,
version: plus.runtime.versionCode
})
.then(res => {
console.log(res);
console.log(plus.runtime.appid);
console.log(plus.runtime.versionCode);
console.log(res.status);
if (res.status == 1) {
uni.showModal({ //提醒用户更新
title: "更新提示",
showCancel: false, // 将取消按钮隐藏
content: res.note,
buttonText: '确定',
success: (rese) => {
if (rese.confirm) {
plus.runtime.openURL(res.url); // 调用手机端的浏览器 进行下载
}
}
})
}
});
//#endif
后端
/**
* 强制 更新校验
* @param appid
* @param version
* @return
*/
@RequestMapping("/update")
public ResponseEntity<Map<String, String>> update(String appid, String version) {
Map<String, String> map = new HashMap<>();
// 获取数据库中存放的升级版本,升级内容以及下载链接
AppUpdateApk appUpdateApk = appUpdateApkService.findNew();
String mVersion = appUpdateApk.getVersionNumber();
// 移动端的版本号 与数据库最新的版本号进行比对
if(mVersion.equals(version)){
map.put("status","0");
}else{
// 不同的进行提醒
map.put("status","1");
map.put("note",appUpdateApk.getUpdateContent());
map.put("url",appUpdateApk.getUrl());
}
return ResponseEntity.ok(map);
}
最后
我相信肯定还有其他比较好的方法,欢迎大家留言,一起相互学习。
边栏推荐
- 大视频文件的缓冲播放原理以及实现
- Force buckle 145 Binary Tree Postorder Traversal
- Codeforces Global Round 19
- 2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
- Yugu p1020 missile interception (binary search)
- Thinkcmf6.0安装教程
- paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
- Main window in QT learning 27 application
- Record a stroke skin bone error of the skirt
- Value sequence (subsequence contribution problem)
猜你喜欢
Qt学习27 应用程序中的主窗口
You Li takes you to talk about C language 6 (common keywords)
Few-Shot Learning && Meta Learning:小样本学习原理和Siamese网络结构(一)
Problem solving: unable to connect to redis
LeetCode简单题之判断一个数的数字计数是否等于数位的值
Explore dry goods! Apifox construction ideas
Most elements
Linux server development, redis protocol and asynchronous mode
自定义类加载器加载网络Class
2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers
随机推荐
dash plotly
力扣(LeetCode)187. 重复的DNA序列(2022.07.06)
Codeforces Global Round 19
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
自定义类加载器加载网络Class
Common validation comments
Zhilian + AV, AITO asked M7 to do more than ideal one
Chip information website Yite Chuangxin
【数字IC验证快速入门】11、Verilog TestBench(VTB)入门
Visualization Document Feb 12 16:42
Linux server development, MySQL transaction principle analysis
Explore dry goods! Apifox construction ideas
Bugku CTF daily one question chessboard with only black chess
Pytest+allure+jenkins installation problem: pytest: error: unrecognized arguments: --alluredir
Li Kou interview question 04.01 Path between nodes
PHP exports millions of data
Info | webrtc M97 update
json 数据展平pd.json_normalize
芯片资料 网站 易特创芯
[mathematical notes] radian