I am using Visual Studio 2015 for develop a hosted web app using Apache Cordova by this tutorial http://taco.visualstudio.com/en-us/docs/create-a-hosted-app For open specific application url in Cordova WebView I should set this url in several places (config.xml, index.html, index.js). This url is different for develop and production environment. And before build application for production I should replace url in several places(config.xml, index.html, index.js). Is it possible to automate this task (maybe through gulp and taco-team-build module)?
问问题
434 次
1 回答
0
最终我的决定很简单。
我将开发人员和生产 url 添加config.xml
到index.html
config.xml
<allow-navigation href="http://dev/*" />
<allow-navigation href="http://prod/*" />
索引.html
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: http://dev/ http://prod/ https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
在index.js中,我创建了返回必要 url 的函数。
function getConnectionInfo(production: boolean): ConnectionInfo
{
if (production)
{
return {
TargetUrl: 'http://prod/',
UsePassword: false,
User: '',
Password: ''
};
}
return {
TargetUrl: 'http://dev/',
UsePassword: false,
User: '',
Password: ''
};
}
如果我构建生产应用程序,我会调用getConnectionInfo(true);
于 2016-07-27T07:40:04.240 回答