code-inspector-plugin 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -139
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
<p align="center">
|
|
5
5
|
<h2>code-inspector-plugin</h2>
|
|
6
6
|
<span>中文文档</span> |
|
|
7
|
-
<a href="https://github.com/zh-lx/code-inspector/blob/main/docs/README-EN.md">English Doc</a>
|
|
7
|
+
<a href="https://github.com/zh-lx/code-inspector/blob/main/docs/README-EN.md">English Doc</a> |
|
|
8
|
+
<a href="https://inspector.fe-dev.cn">在线文档</a>
|
|
8
9
|
</p>
|
|
9
10
|
|
|
10
11
|
[](https://www.npmjs.com/package/code-inspector-plugin)
|
|
@@ -33,143 +34,7 @@ pnpm add code-inspector-plugin -D
|
|
|
33
34
|
|
|
34
35
|
## 🌈 使用
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### 1. 配置 webpack/vite
|
|
39
|
-
|
|
40
|
-
- <b>webpack 中使用</b>,在 `vue.config.js` 或者 `webpack.config.js` 添加如下配置:
|
|
41
|
-
|
|
42
|
-
`vue.config.js`:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
// vue.config.js
|
|
46
|
-
const { CodeInspectorPlugin } = require('code-inspector-plugin');
|
|
47
|
-
|
|
48
|
-
module.exports = {
|
|
49
|
-
// ...other code
|
|
50
|
-
chainWebpack: (config) => {
|
|
51
|
-
config.plugin('code-inspector-plugin').use(
|
|
52
|
-
CodeInspectorPlugin({
|
|
53
|
-
bundler: 'webpack',
|
|
54
|
-
})
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
`webpack.config.js`:
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
// webpack.config.js
|
|
64
|
-
const { CodeInspectorPlugin } = require('code-inspector-plugin');
|
|
65
|
-
|
|
66
|
-
module.exports = (env = {}) => ({
|
|
67
|
-
plugins: [
|
|
68
|
-
CodeInspectorPlugin({
|
|
69
|
-
bundler: 'webpack',
|
|
70
|
-
}),
|
|
71
|
-
],
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
- <b>vite 中使用</b>,在 `vite.config.js` 中添加如下配置:
|
|
76
|
-
|
|
77
|
-
```js
|
|
78
|
-
// vite.config.js
|
|
79
|
-
import { defineConfig } from 'vite';
|
|
80
|
-
import { CodeInspectorPlugin } from 'code-inspector-plugin';
|
|
81
|
-
|
|
82
|
-
// https://vitejs.dev/config/
|
|
83
|
-
export default defineConfig({
|
|
84
|
-
plugins: [
|
|
85
|
-
CodeInspectorPlugin({
|
|
86
|
-
bundler: 'vite',
|
|
87
|
-
}),
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### 2. 使用代码审查
|
|
93
|
-
|
|
94
|
-
目前使用代码审查功能的方式有两种:
|
|
95
|
-
|
|
96
|
-
1. 【推荐】同时持续按住组合键进行代码审查。 (Mac 系统默认组合键是 `Option + Shift`;Window 的默认组合键是 `Alt + Shift`)
|
|
97
|
-
2. 点击页面上的 Code Inspector 开关按钮。当开关的颜色变成彩色时,表示代码审查模式打开 <img src="https://github.com/zh-lx/code-inspector/assets/73059627/842c3e88-dca7-4743-854c-d61093d3d34f" width="20" />;当开关颜色变成黑白时,表示代码审查模式关闭 <img src="https://user-images.githubusercontent.com/73059627/230129864-e2813188-8d49-4a8e-a6bc-dda19c79b491.png" width="20" />。(Code Inspector 开关按钮 <img src="https://github.com/zh-lx/code-inspector/assets/73059627/842c3e88-dca7-4743-854c-d61093d3d34f" width="20" /> 默认隐藏,需要配置 `showSwitch: true` 才会在页面显示。)
|
|
98
|
-
|
|
99
|
-
当代码审查模式打开时,点击页面上的元素,将自动打开你的代码编辑器并将光标定位到元素对应的代码位置。
|
|
100
|
-
|
|
101
|
-
### 3. 配置命令行工具(仅当 Mac + Vscode 需要配置此步)
|
|
102
|
-
|
|
103
|
-
如果你的编辑器是 VSCode 且系统为 MacOS,需要进行如下配置:
|
|
104
|
-
|
|
105
|
-
- 在 VSCode 中执行 `command + shift + p`(mac) 或 `ctrl + shift + p`(windows) 命令, 搜索 指令并点击 `shell Command: Install 'code' command in Path`:
|
|
106
|
-
|
|
107
|
-
<img src="https://s3.bmp.ovh/imgs/2021/08/a99ec7b8e93f55fd.png" width="60%" />
|
|
108
|
-
|
|
109
|
-
- 如果出现如下弹窗,说明配置成功了:
|
|
110
|
-
|
|
111
|
-
<img src="https://s3.bmp.ovh/imgs/2021/08/c3d00a8efbb20feb.png" width="40%" />
|
|
112
|
-
|
|
113
|
-
## 🎨 可选配置
|
|
114
|
-
|
|
115
|
-
| 参数 | 描述 | 是否必传 | 类型 | 可选值 | 默认值 |
|
|
116
|
-
| ---------- | ---------------------------------------------------------- | -------- | ------------------- | -------------------------------------------------------------------- | ------------------------ |
|
|
117
|
-
| bundler | 指定的打包工具 | 是 | `string` | `vite/webpack` | - |
|
|
118
|
-
| showSwitch | 是否展示功能开关 | 否 | `boolean` | `true/false` | `false` |
|
|
119
|
-
| hotKeys | 组合键触发功能,为 `false` 或者空数组则关闭组合键触发 | 否 | `string[] \| false` | Array<`'ctrlKey'`\|`'altKey'`\|`'metaKey'`\|`'shiftKey'`> \| `false` | `['altKey', 'shiftKey']` |
|
|
120
|
-
| autoToggle | 打开功能开关的情况下,点击触发跳转编辑器时是否自动关闭开关 | 否 | `boolean` | `true/false` | `true` |
|
|
121
|
-
|
|
122
|
-
## 🎯 指定 IDE
|
|
123
|
-
|
|
124
|
-
默认情况下,`code-inspector-plugin` 会自动识别当前系统运行中的 IDE 程序并按照优先级打开识别到的第一个。如果你有多种不同的 IDE,你可以指定要打开的 IDE,在项目根目录添加一个名为 `.env.local` 的文件并添加: `CODE_EDITOR=[IDE编码名称]`。
|
|
125
|
-
|
|
126
|
-
以 vscode 为例,它的`IDE编码名称`是 `code`,则对应在 `.env.local` 中添加如下内容:
|
|
127
|
-
|
|
128
|
-
```perl
|
|
129
|
-
# 指定 IDE 为 vscode
|
|
130
|
-
CODE_EDITOR=code
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
IDE 及对应的`IDE编码名称`对照表如下:
|
|
134
|
-
|
|
135
|
-
<table>
|
|
136
|
-
<tr>
|
|
137
|
-
<th>IDE</th>
|
|
138
|
-
<th>IDE编码名称</th>
|
|
139
|
-
</tr>
|
|
140
|
-
<tr>
|
|
141
|
-
<td>Visual Studio Code(vscode)</td>
|
|
142
|
-
<td>code</td>
|
|
143
|
-
</tr>
|
|
144
|
-
<tr>
|
|
145
|
-
<td>Visual Studio Code - Insiders(vscode 内部版)</td>
|
|
146
|
-
<td>code_insiders</td>
|
|
147
|
-
</tr>
|
|
148
|
-
<tr>
|
|
149
|
-
<td>WebStorm</td>
|
|
150
|
-
<td>webstorm</td>
|
|
151
|
-
</tr>
|
|
152
|
-
<tr>
|
|
153
|
-
<td>Atom</td>
|
|
154
|
-
<td>atom</td>
|
|
155
|
-
</tr>
|
|
156
|
-
<tr>
|
|
157
|
-
<td>HBuilderX</td>
|
|
158
|
-
<td>hbuilder</td>
|
|
159
|
-
</tr>
|
|
160
|
-
<tr>
|
|
161
|
-
<td>PhpStorm</td>
|
|
162
|
-
<td>phpstorm</td>
|
|
163
|
-
</tr>
|
|
164
|
-
<tr>
|
|
165
|
-
<td>Pycharm</td>
|
|
166
|
-
<td>pycharm</td>
|
|
167
|
-
</tr>
|
|
168
|
-
<tr>
|
|
169
|
-
<td>IntelliJ IDEA</td>
|
|
170
|
-
<td>idea</td>
|
|
171
|
-
</tr>
|
|
172
|
-
</table>
|
|
37
|
+
完整的接入及使用方式请查看:[code-inspector-plugin 配置](https://inspector.fe-dev.cn/guide/start.html#%E9%85%8D%E7%BD%AE)
|
|
173
38
|
|
|
174
39
|
## 🎨 支持列表
|
|
175
40
|
|
|
@@ -190,6 +55,6 @@ IDE 及对应的`IDE编码名称`对照表如下:
|
|
|
190
55
|
任何使用问题可以加入 QQ 群 `769748484` 或者添加作者微信 `zhoulx1688888` 进行咨询与反馈:
|
|
191
56
|
|
|
192
57
|
<div style="display: flex;">
|
|
193
|
-
<img src="https://github.com/zh-lx/code-inspector/assets/73059627/
|
|
58
|
+
<img src="https://github.com/zh-lx/code-inspector/assets/73059627/1ffb57e0-d511-4981-bc06-cf16f8793fd8" width="200" />
|
|
194
59
|
<img src="https://user-images.githubusercontent.com/73059627/226233691-848b2a40-f1a9-414e-a80f-3fc6c6209eb1.png" width="200" />
|
|
195
60
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-inspector-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"homepage": "https://
|
|
26
|
+
"homepage": "https://inspector.fe-dev.cn/",
|
|
27
27
|
"description": "点击页面上的元素,将自动打开你的代码编辑器并将光标定位到元素对应的代码位置。",
|
|
28
28
|
"keywords": [
|
|
29
29
|
"webpack",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"chalk": "4.1.1",
|
|
42
|
-
"code-inspector-core": "0.1.
|
|
43
|
-
"webpack-code-inspector-plugin": "0.1.
|
|
44
|
-
"vite-code-inspector-plugin": "0.1.
|
|
42
|
+
"code-inspector-core": "0.1.3",
|
|
43
|
+
"webpack-code-inspector-plugin": "0.1.3",
|
|
44
|
+
"vite-code-inspector-plugin": "0.1.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^16.0.1",
|