Add: System info

This commit is contained in:
surunzi
2017-12-16 18:05:49 +08:00
parent ce5dee62d4
commit 38f9d67b0f
7 changed files with 370 additions and 1041 deletions

View File

@@ -36,6 +36,9 @@
color: $blue;
}
}
.device-key, .system-key {
width: 100px;
}
}
}
} }

View File

@@ -1,3 +1,7 @@
import util from '../lib/util';
let browser = util.detectBrowser();
export default [
{
name: 'Location',
@@ -12,7 +16,7 @@ export default [
val: `<table>
<tbody>
<tr>
<td>screen</td>
<td class="eruda-device-key">screen</td>
<td>${screen.width} * ${screen.height}</td>
</tr>
<tr>
@@ -27,6 +31,21 @@ export default [
</table>`
},
{
name: 'System',
val: `<table>
<tbody>
<tr>
<td class="eruda-system-key">os</td>
<td>${util.detectOs()}</td>
</tr>
<tr>
<td>browser</td>
<td>${browser.name + ' ' + browser.version}</td>
</tr>
</tbody>
</table>`
},
{
name: 'About',
val: '<a href="https://github.com/liriliri/eruda" target="_blank">Eruda v' + VERSION + '</a>'

View File

@@ -171,5 +171,5 @@ function loadPlugin(name)
let pluginVersion = {
fps: '1.0.2',
features: '1.0.2',
timing:'1.0.0'
timing:'1.0.1'
};

View File

@@ -756,6 +756,57 @@ module.exports = (function ()
return exports;
})({});
/* ------------------------------ detectOs ------------------------------ */
_.detectOs = (function ()
{
/* Detect operating system using ua.
*
* |Name |Type |Desc |
* |------------------------|------|---------------------|
* |[ua=navigator.userAgent]|string|Browser userAgent |
* |return |string|Operating system name|
*
* Supported os: windows, os x, linux, ios, android, windows phone
*
* ```javascript
* if (detectOs() === 'ios')
* {
* // Do something about ios...
* }
* ```
*/
/* module
* env: all
* test: all
*/
/* dependencies
* isBrowser
*/
function exports(ua)
{
ua = ua || (isBrowser ? navigator.userAgent : '');
ua = ua.toLowerCase();
if (detect('windows phone')) return 'windows phone';
if (detect('win')) return 'windows';
if (detect('android')) return 'android';
if (detect('ipad') || detect('iphone') || detect('ipod')) return 'ios';
if (detect('mac')) return 'os x';
if (detect('linux')) return 'linux';
function detect(keyword) { return ua.indexOf(keyword) > -1 }
return 'unknown';
}
return exports;
})();
/* ------------------------------ optimizeCb ------------------------------ */
var optimizeCb = _.optimizeCb = (function ()
@@ -5649,55 +5700,6 @@ module.exports = (function ()
return exports;
})();
/* ------------------------------ ready ------------------------------ */
_.ready = (function ()
{
/* Invoke callback when dom is ready, similar to jQuery ready.
*
* |Name|Type |Desc |
* |----|--------|-----------------|
* |fn |function|Callback function|
*
* ```javascript
* ready(function ()
* {
* // It's safe to manipulate dom here.
* });
* ```
*/
/* module
* env: browser
* test: browser
*/
var fns = [],
listener,
doc = document,
hack = doc.documentElement.doScroll,
domContentLoaded = 'DOMContentLoaded',
loaded = (hack ? /^loaded|^c/ : /^loaded|^i|^c/).test(doc.readyState);
if (!loaded)
{
doc.addEventListener(domContentLoaded, listener = function ()
{
doc.removeEventListener(domContentLoaded, listener);
loaded = 1;
/* eslint-disable no-cond-assign */
while (listener = fns.shift()) listener();
});
}
function exports(fn)
{
loaded ? setTimeout(fn, 0) : fns.push(fn)
}
return exports;
})();
/* ------------------------------ rtrim ------------------------------ */
var rtrim = _.rtrim = (function ()