Ste*_*euh 9 google-chrome google-chrome-extension google-chrome-app
我需要在manifest.js中使用fileSystem权限,这样我就可以从Chrome扩展程序读取/写入文件.
当我使用"加载解压缩的扩展程序"按钮加载我的扩展程序时,Chrome会显示:
'fileSystem' is only allowed for packaged apps, and this is a legacy packaged app.
Run Code Online (Sandbox Code Playgroud)
因此,对于铬我的分机是一个传统的打包应用程序.
我的问题是如何在技术上将" 遗留打包应用程序 "转换为" 打包应用程序 ",以便我可以测试fileSystem API?
这是我的清单:
{
"name": "MyApp",
"version": "1.0",
"manifest_version": 2,
"app": {
"launch": {
"local_path": "index.html"
}
},
"icons": {
"128": "favicon.ico"
},
"permissions" : [
"fileSystem"
]
}
Run Code Online (Sandbox Code Playgroud)
的确,我已经在使用了"manifest_version": 2
.
man*_*ini 12
打包的应用程序在清单的"app"部分中具有不同的结构.你的manifest.json会是这样的:
{
"name": "MyApp",
"version": "1.0",
"manifest_version": 2,
"app": {
"background": {
"scripts": [
"main.js"
]
}
},
"icons": {
"128": "favicon.ico"
},
"permissions": [
"fileSystem"
]
}
Run Code Online (Sandbox Code Playgroud)
并且您还需要一个后台脚本(此示例中为"main.js"),当用户单击应用程序图标时会打开index.html:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
bounds: {
width: 500,
height: 300
}
});
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10638 次 |
最近记录: |