问题
I want to deploy an existing JS app as a Packaged Crome App to make it distributable in the Chrome Web Store.
In "legacy packaged apps", there is/used to be a way to specify an options_ui
page (in old legacy (legacy-legacy?) apps it was options_page
) which would be accessible via a special link from your app, or by automatic link from from within chrome://extensions
.
There doesn't seem to be any mention about how to migrate the options_*
feature, but if the manifest.json
of a Chrome App has the options_ui
key it generates the following warning on the extensions page:
- 'options_ui' is only allowed for extensions and legacy packaged apps, but this is a packaged app.
(References)
- Chrome Developer: Migrating from a Packaged App to a Chrome App or Extension
- Stack Overflow: Difference between a Packaged App and a Legacy Packaged App in Chrome
回答1:
You can create a context menu item on your icon to open your options.
Add the "contextMenus" permission, then add something like this to your background page:
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({ id: "options", title: "Options", contexts: ["launcher"] })
})
chrome.contextMenus.onClicked.addListener(function(info) {
if(info.menuItemId == "options") {
chrome.app.window.create("options.html")
}
})
来源:https://stackoverflow.com/questions/31645683/how-do-i-handle-options-in-a-packaged-chrome-app