index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const useGetUpdateManager = () => {
  4. return new Promise((resolve, reject) => {
  5. common_vendor.index.getUpdateManager().onCheckForUpdate(function(res) {
  6. if (res.hasUpdate) {
  7. common_vendor.index.getUpdateManager().onUpdateReady(function() {
  8. common_vendor.index.showModal({
  9. title: "更新提示",
  10. content: "新版本已经准备好,单击确定重启应用",
  11. showCancel: false,
  12. success: function(res2) {
  13. if (res2.confirm) {
  14. common_vendor.index.getUpdateManager().applyUpdate();
  15. }
  16. }
  17. });
  18. });
  19. common_vendor.index.getUpdateManager().onUpdateFailed(function() {
  20. common_vendor.index.showModal({
  21. title: "提示",
  22. content: "检查到有新版本,但下载失败,请检查网络设置",
  23. showCancel: false
  24. });
  25. });
  26. }
  27. resolve(res.hasUpdate);
  28. });
  29. });
  30. };
  31. exports.useGetUpdateManager = useGetUpdateManager;
  32. //# sourceMappingURL=../../../.sourcemap/mp-alipay/hook/use-get-update-manager/index.js.map