update.ts 740 B

123456789101112131415161718192021222324252627
  1. export function checkUpdate() {
  2. const { scene } = uni.getEnterOptionsSync();
  3. // 从朋友圈单页模式打开页面
  4. if (scene === 1154) {
  5. return;
  6. }
  7. const updateManager = uni.getUpdateManager();
  8. updateManager.onCheckForUpdate(res => {});
  9. updateManager.onUpdateReady(() => {
  10. uni.showModal({
  11. title: '更新提示',
  12. content: '新版本已经准备好,是否重启应用?',
  13. success(res) {
  14. if (res.confirm) {
  15. updateManager.applyUpdate();
  16. }
  17. }
  18. });
  19. });
  20. updateManager.onUpdateFailed((error) => {
  21. uni.showModal({
  22. title: '更新失败',
  23. content: '请删除小程序后重新打开'
  24. });
  25. });
  26. }