1 Star 3 Fork 0

Maxfengyan / m-console

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

aconsole

一个轻量级的模拟 console 输出工具便于调试机顶盒以及查看输出信息(STB B/S 架构下厂商屏蔽掉了 console 以及 alert 方法)

特点

  • 查看 console 输出
  • 定制化配置

功能

  • 自定义日志输出背景颜色,位置,大小以及优先级等
  • 自定义日志输出文字大小,支持聚焦模式,日志翻页,对象格式化展现便于查看
  • 自动区分输入日志类型
  • 捕捉 js 执行错误并输出
  • 清除日志功能
  • 隐藏以及显示日志
  • 输出 UserAgent

使用

直接下载 release

或者

npm install aconsole

引入 dist/aconsole.min.js 到你的项目中

<script src="path/to/aconsole.min.js"></script>
<script>
  // init Aconsole

  var _aconsole = new Aconsole();
  _aconsole.show();
  _aconsole.log("hello world");
  _aconsole.trace("hello world");
  _aconsole.debug("hello world");
  _aconsole.info("hello world");
  _aconsole.warn("hello world");
  _aconsole.error("hello world");
  // example: match key event
  document.addEventListener("keydown", function (event) {
    var code = event.keyCode;
    if (code == 13) {
      // _mconsole.clearAll();
      _mconsole.toggle();
      // _mconsole.clear();
    }
    if (code == 32) {
      _mconsole.log(document.createElement("div"), 2);
    }
    if (code == 34) {
      _mconsole.pageDown();
    }
    if (code == 33) {
      _mconsole.pageUp();
    }
    if (code == 40) {
      _mconsole.moveDown();
    }
    if (code == 38) {
      _mconsole.moveUp();
    }
  });
</script>

配置

var options = {
  position: "left", // 日志输出位置
  size: "50%", // 日志所占屏幕大小
  id: "console", // 日志dom id
  parent: "body", // 捆绑父元素(body, ID, class)
  focus: true, // 聚焦模式, 默认: false
  zindex: 9999, // 默认: 9999
  spread: true, // 默认: false
  bgcolor: "rgba(85,85,85,.8)",
};
new Aconsole(options); // unnecessarily

所有方法

  • show() && hide()
  • log(data, level) // level: 1: error, 2: warn, 3: info, 4: log, 5: debug, 6: trace
  • trace(data)
  • debug(data)
  • error(data)
  • info(data)
  • trace(data)
  • getDom() // 得到日志 dom
  • clearAll() // 清除日志
  • clear() // 清除当前聚焦的日志, (focus: true)
  • pageDown() && pageUp() // 日志翻页
  • moveDown() && moveUp() // 聚焦模式下移动焦点 (focus: true)
  • toggle() // 格式化当前焦点的日志当当前日志输出为对象的时候 (focus: true)

toggle before:

toggle after:

MIT License Copyright (c) 2021 Maxfengyan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

EPG IPTV机顶盒端模拟console输出的插件 展开 收起
JavaScript 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/Maxfengyan/m-console.git
git@gitee.com:Maxfengyan/m-console.git
Maxfengyan
m-console
m-console
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891