Add: Read me ch

This commit is contained in:
surunzi
2016-06-23 20:10:19 +08:00
parent 9eb3170d62
commit 60ff91c38b
3 changed files with 87 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
[中文](https://github.com/liriliri/eruda/blob/master/docs/Readme_CH.md)
# Eruda
[![npm version](https://badge.fury.io/js/eruda.svg)](https://badge.fury.io/js/eruda)
[![npm version](https://badge.fury.io/js/eruda.svg)](https://badge.fury.io/js/eruda)
Console for Mobile Browsers.
@@ -8,9 +10,9 @@ Console for Mobile Browsers.
## Why
Logging things out on mobile browser is never an easy stuff. I used to include
`window onerror alert` script inside pages to find out JavaScript errors, kind
of stupid and inefficient. Desktop browser DevTools is great, and I wish there
Logging things out on mobile browser is never an easy stuff. I used to include
`window onerror alert` script inside pages to find out JavaScript errors, kind
of stupid and inefficient. Desktop browser DevTools is great, and I wish there
is a similar one on mobile side, which leads to the creation of Eruda.
## Demo
@@ -90,8 +92,8 @@ source code of plugins below to learn how to write your own custom tool panels.
* [eruda-fps](https://github.com/liriliri/eruda-fps): Display page fps info.
> When writing plugins, You can use utilities exposed by Eruda, see
[docs](https://github.com/liriliri/eruda/blob/master/docs/util.md) here.
> When writing plugins, you can use utilities exposed by Eruda, see
[docs](https://github.com/liriliri/eruda/blob/master/docs/Util_Api.md) here.
## License

79
docs/Readme_CH.md Normal file
View File

@@ -0,0 +1,79 @@
# Eruda
[![npm version](https://badge.fury.io/js/eruda.svg)](https://badge.fury.io/js/eruda)
Eruda 是一个专为手机网页前端设计的调试面板,类似 DevTools 的迷你版,其主要功能包括:捕获
console 日志、检查元素状态、显示性能指标、捕获XHR请求、显示本地存储和 Cookie 信息、
浏览器特性检测等等。
## 功能清单
![Eruda](http://7xn2zy.com1.z0.glb.clouddn.com/eruda_screenshot3.jpg)
1. 按钮拖拽,面板透明度大小设置。
2. Console面板捕获Console日志支持log、error、info、warn、dir、time/timeEnd、
clear支持按日志类型及正则表达式过滤支持快捷命令加载underscore、jQuery库支持
JavaScript脚本执行。
3. Elements面板查看标签内容及属性查看应用在Dom上的样式支持页面元素高亮支持屏幕直
接点击选取查看Dom上绑定的各类事件。
4. Network面板图表显示页面加载速度查看页面各资源请求时间Android捕获XHR请求
查看发送数据、返回头、返回内容等信息。
5. Resources面板查看并清除localStorage、sessionStorage及cookie查看页面加载脚本及
样式文件;查看页面加载图片。
6. Sources面板查看页面源码格式化htmlcssjs代码及json数据
7. Info面板输出URL及User Agent支持自定义输出内容
8. Snippets面板页面元素添加边框加时间戳刷新页面支持自定义代码片段
9. Features面板浏览器常用特性检测提供Can I useHtml5Test快捷访问
## 快速上手
通过npm安装
```bash
npm install eruda --save
```
在页面中加载脚本:
```html
<script src="node_modules/eruda/dist/eruda.min.js"></script>
<script>eruda.init();</script>
```
Js文件对于移动端来说略重gzip后大概85kb。建议通过url参数来控制是否加载调试器比如
```javascript
(function () {
var src = 'node_modules/eruda/dist/eruda.min.js';
if (!/eruda=true/.test(window.location) && localStorage.getItem('active-eruda') != 'true') return;
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
document.write('<scr' + 'ipt>eruda.init();</scr' + 'ipt>');
})();
```
初始化时可以传入配置:
* container: 用于插件初始化的Dom元素如果不设置默认创建div作为容器直接置于html根结点
下面。
* tool指定要初始化哪些面板默认加载所有。
> 该工具支持自行编写插件,可参考[eruda-fps](https://github.com/liriliri/eruda-fps)。
## Demo
![Demo](http://7xn2zy.com1.z0.glb.clouddn.com/eruda_qrcode2.png)
请扫描二维码或在手机上直接访问:[http://liriliri.github.io/eruda/](http://liriliri.github.io/eruda/)
如果想在其它页面尝试,请在浏览器地址栏上输入以下代码。
```javascript
javascript:(function () { var script = document.createElement('script'); script.src="//liriliri.github.io/eruda/eruda.min.js"; document.body.appendChild(script); script.onload = function () { eruda.init() } })();
```