App.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import 'uview-ui/index.scss';
  4. @import './style/common.scss';
  5. image {
  6. image-rendering: -moz-crisp-edges;
  7. image-rendering: -o-crisp-edges;
  8. image-rendering: -webkit-optimize-contrast;
  9. image-rendering: crisp-edges;
  10. -ms-interpolation-mode: nearest-neighbor;
  11. }
  12. </style>
  13. <script>
  14. import store from './store'
  15. export default {
  16. onLaunch: function () {
  17. console.log('App Launch')
  18. },
  19. onShow: function () {
  20. const updateManager = uni.getUpdateManager()
  21. updateManager.onCheckForUpdate(function (res) {
  22. // 请求完新版本信息的回调
  23. if (res.hasUpdate) {
  24. updateManager.onUpdateReady(function () {
  25. uni.showModal({
  26. title: '更新提示',
  27. content: '发现新版本,是否重启应用?',
  28. cancelColor: '#eeeeee',
  29. confirmColor: '#FF0000',
  30. success(resp) {
  31. if (resp.confirm) {
  32. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  33. updateManager.applyUpdate()
  34. }
  35. },
  36. })
  37. })
  38. }
  39. })
  40. updateManager.onUpdateFailed(function (res) {
  41. // 新的版本下载失败
  42. uni.showModal({
  43. title: '提示',
  44. content: '检查到有新版本,但下载失败,请检查网络设置',
  45. success(res) {
  46. if (res.confirm) {
  47. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  48. updateManager.applyUpdate()
  49. }
  50. },
  51. })
  52. })
  53. store.dispatch('getUserInfo')
  54. },
  55. onHide: function () {
  56. },
  57. }
  58. </script>