我有一个静态的html页面,该页面拦截授权消息,我想在域上公开此页面。看起来像这样:
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>JwtAuthDemo - Facebook Auth</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="assets/util.js"></script>
</head>
<body>
<script>
// if we don't receive an access token then login failed and/or the user has not connected properly
var accessToken = getParameterByName("access_token");
var message = {};
if (accessToken) {
message.status = true;
message.accessToken = accessToken;
}
else
{
message.status = false;
message.error = getParameterByName("error");
message.errorDescription = getParameterByName("error_description");
}
window.opener.postMessage(JSON.stringify(message), "http://localhost:5000");
</script>
</body>
</html>
如果我将此页面放置在index.html页面旁边,则不会显示该页面,但是当我将其放置在资产文件夹中时,可以访问它。我猜我必须在json配置文件之一中显式公开页面,但是我不确定如何做到这一点?
我不希望重定向网址为www.mydomain.com/assets/oauth-response-parser.html。我希望将此内容保留在我的应用程序中,因为它是应用程序的一部分。
如何将Ionic的静态html页面作为同级暴露给index.html页面?
答案 0 :(得分:0)
您可以通过指定要在Ionic构建过程中运行自定义脚本来自动将文件获取到资产目录。 在package.json中,您将有一个“配置”部分,您可以在其中指定此脚本:
...
"config": {
"ionic_copy": "./config/customCopy.config.js"
},
...
,然后您的customCopy.config.js将包含一个条目,用于通过html复制到资产中:
module.exports = {
copyAssets: {
src: ['{{SRC}}/assets/**/*'],
dest: '{{WWW}}/assets'
}
}
有关此过程的更多信息,请访问ionic app scripts page
我希望这可以引导您朝正确的方向前进。