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

前端 未结 2 594
挽巷
挽巷 2021-01-04 11:24

I need to use the fileSystem permission in the manifest.js, so I can read/write files from my Chrome extension.

When I load my extension with the \"Load unpacked ext

相关标签:
2条回答
  • 2021-01-04 12:20

    Packaged apps have a different structure in the "app" section of the manifest. Your manifest.json would be something like:

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

    and you would also need a background script ("main.js" in this sample) that opens your index.html when the user clicks on the app icon:

    chrome.app.runtime.onLaunched.addListener(function() {
      chrome.app.window.create('index.html', {
        bounds: {
          width: 500,
          height: 300
        }
      });
    });
    
    0 讨论(0)
  • 2021-01-04 12:22

    Add this to your manifest:

    "manifest_version": 2,
    
    0 讨论(0)
提交回复
热议问题