跳转到内容

移动端调试工具

NPM Version

开启方式

  1. 安装插件
bash
$ npm add @winner-fed/plugin-wconsole -D
bash
$ yarn add @winner-fed/plugin-wconsole -D
bash
$ pnpm add @winner-fed/plugin-wconsole -D
bash
$ bun add @winner-fed/plugin-wconsole -D
  1. 在配置文件中 .winrc 中开启该功能
ts
import { defineConfig } from 'win';

export default defineConfig({
  plugins: [require.resolve('@winner-fed/plugin-wconsole')],
  wconsole: {
    // 三者使用其一即可或全部使用均可
    vconsole: {},
    eruda: {},
    pagespy: {}
  },
  appConfig: {
    development: {
      API_HOME: 'https://api.github.com/',
      API_UPLOAD: 'https://api.github.com/upload',
      // 调试工具启用开关
      IS_OPEN_VCONSOLE: true
    },
  }
});

介绍

WinJS 项目的常用的移动端调试工具集合。目前涵盖了 vConsoleerudaPageSpy

注意

为了保证和之前项目开启调试工具的一致性,在启用插件前,需要在项目的配置文件中添加 IS_OPEN_VCONSOLE 属性。即在 window.LOCAL_CONFIG 挂载 IS_OPEN_VCONSOLE 属性,且其值设置为 true

配置

vConsole

js
import { defineConfig } from 'win';

export default defineConfig({
  plugins: [require.resolve('@winner-fed/plugin-wconsole')],
  wconsole: {
    vconsole: {
      defaultPlugins: Array(string),
      onReady: Function,
      disableLogScrolling: Boolean,
      theme: String,
      url: String
    },
  }
});
键名类型可选默认值描述
defaultPluginsArray(String)true['system', 'network', 'element', 'storage']需要自动初始化并加载的内置插件。
onReadyFunctiontrue回调方法,当 vConsole 完成初始化并加载完内置插件后触发。
disableLogScrollingBooleantrue若为 false,有新日志时面板将不会自动滚动到底部。
themeStringtrue'light'主题颜色,可选值为 'light'
urlStringtrue'https://cdnjs.cloudflare.com/ajax/libs/vConsole/3.14.7/vconsole.min.js'加载的 vConsole 文件地址。

可以参考这里

edura

js
import { defineConfig } from 'win';

export default defineConfig({
  plugins: [require.resolve('@winner-fed/plugin-wconsole')],
  wconsole: {
    edura: {
      container: String,
      tool: Array(String),
      autoScale: Boolean,
      useShadowDom: Boolean,
      defaults: Object,
      url: String
    },
  }
});
键名类型可选默认值描述
containerStringtrue用于插件初始化的 Dom 元素,如果不设置,默认创建 div 作为容器直接置于 html 根结点下面。
toolArray(String)true指定要初始化哪些面板,默认加载所有。
autoScaleBooleantruetrue不同的视窗下自动缩放
useShadowDomBooleantruetrue使用 Shadow DOM 实现 CSS 封装
defaultsObjecttrue{ displaySize: 50, transparency: 0.9, theme: 'Monokai Pro' }默认设置。
urlStringtrue'https://cdnjs.cloudflare.com/ajax/libs/eruda/3.0.1/eruda.min.js'加载的 edura 文件地址。

可以参考这里

基于 MIT 许可发布