'fileSystem'只适用于打包的应用程序,这是一个传统的打包应用程序 [英] 'fileSystem' is only allowed for packaged apps, and this is a legacy packaged app
问题描述
我需要在manifest.js中使用fileSystem权限,所以我可以从我的Chrome扩展中读取/写入文件。
I need to use the fileSystem permission in the manifest.js, so I can read/write files from my Chrome extension.
当我使用加载解压后的扩展名按钮,Chrome显示:
When I load my extension with the "Load unpacked extension" button, Chrome displays:
'fileSystem' is only allowed for packaged apps, and this is a legacy packaged app.
因此,对于Chrome,我的扩展程序是旧版套装应用程序。
So for Chrome my extension is a legacy packaged app.
我的问题是如何从技术上将传统打包应用转换为打包应用,以便测试fileSystem API?
My question is how to technically convert a "legacy packaged app" into a "packaged apps" so I can test the fileSystem API ?
以下是我的清单:
Here is my manifest:
{
"name": "MyApp",
"version": "1.0",
"manifest_version": 2,
"app": {
"launch": {
"local_path": "index.html"
}
},
"icons": {
"128": "favicon.ico"
},
"permissions" : [
"fileSystem"
]
}
确实我已经在使用manifest_version:2
。
推荐答案
打包应用在清单的应用部分有不同的结构。您的manifest.json应该是这样的:
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"
]
}
并且您还需要一个后台脚本(本示例中为main.js),当用户单击应用程序图标时打开您的index.html:
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
}
});
});
这篇关于'fileSystem'只适用于打包的应用程序,这是一个传统的打包应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!