Platform.js 1.1 KB

123456789101112
  1. let _platform;export function platform(){if(!_platform){_platform=Host.InspectorFrontendHost.platform();}
  2. return _platform;}
  3. let _isMac;export function isMac(){if(typeof _isMac==='undefined'){_isMac=platform()==='mac';}
  4. return _isMac;}
  5. let _isWin;export function isWin(){if(typeof _isWin==='undefined'){_isWin=platform()==='windows';}
  6. return _isWin;}
  7. let _isCustomDevtoolsFrontend;export function isCustomDevtoolsFrontend(){if(typeof _isCustomDevtoolsFrontend==='undefined'){_isCustomDevtoolsFrontend=window.location.toString().startsWith('devtools://devtools/custom/');}
  8. return _isCustomDevtoolsFrontend;}
  9. let _fontFamily;export function fontFamily(){if(_fontFamily){return _fontFamily;}
  10. switch(platform()){case'linux':_fontFamily='Roboto, Ubuntu, Arial, sans-serif';break;case'mac':_fontFamily='\'Lucida Grande\', sans-serif';break;case'windows':_fontFamily='\'Segoe UI\', Tahoma, sans-serif';break;}
  11. return _fontFamily;}
  12. self.Host=self.Host||{};Host=Host||{};Host.platform=platform;Host.isWin=isWin;Host.isMac=isMac;Host.isCustomDevtoolsFrontend=isCustomDevtoolsFrontend;Host.fontFamily=fontFamily;