mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Add: Contribution doc
This commit is contained in:
@@ -106,6 +106,10 @@ source code of plugins below to learn how to write your own custom tool panels.
|
|||||||
> When writing plugins, you can use utilities exposed by Eruda, see
|
> When writing plugins, you can use utilities exposed by Eruda, see
|
||||||
[docs](https://github.com/liriliri/eruda/blob/master/doc/UTIL_API.md) here.
|
[docs](https://github.com/liriliri/eruda/blob/master/doc/UTIL_API.md) here.
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
Read [Contributing Guide](https://github.com/liriliri/eruda/blob/master/doc/CONTRIBUTING.md) for development setup instructions.
|
||||||
|
|
||||||
## Related Projects
|
## Related Projects
|
||||||
|
|
||||||
* [eustia](https://github.com/liriliri/eustia): Generator of eruda's utility library.
|
* [eustia](https://github.com/liriliri/eustia): Generator of eruda's utility library.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ btns
|
|||||||
devtool
|
devtool
|
||||||
draggabilly
|
draggabilly
|
||||||
eruda
|
eruda
|
||||||
|
eustia
|
||||||
focusin
|
focusin
|
||||||
iframe
|
iframe
|
||||||
iteratee
|
iteratee
|
||||||
|
|||||||
32
doc/CONTRIBUTING.md
Normal file
32
doc/CONTRIBUTING.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Contributing Guide
|
||||||
|
|
||||||
|
## Development Setup
|
||||||
|
|
||||||
|
[Node.js](https://nodejs.org/en/) is needed for the development of eruda.
|
||||||
|
|
||||||
|
After cloning the repo, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# install npm dependencies.
|
||||||
|
npm install
|
||||||
|
# copy jasmine lib from node_modules to test folder.
|
||||||
|
npm run cpTestLib
|
||||||
|
```
|
||||||
|
|
||||||
|
## Commonly used NPM scripts
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# watch and auto re-build, webpack-dev-server is required.
|
||||||
|
npm run dev
|
||||||
|
# build eruda.js and eruda.min.js
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
- **dev**: development related files.
|
||||||
|
- **doc**: documents.
|
||||||
|
- **eustia**: eustia extended utilties.
|
||||||
|
- **script**: webpack configuration, and some other useful scripts.
|
||||||
|
- **src**: source code, written in es2015.
|
||||||
|
- **test**: contain pages for testing.
|
||||||
81
doc/README_CH.md
Normal file
81
doc/README_CH.md
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# Eruda
|
||||||
|
|
||||||
|
[](https://badge.fury.io/js/eruda)
|
||||||
|
|
||||||
|
Eruda 是一个专为手机网页前端设计的调试面板,类似 DevTools 的迷你版,其主要功能包括:捕获 console 日志、检查元素状态、显示性能指标、捕获XHR请求、显示本地存储和 Cookie 信息、浏览器特性检测等等。
|
||||||
|
|
||||||
|
## 功能清单
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
1. 按钮拖拽,面板透明度大小设置。
|
||||||
|
|
||||||
|
2. Console面板:捕获Console日志,支持log、error、info、warn、dir、time/timeEnd、clear、count、assert、table;支持占位符,包括%c自定义样式输出;支持按日志类型及正则表达式过滤;支持快捷命令加载underscore、jQuery库;支持JavaScript脚本执行。
|
||||||
|
|
||||||
|
3. Elements面板:查看标签内容及属性;查看应用在Dom上的样式;支持页面元素高亮;支持屏幕直接点击选取;查看Dom上绑定的各类事件。
|
||||||
|
|
||||||
|
4. Network面板:图表显示页面加载速度;查看页面各资源请求时间(Android);捕获XHR请求,查看发送数据、返回头、返回内容等信息。
|
||||||
|
|
||||||
|
5. Resources面板:查看并清除localStorage、sessionStorage及cookie;查看页面加载脚本及样式文件;查看页面加载图片。
|
||||||
|
|
||||||
|
6. Sources面板:查看页面源码;格式化html,css,js代码及json数据。
|
||||||
|
|
||||||
|
7. Info面板:输出URL及User Agent;支持自定义输出内容。
|
||||||
|
|
||||||
|
8. Snippets面板:页面元素添加边框;加时间戳刷新页面;支持自定义代码片段。
|
||||||
|
|
||||||
|
9. Features面板:浏览器常用特性检测;提供Can I use,Html5Test快捷访问。
|
||||||
|
|
||||||
|
## 快速上手
|
||||||
|
|
||||||
|
通过npm安装:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install eruda --save
|
||||||
|
```
|
||||||
|
|
||||||
|
在页面中加载脚本:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="node_modules/eruda/eruda.min.js"></script>
|
||||||
|
<script>eruda.init();</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
Js文件对于移动端来说略重(gzip后大概80kb)。建议通过url参数来控制是否加载调试器,比如:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
;(function () {
|
||||||
|
var src = 'node_modules/eruda/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:指定要初始化哪些面板,默认加载所有。
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var el = document.createElement('div');
|
||||||
|
document.body.appendChild(el);
|
||||||
|
|
||||||
|
eruda.init({
|
||||||
|
container: el,
|
||||||
|
tool: ['console', 'elements']
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
> 该工具支持自行编写插件,可参考[eruda-fps](https://github.com/liriliri/eruda-fps)。
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
请扫描二维码或在手机上直接访问:[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() } })();
|
||||||
|
```
|
||||||
156
doc/TOOL_API.md
Normal file
156
doc/TOOL_API.md
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
# Tool Api
|
||||||
|
|
||||||
|
Each default tool provided by eruda can be accessed by `eruda.get('Tool Name')`.
|
||||||
|
|
||||||
|
## Console
|
||||||
|
|
||||||
|
Display console logs. Implementation detail follows the [console api spec](https://github.com/DeveloperToolsWG/console-object/blob/master/api.md).
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
|Name |Type |Desc |
|
||||||
|
|-------------------|-------|-------------------------------|
|
||||||
|
|catchGlobalErr |boolean|Catch global errors |
|
||||||
|
|overrideConsole |boolean|Override console |
|
||||||
|
|displayExtraInfo |boolean|Display extra information |
|
||||||
|
|displayUnenumerable|boolean|Display unenumerable properties|
|
||||||
|
|displayGetterVal |boolean|Access getter value |
|
||||||
|
|viewLogInSources |boolean|View log in sources panel |
|
||||||
|
|displayIfErr |boolean|Auto display if error occurs |
|
||||||
|
|maxLogNum |string |Max log number |
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var console = eruda.get('console');
|
||||||
|
console.config.set('catchGlobalErr', true);
|
||||||
|
```
|
||||||
|
|
||||||
|
### log, error, info, warn, dir, time/timeEnd, clear, count, assert, table
|
||||||
|
|
||||||
|
All these methods can be used in the same way as window.console object.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var console = eruda.get('console');
|
||||||
|
console.log('eruda is a console for %s.', 'mobile browsers');
|
||||||
|
console.table([{test: 1}, {test: 2}, {test2: 3}], 'test');
|
||||||
|
console.error(new Error('eruda'));
|
||||||
|
```
|
||||||
|
|
||||||
|
### filter
|
||||||
|
|
||||||
|
Filter logs.
|
||||||
|
|
||||||
|
|Name |Type |Desc |
|
||||||
|
|------|----------------------|-------------|
|
||||||
|
|filter|string regexp function|Custom filter|
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
console.filter('all'); // String parameter. Log, warn, debug, error is also supported.
|
||||||
|
console.filter(/^eruda/);
|
||||||
|
console.filter(function (log)
|
||||||
|
{
|
||||||
|
return log.type === 'error';
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### html
|
||||||
|
|
||||||
|
Log out html content.
|
||||||
|
|
||||||
|
|Name|Type |Desc |
|
||||||
|
|----|------|-----------|
|
||||||
|
|html|string|Html string|
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
console.html('<span style="color:red">Red</span>');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Elements
|
||||||
|
|
||||||
|
## Network
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
## Sources
|
||||||
|
|
||||||
|
## Info
|
||||||
|
|
||||||
|
Display special information, could be used for displaying user info to track
|
||||||
|
user logs.
|
||||||
|
|
||||||
|
By default, page url and browser user agent is shown.
|
||||||
|
|
||||||
|
### clear
|
||||||
|
|
||||||
|
Clear infos.
|
||||||
|
|
||||||
|
### add
|
||||||
|
|
||||||
|
Add info.
|
||||||
|
|
||||||
|
|Name |Type |Desc |
|
||||||
|
|-------|------|------------|
|
||||||
|
|name |string|Info name |
|
||||||
|
|content|string|Info content|
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
info.add('title', 'content');
|
||||||
|
```
|
||||||
|
|
||||||
|
### remove
|
||||||
|
|
||||||
|
Remove specified info.
|
||||||
|
|
||||||
|
|Name|Type |Desc |
|
||||||
|
|----|------|---------|
|
||||||
|
|name|string|Info name|
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
info.remove('title');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Snippets
|
||||||
|
|
||||||
|
Allow you to register small functions that can be triggered multiple times.
|
||||||
|
|
||||||
|
### clear
|
||||||
|
|
||||||
|
Clear Snippets.
|
||||||
|
|
||||||
|
### add
|
||||||
|
|
||||||
|
Add Snippet.
|
||||||
|
|
||||||
|
|Name|Type |Desc |
|
||||||
|
|----|--------|------------------------|
|
||||||
|
|name|string |Snippet name |
|
||||||
|
|fn |function|Function to be triggered|
|
||||||
|
|desc|string |Snippet description |
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
snippets.add('hello', function ()
|
||||||
|
{
|
||||||
|
console.log('Hello World!');
|
||||||
|
}, 'Display hello on console');
|
||||||
|
```
|
||||||
|
|
||||||
|
### remove
|
||||||
|
|
||||||
|
Remove specified snippet.
|
||||||
|
|
||||||
|
|Name|Type |Desc |
|
||||||
|
|----|------|-----------------|
|
||||||
|
|name|string|Snippet to remove|
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
snippets.remove('hello');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
Browser feature detections, thanks to
|
||||||
|
[modernizr](https://github.com/Modernizr/Modernizr) project.
|
||||||
|
|
||||||
|
Red means unsupported, otherwise ok. All buttons is linked directly to
|
||||||
|
related materials in [Can I Use](http://caniuse.com/) website.
|
||||||
|
|
||||||
|
## Settings
|
||||||
1347
doc/UTIL_API.md
Normal file
1347
doc/UTIL_API.md
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user