后台权限很重要。没有它,你如何创建窗口?
chrome.app.window.create(...)
我有一个带有以下清单的应用程序:
{
"manifest_version": 2,
"name": "MyApp",
"description": "MyApp",
"version": "0.7",
"minimum_chrome_version": "27",
"offline_enabled": true,
"options_page": "options.html",
"icons":
{
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"app":
{
"background":
{
"scripts":
[
"scripts/messaging.js",
"scripts/utils.js",
"scripts/database.js",
"scripts/fs.js",
"scripts/background.js"
]
}
},
"permissions":
[
"unlimitedStorage",
"fullscreen",
{
"fileSystem":
[
"write"
]
},
"background",
"<all_urls>"
],
"update_url": "http://192.168.1.101/chrome/crx/updates/MyApp2.xml"
}
此应用程序显示为全屏。数据库和文件的处理,以及用户窗口的创建都是由background.js
后台运行的。在常规的 Chrome 应用程序中,当我尝试添加其中一些功能(例如,chrome.app.window.create(...)
创建客户端窗口的功能)时,运行时会引发错误,指出这些功能/对象在前端不存在。那么,在没有背景许可的情况下,我该如何做这些事情呢?