首页 > 解决方案 > 用于 Windows 10 的 Cordova 应用程序在代理后面启动时卡在启动画面上

问题描述

我有一个 Cordova 应用程序在连接到互联网的多个设备上运行良好。

观察到的行为:

但是当我在我们的开发环境虚拟机上部署应用程序时,它只是在闪屏上冻结。我注意到的一件奇怪的事情是,每次我启动浏览器时,它都会要求我登录代理服务器。这是因为代理使用我的生产凭据进行身份验证。凭据保存在浏览器中,我只需单击确定。我觉得应用程序无法启动,因为 web 视图正在等待代理登录提示被操作,这在启动时显然是不可见的。该应用程序只是坐在那里,直到它关闭。

此外,当我使用 VS2017 在调试模式下运行应用程序时, index.html 文件只加载了 head 标签,没有 body 标签

所有库和脚本都在 head 选项卡中本地引用,因为该应用程序也可以离线工作。下面的头部示例。

配置:

索引.html

    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
    <link rel="stylesheet" href="css/jquery-ui.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="scripts/datepicker/bootstrap-datetimepicker.min.css">
    <link rel="stylesheet" href="scripts/daterangepicker/daterangepicker.css">
    <link rel="stylesheet" href="scripts/timepicker/bootstrap-timepicker.min.css">
    <link rel="stylesheet" href="scripts/easyautocomplete/easy-autocomplete.css">
    <link href="scripts/growl/jquery.growl.css" rel="stylesheet" type="text/css" />
    <link href="scripts/jquery-confirm/jquery-confirm.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/SHMOStyles.css" />
    <link rel="stylesheet" href="css/ripple.min.css">
    <script type="text/javascript" src="scripts/jquery-2.2.3.min.js"></script>
    <script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
    <script type="text/javascript" src="scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="scripts/fastclick.js"></script>
    <script type="text/javascript" src="mapapi.js"></script>
    <script type="text/javascript" src="scripts/index.js"></script>
    <script type="text/javascript" src="scripts/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="scripts/dataTables.bootstrap.min.js"></script>
    <script type="text/javascript" src="scripts/hammer.min.js"></script>

我在 config.xml 中使用了一些插件,但是当我在生产环境或任何直接连接到 Internet 的设备中运行它们时,它们中的任何一个都没有问题。在生产中,它使用相同的凭据进行计算机登录和代理,因此我不会像在 Dev env 中那样获得登录提示。

配置文件

<vs:platformSpecificValues>
    <vs:platformSpecificWidget platformName="windows" id="SIMSMobileV0" />
  </vs:platformSpecificValues>
  <plugin name="cordova-plugin-fastclick" spec="~1.0.0" />
  <plugin name="cordova-plugin-file-opener2" spec="~2.0.19" />
  <plugin name="cordova-sqlite-storage" spec="~2.3.1" />
  <plugin name="cordova-plugin-camera" spec="~2.4.1" />
  <plugin name="cordova-plugin-device" spec="~2.0.2" />
  <plugin name="cordova-plugin-network-information" spec="~2.0.1" />
  <plugin name="cordova-plugin-splashscreen" spec="~5.0.2" />
  <plugin name="cordova-plugin-file" spec="~6.0.1" />
  <plugin name="cordova-plugin-zeep" spec="~0.0.4" />
  <plugin name="cordova-plugin-file" spec="~6.0.1" />
  <plugin name="cordova-plugin-geolocation" spec="~4.0.1" />
  <plugin name="cordova-plugin-insomnia" spec="~4.3.0" />

我尝试过的事情:

  1. 覆盖 Windows 10 VM 上的代理设置,仍然会导致提示出现

  2. 将凭据保存在 Windows/代理主机的通用凭据中,不走运

  3. 为 npm、git、gradle 等添加代理配置。没有工作

问题是,如何解决这种情况:

  1. 代理登录提示出现在应用程序中?我做了一些研究,看起来科尔多瓦应用程序不支持这一点。但是,很想看看这是否可以做到。
  2. 如果检测到没有连接,则将模块添加到应用程序以管理此行为
  3. 以某种方式在不安装任何软件或不连接到 VPN 的情况下全局设置持久代理

如果您有任何其他建议/解决方案,我们非常欢迎。任何帮助都将不胜感激。

标签: cordovauwpproxycrash

解决方案


通过网络监视器的进一步分析,我可以看到流向 google fonts api 的流量。因此,问题在于页眉有一条线可以连接到 google api 以获取字体。这是在寻找 Internet 连接,而代理将挑战HTTP 407.

    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">

注释掉这一行后,应用程序现在能够成功启动。希望它也可以帮助其他人。


推荐阅读