net::ERR_CONNECTION_REFUSED - 从 inappbrowser 访问我的 Meteor 应用程序中的项目文件

net::ERR_CONNECTION_REFUSED - Access project file inside my Meteor app from inappbrowser

我是 Meteor 和 React 的新手,用它为 Android 构建了我的第一个应用程序(我使用的是 Angular1)。

这个应用程序里面有很多小游戏,我正在尝试从我的 resources/ 文件夹中提供这些游戏。

我的问题是:当我点击一个标题时,一个应用程序浏览器 windows pop-up,我想在那里提供我的游戏。

我尝试了很多方法来打开 resources/games/meme/index.html 中的文件,但我总是得到:net::ERR_CONNECTION_REFUSED net::ERR_FILE_NOT_FOUND(这是我用file:///games/meme/index.html时的最后一个)

这是我的代码:

// here I have some settings
const inAppOptions = 'location=no,clearcache=yes,toolbar=no';
const target = '_blank';

// and here the code itself
if (Meteor.isCordova) {
    Meteor.startup(function() {
        let ref = cordova.InAppBrowser.open('file:///games/meme/index.html', target, inAppOptions);
        ref.addEventListener('exit', () => cordova.InAppBrowser.close());
    });
}

到目前为止,我已经尝试使用 let ref = cordova.InAppBrowser.open('file:///games/meme/index.html', target, inAppOptions); 行: 'file:///games/meme/index.html' '/games/meme/index.html' '/resources/games/meme/index.html' 'resources/games/meme/index.html'

我也将 games/ 文件夹及其内容放在 public/ 目录中,结果相同。

我安装了cordova-whitelist插件,mobile-config.js里面的App.accessRule('*', {type: 'navigation'});

这是我的文件夹结构:

MyApp
├── .meteor
├── client
├── imports
├── node_modules
├── public
│   ├── games
│   │   ├── meme
│   │   │   ├── index.html
│   ├── img
├── resources
│   ├── games
│   │   ├── meme
│   │   │   ├── index.html
│   ├── icons
│   ├── splash
├── server
│   mobile-config.js
│   package.json

我希望有人能帮助我,我在 angular 中的 ionic 没有这个问题,根文件夹就是我所在的位置,所以我不得不像这样导航:'../../resources/games/meme/index.html'获取文件。

提前致谢!

编辑: 我尝试在chrome://inspect中手动写入地址,这样访问成功:localhost:12200/games/meme/index.html(在 public/ 文件夹中),但我无法在 inappbrowser 中使用相同的地址。

这里只是猜测,但我知道在使用 React Native 为 Android 开发时我不能使用 localhost,因为它无法解析。尝试将 localhost 换成您机器的 IP 地址。