whistle.mockbubu 1.0.0-dev.1 → 1.0.0-dev.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 CHANGED
@@ -13,7 +13,7 @@ $ w2 install whistle.mockbubu
13
13
 
14
14
  ### 配置 [whistle 规则](https://avwo.github.io/whistle/rules/)
15
15
 
16
- > mode 有三种选项 pathname | href | pattern,默认是 pathname
16
+ > mode默认使用 pathname
17
17
 
18
18
  ```text
19
19
  pattern mockbubu://[mode]
@@ -28,53 +28,31 @@ pattern mockbubu://[mode]
28
28
  ```text
29
29
  pattern mockbubu:// 或者 pattern mockbubu://pathname
30
30
  ```
31
+ > 配置规则并开启插件后,mockbubu将实时获取匹配到的请求数据
31
32
 
32
- ---
33
-
34
- #### href 模式:使用接口的 路径 作为文件名
35
-
36
- ```text
37
- pattern mockbubu://href
38
-
39
- ```
40
-
41
- ---
42
-
43
- #### pattern 模式:使用 pattern 作为文件名
44
-
45
- ```text
46
- pattern mockbubu://pattern
47
- ```
33
+ ![alt text](https://www.helloimg.com/i/2025/08/08/68959441e385e.png)
48
34
 
49
35
  ---
50
36
 
51
37
  ### 开始 mock
52
38
 
53
- 第一步:开启文件的 mock 开关,系统生成一条规则:
39
+ 第一步:开启文件的 mock 开关,拦截到对应请求mockbubu将直接返回对应匹配请求的数据,开启mock开关后可在Response面板管理文件内容
54
40
 
55
- ```
56
- 文件名 resBody:{文件内容}
57
- ```
58
41
 
59
42
  第二步:在 Response 面板管理文件内容
60
43
 
61
- 手动添加文件
62
-
63
- - 如果需要提前生成 mock 文件,可手动添加(通常不需要手动添加,通过实时捕获接口即可生成 mock 文件)
64
-
65
44
  编辑文件
66
45
 
67
46
  - 支持文件编辑
47
+ - 支持快捷键保存 Mac: Command + s / Windows: Ctrl + s
68
48
 
69
49
  多版本
70
50
 
71
- - 支持新增不同版本的文件内容
51
+ - 支持新增不同版本的文件内容,点击切换不同版本即刻生效返回该版本数据
72
52
  - 其中 source 版本是默认生成的,是原始接口响应数据,支持修改
73
53
 
74
54
  切换 mock 文件
75
55
 
76
56
  - mock 返回内容使用当前选中的版本
77
57
 
78
- ![alt text](step1.png)
79
-
80
- ![alt text](step2.png)
58
+ ![alt text](https://www.helloimg.com/i/2025/08/08/6895944122f24.png)
package/README_EN.md ADDED
@@ -0,0 +1,60 @@
1
+ # whistle.mockbubu
2
+
3
+ whistle.mockbubu is an extension script plugin for [whistle](https://github.com/avwo/whistle) that provides the following features:
4
+
5
+ - Real-time generation of mock files from captured API responses
6
+ - Mock file management
7
+
8
+ # Installation
9
+
10
+ ```bash
11
+ $ w2 install whistle.mockbubu
12
+ ```
13
+
14
+ # Usage
15
+
16
+ ### Configure [whistle rules](https://avwo.github.io/whistle/rules/)
17
+
18
+ > Default mode uses pathname
19
+
20
+ ```text
21
+ pattern mockbubu://[mode]
22
+ ```
23
+
24
+ ### Generate Mock Files
25
+
26
+ ---
27
+
28
+ #### Pathname Mode: Uses the interface's origin + pathname as the filename
29
+
30
+ ```text
31
+ pattern mockbubu:// or pattern mockbubu://pathname
32
+ ```
33
+
34
+ > After configuring the rules and enabling the plugin, mockbubu will capture matching request data in real-time
35
+
36
+ ![alt text](https://www.helloimg.com/i/2025/08/08/68959441e385e.png)
37
+
38
+ ---
39
+
40
+ ### Start Mocking
41
+
42
+ **Step 1:** Enable the mock switch for the file. When mockbubu intercepts the corresponding request, it will directly return the matched request data. After enabling the mock switch, you can manage file content in the Response panel.
43
+
44
+ **Step 2:** Manage file content in the Response panel
45
+
46
+ **Edit Files**
47
+
48
+ - Supports file editing
49
+ - Supports keyboard shortcuts for saving: Mac: Command + S / Windows: Ctrl + S
50
+
51
+ **Multiple Versions**
52
+
53
+ - Supports creating different versions of file content. Click to switch between different versions for instant effect and return that version's data
54
+ - The "source" version is the default generated version containing the original API response data and supports modification
55
+
56
+ **Switch Mock Files**
57
+
58
+ - Mock return content uses the currently selected version
59
+
60
+ ![alt text](https://www.helloimg.com/i/2025/08/08/6895944122f24.png)
package/lib/server.js CHANGED
@@ -95,10 +95,12 @@ module.exports = (server, { storage }) => {
95
95
  setApiListUpdated(storage, true)
96
96
  })
97
97
  }))
98
+
99
+ // 将响应透传给客户端
100
+ svrRes.pipe(res)
98
101
  })
99
102
 
100
103
  req.pipe(client)
101
- req.passThrough()
102
104
  }
103
105
  } catch (error) {
104
106
  req.passThrough()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whistle.mockbubu",
3
- "version": "1.0.0-dev.1",
3
+ "version": "1.0.0-dev.3",
4
4
  "description": "mock response data",
5
5
  "scripts": {
6
6
  "lint": "eslint . --ext .js",
@@ -25,7 +25,7 @@
25
25
  ".gitignore",
26
26
  "index.js",
27
27
  "package.json",
28
- "README.md",
28
+ "*.md",
29
29
  "step1.png",
30
30
  "step2.png"
31
31
  ],
package/public/js/app.js CHANGED
@@ -947,7 +947,8 @@ const __default__ = {
947
947
  element_ui_lib_message__WEBPACK_IMPORTED_MODULE_2___default().error('更新失败');
948
948
  });
949
949
  };
950
- const handleUpdate = () => {
950
+ const handleUpdate = e => {
951
+ e.preventDefault();
951
952
  if (currentFile.value.type === 'history') {
952
953
  updateHistory();
953
954
  } else {
@@ -1535,6 +1536,17 @@ var render = function render() {
1535
1536
  return _setup.handleFileChange();
1536
1537
  }
1537
1538
  },
1539
+ nativeOn: {
1540
+ keydown: [function ($event) {
1541
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "s", undefined, $event.key, undefined)) return null;
1542
+ if (!$event.metaKey) return null;
1543
+ return _setup.handleUpdate.apply(null, arguments);
1544
+ }, function ($event) {
1545
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "s", undefined, $event.key, undefined)) return null;
1546
+ if (!$event.ctrlKey) return null;
1547
+ return _setup.handleUpdate.apply(null, arguments);
1548
+ }]
1549
+ },
1538
1550
  model: {
1539
1551
  value: _setup.currentFile.content,
1540
1552
  callback: function ($$v) {
@@ -1556,9 +1568,7 @@ var render = function render() {
1556
1568
  type: "primary"
1557
1569
  },
1558
1570
  on: {
1559
- click: function ($event) {
1560
- return _setup.handleUpdate();
1561
- }
1571
+ click: _setup.handleUpdate
1562
1572
  }
1563
1573
  }, [_vm._v(" Save ")])], 1) : _vm._e()], 1), _c("el-dialog", {
1564
1574
  attrs: {