问题
Since packaged apps can run on different platforms, is there any way to distinguish between Windows and Mac ?
I would like to show some help vis-à-vis keyboard shortcuts and being able to detect the OS would help in for example showing Command ⌘C or CtrlC accordingly.
回答1:
You can use window.navigator
in JS. Typically that will have the information you're looking for. Probably in window.navigator.platform.
回答2:
You can also use the new chrome.runtime.getPlatformInfo
API (https://developer.chrome.com/apps/runtime.html#method-getPlatformInfo, available since Chrome 29).
来源:https://stackoverflow.com/questions/18153367/detect-the-underlying-os-in-a-chrome-packaged-app