如何将node.js应用程序转换为cordova

问题描述:

我们为台式机和平板电脑构建了 node.js 应用程序。这是完全基于网络的应用程序。现在,我计划使用 Apache cordova android 中实现与本机应用程序相同的应用程序。

we built a node.js application for desktop and tablet. It's completely web based application. Now I am planning to implement same application as native app in android using Apache cordova.

在项目目录下,我们有 node_modules,public,...。所有客户端文件都在 public 文件夹。当我在浏览器中调用 URL 时,从客户端进行API调用以检查用户是否已登录。

Under project directory, we have node_modules,public,.... all client side files are in public folder. When I invoke URL in browser, from client side I am making API call to check whether user already logged or not. like this we are making API calls to my server.

根据我的理解,本机应用程序什么都不是,但是我们将所有客户端文件存储到设备中。每当用户打开的应用程序将加载客户端文件并按照工作流程进行调用时,都会进行API调用。

As per my understanding,native app is nothing but we are storing all the client side files into device. whenever user open app will load client side files and as per work flow it will make API calls.

理论上,我对此非常了解。

Theoretically I understand that much.

我卡住的地方:

在桌面应用程序中,我曾经使用 / api / web / shared之类的URL进行API调用/ reject / ,这里我们无需提及服务器地址,例如 localhost:8080 / api / web / shared / reject / 会照顾的相同的方法如何在 cordova 应用程序中起作用。

In desktop app , I used to make API calls with URL like /api/web/shared/reject/, here we don't need to mention server address like localhost:8080/api/web/shared/reject/ that everything browser will take care. This same thing how can I make it work in cordova applications.

cordova 会知道它是 localhost还是其他东西 ...

How cordova will know whether it is localhost or something else...

关于此,我

有人可以建议我吗?

基本上,这是一个概念问题。
Node.js是一种专门用于后端的技术,并且诸如扩展某些服务/功能之类的一些用法。
当您谈论localhost:8080时,您在说应该在您的node.js实现中使用服务器(Amazon,Azure,您自己的服务器,nodejitsu等),公共页面或客户端应使用的页面将添加到phonegap中,尤其是在您的 www 中>目录,并且应该为您的服务器(Amazon,您自己的服务器,nodejitsu等)更改localhost:8080的引用,并且 www 目录中的文件可能具有引用(通过 GET POST 从服务器检索数据。请记住, Crossdomain 问题不会在phonegap上发生(也许在
和Phonegap是使用HTML5,jquery,CSS3和其他相关技术开发前端的框架技术。
对于您的特定情况, node_modules 也应该安装在服务器中,而不是在phonegap项目上。

Basically, is a concept problem. Node.js is a technology specialised in backend and some of usages like extend some services/functions, etc. When you talk of a localhost:8080 you are talking that your node.js implementation should be in a server (Amazon, Azure, your own server, nodejitsu, etc), and the public pages or the pages that the client should consume will be added into phonegap, specifically in your www directory and the references for localhost:8080 should be changed for your server (Amazon, your own server, nodejitsu, etc), and the files on your www directory could have references (via GET or POST to retrieve the data from the server. Remember, the Crossdomain problem doesn't happens on phonegap (maybe in a local enviroment should occur). And Phonegap is a framework to develop front-end with HTML5, jquery, CSS3 and other releated technologies. For your specific case the node_modules should be installed in the server too, not on the phonegap project.