|
1 | | -# winjs-plugin-example |
| 1 | +# @winner-fed/plugin-code-inspector |
2 | 2 |
|
3 | | -Example plugin for WinJS. |
| 3 | +WinJS 代码检查器插件,基于 [code-inspector-plugin](https://github.com/zh-lx/code-inspector) 封装,在开发环境中提供点击页面元素快速定位到源码文件的功能。 |
4 | 4 |
|
5 | 5 | <p> |
6 | | - <a href="https://npmjs.com/package/winjs-plugin-example"> |
7 | | - <img src="https://img.shields.io/npm/v/winjs-plugin-example?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /> |
| 6 | + <a href="https://npmjs.com/package/@winner-fed/plugin-code-inspector"> |
| 7 | + <img src="https://img.shields.io/npm/v/@winner-fed/plugin-code-inspector?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /> |
8 | 8 | </a> |
9 | 9 | <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" /> |
10 | | - <a href="https://npmcharts.com/compare/winjs-plugin-example?minimal=true"><img src="https://img.shields.io/npm/dm/winjs-plugin-example.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a> |
| 10 | + <a href="https://npmcharts.com/compare/@winner-fed/plugin-code-inspector?minimal=true"><img src="https://img.shields.io/npm/dm/@winner-fed/plugin-code-inspector.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a> |
11 | 11 | </p> |
12 | 12 |
|
13 | | -## Usage |
| 13 | +## 功能特性 |
14 | 14 |
|
15 | | -Install: |
| 15 | +- 🎯 点击页面元素快速定位到源码文件 |
| 16 | +- 🔧 支持 22+ 种主流 IDE(VSCode、Cursor、WebStorm 等) |
| 17 | +- ⌨️ 可自定义快捷键组合 |
| 18 | +- 📱 支持移动端调试(开关按钮模式) |
| 19 | +- 🚀 支持 Vite、Webpack、Rspack 等打包工具 |
| 20 | +- 🎨 仅在开发环境生效,零侵入生产代码 |
| 21 | + |
| 22 | +## 安装 |
16 | 23 |
|
17 | 24 | ```bash |
18 | | -npm add winjs-plugin-example -D |
| 25 | +npm add @winner-fed/plugin-code-inspector -D |
| 26 | +# or |
| 27 | +pnpm add @winner-fed/plugin-code-inspector -D |
19 | 28 | ``` |
20 | 29 |
|
21 | | -Add plugin to your `.winrc.ts`: |
| 30 | +## 使用 |
| 31 | + |
| 32 | +在 `.winrc.ts` 中添加插件配置: |
22 | 33 |
|
23 | 34 | ```ts |
24 | 35 | // .winrc.ts |
25 | 36 | export default { |
26 | | - plugins: ['winjs-plugin-example'], |
27 | | - // 开启配置 |
28 | | - example: {} |
| 37 | + plugins: ['@winner-fed/plugin-code-inspector'], |
| 38 | + codeInspector: { |
| 39 | + // 默认配置已足够使用,以下为可选配置 |
| 40 | + } |
| 41 | +}; |
| 42 | +``` |
| 43 | + |
| 44 | +启动开发服务器后,按住 `Alt + Shift` 组合键(Mac 为 `Option + Shift`),然后点击页面元素,即可在 IDE 中打开对应的源码文件。 |
| 45 | + |
| 46 | +## 配置选项 |
| 47 | + |
| 48 | +### editor |
| 49 | + |
| 50 | +指定要打开的 IDE 编辑器。 |
| 51 | + |
| 52 | +- Type: `'code' | 'cursor' | 'webstorm' | 'phpstorm' | 'idea' | ...` |
| 53 | +- Default: 自动识别 |
| 54 | +- 说明:插件会自动识别系统运行的 IDE,当同时运行多个 IDE 时可通过此配置指定 |
| 55 | + |
| 56 | +```ts |
| 57 | +export default { |
| 58 | + plugins: ['@winner-fed/plugin-code-inspector'], |
| 59 | + codeInspector: { |
| 60 | + editor: 'cursor' // 指定使用 Cursor 编辑器 |
| 61 | + } |
| 62 | +}; |
| 63 | +``` |
| 64 | + |
| 65 | +### hotKeys |
| 66 | + |
| 67 | +触发源码定位的快捷键组合。 |
| 68 | + |
| 69 | +- Type: `Array<'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey'>` |
| 70 | +- Default: `['altKey', 'shiftKey']` |
| 71 | +- 说明:设置为空数组则关闭快捷键功能 |
| 72 | + |
| 73 | +```ts |
| 74 | +export default { |
| 75 | + plugins: ['@winner-fed/plugin-code-inspector'], |
| 76 | + codeInspector: { |
| 77 | + hotKeys: ['metaKey', 'shiftKey'] // Mac: Cmd + Shift,Windows: Win + Shift |
| 78 | + } |
29 | 79 | }; |
30 | 80 | ``` |
31 | 81 |
|
32 | | -## Options |
| 82 | +### showSwitch |
| 83 | + |
| 84 | +是否在页面显示开关按钮来控制源码定位功能。 |
33 | 85 |
|
34 | | -### foo |
| 86 | +- Type: `boolean` |
| 87 | +- Default: `false` |
| 88 | +- 说明:移动端开发时推荐开启此选项 |
35 | 89 |
|
36 | | -Some description. |
| 90 | +```ts |
| 91 | +export default { |
| 92 | + plugins: ['@winner-fed/plugin-code-inspector'], |
| 93 | + codeInspector: { |
| 94 | + showSwitch: true |
| 95 | + } |
| 96 | +}; |
| 97 | +``` |
37 | 98 |
|
38 | | -- Type: `string` |
39 | | -- Default: `undefined` |
40 | | -- Example: |
| 99 | +### behavior |
41 | 100 |
|
42 | | -```js |
| 101 | +定义点击元素时的行为配置。 |
| 102 | + |
| 103 | +- Type: `{ locate?: boolean; copy?: boolean | string; target?: string }` |
| 104 | +- Default: `{ locate: true, copy: true }` |
| 105 | + |
| 106 | +```ts |
43 | 107 | export default { |
44 | | - plugins: ['winjs-plugin-example'], |
45 | | - // 开启配置 |
46 | | - example: { |
47 | | - foo: 'bar' |
| 108 | + plugins: ['@winner-fed/plugin-code-inspector'], |
| 109 | + codeInspector: { |
| 110 | + behavior: { |
| 111 | + locate: true, // 是否跳转 IDE |
| 112 | + copy: '{file}:{line}:{column}', // 复制源码位置信息 |
| 113 | + target: 'https://github.com/your-repo/blob/main/{file}#L{line}' // 自定义跳转 URL |
| 114 | + } |
48 | 115 | } |
49 | 116 | }; |
50 | 117 | ``` |
51 | 118 |
|
| 119 | +### 更多配置 |
| 120 | + |
| 121 | +插件支持更多配置项,包括: |
| 122 | + |
| 123 | +- `autoToggle` - 触发跳转后自动关闭开关 |
| 124 | +- `dev` - 手动指定开发环境 |
| 125 | +- `enforcePre` - 控制编译顺序 |
| 126 | +- `ip` - 服务器通信地址 |
| 127 | +- `port` - 服务器端口号 |
| 128 | +- `hideConsole` - 隐藏控制台提示 |
| 129 | +- `hideDomPathAttr` - 隐藏 DOM 属性 |
| 130 | +- `include` / `exclude` - 文件过滤规则 |
| 131 | +- `escapeTags` - 跳过的 HTML 标签 |
| 132 | +- `openIn` - IDE 窗口打开方式 |
| 133 | +- `pathType` - 路径类型(相对/绝对) |
| 134 | +- `printServer` - 打印服务器信息 |
| 135 | +- `cache` - 缓存控制 |
| 136 | +- `skipSnippets` - 跳过代码片段注入 |
| 137 | + |
| 138 | +完整配置文档请参考:[code-inspector-plugin 官方文档](https://inspector.fe-dev.cn) |
| 139 | + |
| 140 | +## 支持的 IDE |
| 141 | + |
| 142 | +code、cursor、webstorm、appcode、atom、atom-beta、brackets、code-insiders、codium、colin、emacs、goland、hbuilder、idea、notepad、phpstorm、pycharm、rider、rubymine、sublime、vim、zed |
| 143 | + |
52 | 144 | ## License |
53 | 145 |
|
54 | | -[MIT](./LICENSE). |
| 146 | +[MIT](./LICENSE) |
0 commit comments