feat: 版本更新优化非强制更新
This commit is contained in:
@@ -81,7 +81,6 @@
|
||||
import { ref, reactive } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { gethotupdatelist } from '@/sheep/api/index/index';
|
||||
import AuthUtil from '@/sheep/api/member/auth';
|
||||
let type = ref(2);
|
||||
let formData = reactive({});
|
||||
@@ -334,67 +333,6 @@
|
||||
const windowHeight = sysInfo.windowHeight;
|
||||
let height = ref(0);
|
||||
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
||||
|
||||
const wgtUp = async () => {
|
||||
// console.log(plus.runtime);
|
||||
|
||||
let res = await gethotupdatelist();
|
||||
if (res.code !== 0) return;
|
||||
let filePath = res.data.filePath;
|
||||
let localVersion = uni.getSystemInfoSync().appWgtVersion;
|
||||
if (res.data.versionNumber != localVersion) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '发现新的版本,是否更新?',
|
||||
confirmColor: '#FA7E31',
|
||||
success: (res) => {
|
||||
downloadFile(filePath);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
const downloadFile = (url) => {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: (downloadResult) => {
|
||||
uni.showToast({
|
||||
title: '更新中....',
|
||||
icon: 'none',
|
||||
});
|
||||
if (downloadResult) {
|
||||
if (downloadResult.statusCode === 200) {
|
||||
plus.runtime.install(
|
||||
downloadResult.tempFilePath,
|
||||
{
|
||||
force: true,
|
||||
},
|
||||
function () {
|
||||
uni.showModal({
|
||||
title: '成功提示',
|
||||
content: '热更新成功,请重启应用',
|
||||
confirmColor: '#FA7E31',
|
||||
showCancel: false,
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
plus.runtime.restart(); //自动重启软件
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
function (e) {
|
||||
uni.showModal({
|
||||
title: '失败提示',
|
||||
content: e,
|
||||
showCancel: false,
|
||||
confirmColor: '#FA7E31',
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.login {
|
||||
|
||||
Reference in New Issue
Block a user