|

楼主 |
发表于 2017-10-25 16:15:51
|
显示全部楼层
修改了还是不执行。我反复调试了N次,现在在版本更新这竟然卡住了,好无语。我整理了一下,综合说一下我在版本更新这方面的操作,希望版主指点一下。我在index页面引用并修改了system/components/justep/versionChecker/versionChecker.js文件。
引用代码:- var versionChecker = require("$UI/system/components/justep/versionChecker/versionChecker");
复制代码
index页面调用方法代码:- Model.prototype.modelLoad = function(event){
- versionChecker.check();
复制代码 直接在modelload事件中一上来就进行版本检查。
versionChecker.js文件修改部分按由上到下的顺序修改了几处:
1、增加onCancel的事件处理- this.versionMsg.on('onNo', function(event) {
- // 忽略
- this.ignore();
- }, this);
- this.versionMsg.on('onCancel', function(event) {
- //取消
- this.exitApp();
- }, this);
复制代码
2、修改checkAppVersion函数的条件判断- VersionChecker.prototype.checkAppVersion = function() {
- var self = this;
- if (window.cordova && cordova.getAppVersion) {
- cordova.getAppVersion.getVersionNumber(function(currentVersion) {
- localStorage.setItem('currentVersion',
- currentVersion);
- if (self.appInfo[self.env]
- && self.versionCompare(currentVersion,
- self.appInfo[self.env].version)
- //&& window.localStorage
- //&& localStorage.getItem('versionIgnore') !== self.appInfo[self.env].version
- ) {
- self.versionMsg.show({
- type : "YesNoCancel",
- title : "版本更新",
- message : self.appInfo[self.env].changeLog
- });
- }
- });
- }
- };
复制代码 在里面把localStorage.getItem('versionIgnore') !== self.appInfo[self.env].version这个对比去掉,想达到点击忽略后再次打开软件要继续验证版本更新的效果;localStorage.setItem('currentVersion',currentVersion)将当前版本号写入本地缓存,方便后续显示使用
3、修改ignore函数,添加安卓系统退出app操作- VersionChecker.prototype.ignore = function() {
- if (window.localStorage) {
- localStorage.setItem('versionIgnore',
- this.appInfo[this.env].version);
- if(this.env == "androidApp"){
- navigator.app.exitApp();
- }
- }
- };
复制代码
4、添加exitApp函数,对应onCancel事件,里面添加安卓系统退出app操作- VersionChecker.prototype.exitApp = function(){
- if(this.env == "androidApp"){
- navigator.app.exitApp();
- }
-
- };
复制代码
现在遇到的问题:
1、版本更新包放到服务器上后首次打开软件会有版本更新提示,安卓手机点取消不会退出app;
2、版本更新包放到服务器上后首次打开软件会有版本更新提示,点忽略不会退出app;
3、版本更新包放到服务器上后首次打开软件会有版本更新提示,点忽略后再次打开app不再提示版本更新;
4、在checkAppVersion函数里添加的将当前版本号写入缓存的功能未实现,后续调用localStorage.getItem('currentVersion')值为null
总体感觉是修改了versionChecker.js文件但没生效,修改代码想要达到的功能都未实现,请版主指点一下,脑子混沌了快
|
|