容器版本判断

框架提供了版本判断函数,可以针对某些不支持的功能进行特殊处理。

  1. import { system, compareVersion } from 'waft';
  2. /**
  3. {
  4. "screenWidth":1280,
  5. "screenHeight":800,
  6. "pixelRatio":1.25,
  7. "platform":"Android",
  8. "system":"6.1.8-D-20201202.2128",
  9. "version":"1.1.191",
  10. "versionCode":191,
  11. "app":"com.alibaba.genie.waft",
  12. "sdkVersion":"0.3",
  13. "sdkVersionCode":3,
  14. "model":"AILABS_S3",
  15. "brand":"alps"
  16. }
  17. */
  18. const version = system.getSystemInfoCache().version;
  19. // 某功能只在 >= 1.5 versionCode后生效
  20. const result = compareVersion(version, "1.5");
  21. // 大于等于该版本,生效
  22. if(result >= 0){
  23. }

最低运行的容器版本限定

如果应用核心功能都无法在某版本以下运行,建议设置最低版本的字段。
在app.json中,配置minVersion字段可以限制最低版本容器:

{
  "pages": [
    "pages/index/index",
    "pages/waft-index/waft-index"
  ],
  "default": "pages/index/index",
  "viewport":{
    "width": 1024,
    "height": 600,
    "scaleMode": "fixedHeight"
  },
  "minVersion": "1.3"
}

在不支持的版本中,将会对用户出现升级页面。(后续会加入点击升级的按钮)
image.png