[英]Background not supported manifest.json
A Chrome app had a function that I wanted to emulate. Chrome应用程式具有我要模仿的功能。 Essentially, the manifest.json calls a script (main.js) that causes the window to open and size the html a certain way.
本质上,manifest.json调用一个脚本(main.js),该脚本导致窗口以某种方式打开并调整html的大小。
So instead of loading the html directly, its supposed to preload and execute this script before, so that the app feels more complete and encapsulated. 因此,与其直接加载html,不如直接加载并执行此脚本,这样应用程序将感觉更加完整和封装。 Now when I side load the app (to test it) I have no issues.
现在,当我侧面加载应用程序(以对其进行测试)时,我没有任何问题。 But when I go to upload it, I get an error.
但是,当我上传它时,出现错误。
Now since I know that this manifest and script works sideloaded and on this other uploaded app, I have no idea how I'm supposed to be able to get it to upload without the error. 现在,由于我知道此清单和脚本可以侧面加载,并且可以在其他已上载的应用程序上使用,因此我不知道应该如何将其上传而不会出现错误。
An error occurred: Failed to process your item. background subsection of app section is not supported.
This is the part of the manifest that is getting the error: 这是清单中出现错误的部分:
"app": {
"background": {
"scripts": [ "main.js" ]
} },
Is there a way to get this script to work or get the effect of it through some other way? 是否有办法使此脚本起作用或通过其他方式获得效果?
here is the main.js script: 这是main.js脚本:
/**
* Listens for the app launching then creates the window
*
* @see http://developer.chrome.com/trunk/apps/app.runtime.html
* @see http://developer.chrome.com/trunk/apps/app.window.html
*/
chrome.app.runtime.onLaunched.addListener(function() {
// Center window on screen.
var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var width = 1280;
var height = 720;
chrome.app.window.create('index.html', {
bounds: {
width: width,
height: height,
left: Math.round((screenWidth-width)/2),
top: Math.round((screenHeight-height)/2)
}
});
});
The whole process stops working if the first upload was with 如果第一次上传与
"app": {
"launch": {
"local_path": "index.html"
} },
I clicked on "Add New Item" and by uploading the first file with the "background" "scripts" instead of "launch" it accepted the zip file with no issues. 我单击“添加新项”,并通过上载带有“背景”“脚本”而不是“启动”的第一个文件,它接受了zip文件,没有任何问题。
I guess it just means that if you have to submit it as a brand new item to begin with, if you want it to be a packaged app. 我想这只是意味着,如果您必须首先将其作为一个全新的项目提交,则希望它成为一个打包的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.