whistle.mock-plugins 1.3.1-beta.1 → 1.4.0-beta.0

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/VERSION.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # 🔄 版本更新记录
2
2
 
3
+ ## v1.4.0-beta.0
4
+
5
+ ### ✨ Feature
6
+ - **WebDAV 模块同步**:新增 WebDAV 同步能力,可将功能模块及接口配置同步到 WebDAV 服务器
7
+ - **连接管理**:支持配置 WebDAV 地址与账号密码,支持测试连接、连接、刷新状态与断开连接
8
+ - **推送 / 拉取**:支持按模块推送至远端或从远端拉取,支持强制覆盖(force)并处理远端清单冲突
9
+ - **同步设置开关**:系统设置新增「WebDAV 同步」开关,开启后在功能模块管理页显示同步入口
10
+ - **同步状态展示**:同步弹窗展示连接状态、最近同步时间与远端模块清单
11
+
12
+ ### 🔧 Technical
13
+ - 新增后端 `app/cgi-bin/webdav.js` 与 `lib/webdav-sync.js`,实现 WebDAV 客户端与同步逻辑
14
+ - 新增前端 `ui/src/components/WebDavSyncModal.js` 与 `ui/src/styles/webdav-sync.css`
15
+ - 新增 `ui/src/utils/api-error.js`,统一解析 WebDAV 错误响应
16
+ - 新增 `test/webdav-sync.test.js`、`test/api-error.test.js` 单元测试
17
+
18
+ ## v1.3.1
19
+
20
+ ### ✨ Feature
21
+ - **功能模块批量导出**:支持勾选多个功能模块导出;仅选一个时导出为单个对象(兼容旧版导入),多个时导出为数组
22
+ - **功能模块批量导入**:导入同时兼容单个功能(对象)与多个功能(数组)两种格式
23
+
3
24
  ## v1.3.0
4
25
 
5
26
  ### ✨ Feature
@@ -4,6 +4,7 @@ const path = require('path');
4
4
  const DEFAULT_SETTINGS = {
5
5
  interfaceParamMatcherEnabled: true,
6
6
  responseParamMatcherEnabled: true,
7
+ webDavSyncEnabled: false,
7
8
  };
8
9
 
9
10
  module.exports = function(req, res) {
@@ -0,0 +1,56 @@
1
+ const { createWebDavSync } = require('../../lib/webdav-sync');
2
+
3
+ module.exports = async function(req, res) {
4
+ const webDavSync = createWebDavSync(this.dataDir);
5
+
6
+ try {
7
+ if (req.method == 'GET') {
8
+ return res.json({ code: 0, message: '成功', data: webDavSync.getStatus() });
9
+ }
10
+
11
+ if (req.method != 'POST') {
12
+ return res.status(405).json({ code: 405, message: 'Method Not Allowed', data: null });
13
+ }
14
+
15
+ const { action, force, featureIds, endpoint, username, password } = req.body || {};
16
+ const input = { endpoint, username, password };
17
+ let data;
18
+
19
+ switch (action) {
20
+ case 'test':
21
+ data = await webDavSync.test(input);
22
+ break;
23
+ case 'connect':
24
+ data = await webDavSync.connect(input);
25
+ break;
26
+ case 'refresh':
27
+ data = await webDavSync.refresh();
28
+ break;
29
+ case 'push':
30
+ data = await webDavSync.push({ force: force == true, featureIds });
31
+ break;
32
+ case 'pull':
33
+ data = await webDavSync.pull({ force: force == true, featureIds });
34
+ break;
35
+ case 'disconnect':
36
+ data = webDavSync.disconnect();
37
+ break;
38
+ default:
39
+ return res.status(400).json({ code: 400, message: '不支持的 WebDAV 操作', data: null });
40
+ }
41
+
42
+ return res.json({ code: 0, message: '成功', data });
43
+ } catch (error) {
44
+ const statusCode = error.statusCode || 500;
45
+ console.error(
46
+ `[webdav] ${req.body && req.body.action ? req.body.action : req.method} 失败:`,
47
+ error.message || error.code || error
48
+ );
49
+ return res.status(statusCode).json({
50
+ code: statusCode,
51
+ message: error.message || 'WebDAV 操作失败',
52
+ conflict: error.conflict || null,
53
+ data: null,
54
+ });
55
+ }
56
+ };