Ibm mobilefirst Android Worklight初始化始终清除WebView历史记录

Ibm mobilefirst Android Worklight初始化始终清除WebView历史记录,ibm-mobilefirst,Ibm Mobilefirst,我注意到每次在Android应用程序中初始化Worklight/Cordova时都会调用cordovaInitCallback。特别是,它将科尔多瓦的“clearHistory”称为清除WebView历史。当我尝试在多页应用程序中使用window.history时,这一直是一个问题,因为在从一页到另一页的初始化过程中,历史总是被重置 由于该评论表明,此clearHistory调用的目的是防止在直接更新场景中返回到旧页面,因此该条件是否可以通过Android环境检查得到加强,以便仅在直接更新刚刚发

我注意到每次在Android应用程序中初始化Worklight/Cordova时都会调用cordovaInitCallback。特别是,它将科尔多瓦的“clearHistory”称为清除WebView历史。当我尝试在多页应用程序中使用window.history时,这一直是一个问题,因为在从一页到另一页的初始化过程中,历史总是被重置

由于该评论表明,此clearHistory调用的目的是防止在直接更新场景中返回到旧页面,因此该条件是否可以通过Android环境检查得到加强,以便仅在直接更新刚刚发生时调用它?例如,我能想到的一种情况是,当connectOnStartup=false时,将不会发生直接更新

wlclient.js:

 var cordovaInitCallback = function(returnedData) {
            onEnvInit(options);
            if (WL.Client.getEnvironment() == WL.Env.ANDROID) {
                if (returnedData !== null && returnedData !== "") {
                    WL.StaticAppProps.APP_VERSION = returnedData;
                }
                // In development mode, the application has a settings
                // widget in which the user may alter
                // the application's root url
                // and here the application reads this url, and replaces the
                // static prop
                // WL.StaticAppProps.WORKLIGHT_ROOT_URL
                // __setWLServerAddress for iOS is called within
                // wlgap.ios.js's wlCheckReachability
                // function because it is an asynchronous call.

                // Only in Android we should clear the history of the
                // WebView, otherwise when user will
                // press the back button after upgrade he will return to the
                // html page before the upgrade
                if (**WL.Env.ANDROID == getEnv()**) {
                    cordova.exec(null, null, 'Utils', 'clearHistory', []);
                }
            }
我目前正在使用Worklight 5.0.5,并检查了5.0.5.1中存在的相同条件


谢谢

Worklight的架构设计是SPA(单页应用)。
cordovaInitCallback
在应用程序的生命周期中只能调用一次。

也就是说,如果你愿意,你可以重写它。

工作灯是用单页应用程序开发的,如果你的主HTML页面上有太多的标记,你应该考虑在HTML主文件中动态填充HTML标记。您可以重写JavaScript中的函数,例如:
console.log=function(){return'hello'}
。现在console.log将只返回“hello”,而不是默认行为。一个选项(我并不推荐)是重写其中一个函数或对象(WL.Env.ANDROID='hello')。请注意,这不是一个答案,只是一个旁注:)。