11

我需要在 manifest.js 中使用 fileSystem 权限,这样我就可以从我的 Chrome 扩展程序中读取/写入文件。

当我使用“加载解压的扩展程序”按钮加载我的扩展程序时,Chrome 显示:

'fileSystem' is only allowed for packaged apps, and this is a legacy packaged app.

所以对于 Chrome,我的扩展是一个遗留的打包应用程序

我的问题是如何在技术上将“遗留打包应用程序”转换为“打包应用程序”,以便我可以测试文件系统 API?

这是我的清单:

{
 "name": "MyApp",
 "version": "1.0",
 "manifest_version": 2,
  "app": {
  "launch": {
  "local_path": "index.html"
  }
 },
 "icons": {
 "128": "favicon.ico"
 },
  "permissions" : [
    "fileSystem"
  ]
}

事实上,我已经在使用"manifest_version": 2.

4

2 回答 2

14

打包的应用程序在清单的“应用程序”部分具有不同的结构。您的 manifest.json 将类似于:

{
  "name": "MyApp",
  "version": "1.0",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": [
        "main.js"
      ]
    }
  },
  "icons": {
    "128": "favicon.ico"
  },
  "permissions": [
    "fileSystem"
  ]
}

并且您还需要一个后台脚本(在此示例中为“main.js”),当用户单击应用程序图标时,它会打开您的 index.html:

chrome.app.runtime.onLaunched.addListener(function() {
  chrome.app.window.create('index.html', {
    bounds: {
      width: 500,
      height: 300
    }
  });
});
于 2013-04-24T14:48:55.087 回答
-2

将此添加到您的清单中:

"manifest_version": 2,
于 2013-04-23T15:06:24.393 回答