1.0.2修复版 增加演示

This commit is contained in:
滕亚庆 2018-08-24 08:57:06 +08:00
parent e2e84bd5e1
commit 85a578a686
3 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,6 @@
# hotfix[查看文档](https://tyaqing.github.io/mogo-h5plus/hotfix/introduction.html)
让您的Hbuilder APP应用快速拥有更新能力.
## [演示APK](https://fir.im/p52j)
## 开发Hbuilder应用 推荐使用[MogoH5+](https://github.com/tyaqing/mogo-h5plus)

View File

@ -1,6 +1,6 @@
{
"name": "h5plus-hotfix",
"version": "1.0.1",
"version": "1.0.2",
"description": "让您的Hbuilder APP应用快速拥有更新能力.",
"main": "src/hotfix.js",
"scripts": {

View File

@ -3,8 +3,6 @@ export default function ({ url, success, error, before, onProgress }) {
if (!(url && typeof url === 'string')) throw "url 必须填写 类型为string";
if (!(success && typeof success === 'function')) throw "success必须填写 类型为function";
if (!(before && typeof before === 'function')) throw "before必须填写 类型为function"
if (!onProgress) onProgress = function () { };
if (!error) error = function () { };
// 对环境的要求
let resData;
getProperty().then((inf) => {
@ -26,7 +24,9 @@ export default function ({ url, success, error, before, onProgress }) {
return installWgt(localPath);
}).then(() => {
success();
}).catch(error)
}).catch((e) => {
error && error()
})
}
// 下载wgt文件
function downWgt(url, onProgress) {
@ -42,7 +42,7 @@ function downWgt(url, onProgress) {
}
})
dtask.addEventListener("statechanged", function (task, status) {
onProgress(Number.parseInt(task.downloadedSize / task.totalSize * 100));
onProgress && onProgress(Number.parseInt(task.downloadedSize / task.totalSize * 100));
});
dtask.start();
})