【问题标题】:Background not supported manifest.json后台不支持 manifest.json
【发布时间】:2014-01-18 03:34:40
【问题描述】:

Chrome 应用有一个我想模拟的功能。本质上,manifest.json 调用了一个脚本 (main.js),该脚本会导致窗口以某种方式打开并调整 html 的大小。

所以不是直接加载html,而是应该在之前预加载并执行这个脚本,让应用感觉更加完整和封装。现在,当我侧加载应用程序(进行测试)时,我没有问题。但是当我去上传它时,我得到了一个错误。

现在,由于我知道这个清单和脚本可以侧载并在这个其他上传的应用程序上工作,我不知道我应该如何才能让它在没有错误的情况下上传。

 An error occurred: Failed to process your item.

 background subsection of app section is not supported.

这是出现错误的清单部分:

 "app": {
      "background": {
         "scripts": [ "main.js" ]
      }    },

有没有办法让这个脚本工作或通过其他方式获得它的效果?

这是 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)
    }
  });
});

【问题讨论】:

    标签: javascript resize window


    【解决方案1】:

    如果第一次上传是用

    "app": {
          "launch": {
             "local_path": "index.html"
          }    },
    

    我点击了“添加新项目”并通过上传第一个带有“背景”“脚本”而不是“启动”的文件,它毫无问题地接受了 zip 文件。

    我想这只是意味着如果你必须将它作为一个全新的项目开始提交,如果你希望它成为一个打包的应用程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-24
      • 2011-12-09
      • 1970-01-01
      • 1970-01-01
      • 2023-02-08
      • 2018-08-27
      • 2010-09-11
      相关资源
      最近更新 更多