mock-service-cli 3.6.5 → 3.7.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/README.md CHANGED
@@ -52,27 +52,28 @@ npx mock-service-cli [options] [path]
52
52
 
53
53
  ## 🛠️ 命令行选项
54
54
 
55
- | 选项 | 描述 | 默认值 |
56
- | -------------------------- | ----------------------------------------------------------- | ------ |
57
- | `-h` 或 `--help` | 显示帮助信息 | - |
58
- | `-p` 或 `--port` | Mock 服务器端口 | 8090 |
59
- | `-d` | 指定 mock 目录 | ./mock |
60
- | `-f` | 指定单个 mock 文件 | - |
61
- | `-s` 或 `--silent` | 抑制日志输出 | - |
62
- | `-v` 或 `--version` | 显示版本信息 | - |
63
- | `-S` 或 `--socket-server` | 启动 socket 服务器,用于保存 API 响应数据 | false |
64
- | `-a` 或 `--api-stat` | 打印 API URL 和文件路径信息 | false |
65
- | `-t` 或 `--track` | 记录操作信息到文件 | false |
66
- | `-o` 或 `--cors-origin` | 配置 CORS 允许的源,多个源用逗号分隔 | \* |
67
- | `-O` 或 `--proxy-options` | 配置 HTTP 请求代理选项,支持 js 文件、json 文件或命令行参数 | - |
68
- | `-H` 或 `--cors-headers` | 配置 CORS 头信息 | \* |
69
- | `-A` 或 `--append-headers` | 添加响应头信息,多个头用逗号分隔 | - |
70
- | `-D` 或 `--web-dir` | 启用 Web 服务器,指定 web 目录(SPA 应用) | - |
71
- | `-P` 或 `--web-port` | Web 服务器端口 | 9090 |
72
- | `-b` 或 `--web-baseurl` | 指定 SPA Web 服务器的公共路径 | - |
73
- | `-R` 或 `--static-server` | 启用静态服务器,指定静态资源目录 | - |
74
- | `-w` 或 `--open` | 自动打开 API 概览页、文件浏览器页 | false |
75
- | `-e` 或 `--explorer` | 启用文件浏览器服务器,指定要浏览的目录 | ./ |
55
+ | 选项 | 描述 | 默认值 |
56
+ | -------------------------- | ----------------------------------------------------------------- | ------ |
57
+ | `-h` 或 `--help` | 显示帮助信息 | - |
58
+ | `-p` 或 `--port` | Mock 服务器端口 | 8090 |
59
+ | `-d` | 指定 mock 目录 | ./mock |
60
+ | `-f` | 指定单个 mock 文件 | - |
61
+ | `-s` 或 `--silent` | 抑制日志输出 | - |
62
+ | `-v` 或 `--version` | 显示版本信息 | - |
63
+ | `-S` 或 `--socket-server` | 启动 socket 服务器,用于保存 API 响应数据 | false |
64
+ | `-a` 或 `--api-stat` | 打印 API URL 和文件路径信息 | false |
65
+ | `-t` 或 `--track` | 记录操作信息到文件 | false |
66
+ | `-o` 或 `--cors-origin` | 配置 CORS 允许的源,多个源用逗号分隔 | \* |
67
+ | `-O` 或 `--proxy-options` | 配置 HTTP 请求代理选项,支持 js 文件、json 文件或命令行参数 | - |
68
+ | `-r` 或 `--rewrite` | rewrite http or https request url prefix of proxy, default false. | false |
69
+ | `-H` 或 `--cors-headers` | 配置 CORS 头信息 | \* |
70
+ | `-A` 或 `--append-headers` | 添加响应头信息,多个头用逗号分隔 | - |
71
+ | `-D` 或 `--web-dir` | 启用 Web 服务器,指定 web 目录(SPA 应用) | - |
72
+ | `-P` 或 `--web-port` | Web 服务器端口 | 9090 |
73
+ | `-b` 或 `--web-baseurl` | 指定 SPA Web 服务器的公共路径 | - |
74
+ | `-R` 或 `--static-server` | 启用静态服务器,指定静态资源目录 | - |
75
+ | `-w` 或 `--open` | 自动打开 API 概览页、文件浏览器页 | false |
76
+ | `-e` 或 `--explorer` | 启用文件浏览器服务器,指定要浏览的目录 | ./ |
76
77
 
77
78
  ## 📖 使用示例
78
79
 
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="zh-CN">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
@@ -379,6 +379,9 @@
379
379
  font-size: 10px;
380
380
  color: #999;
381
381
  }
382
+ .birthtime {
383
+ padding-right: 4px;
384
+ }
382
385
 
383
386
  .list-view .file-meta {
384
387
  display: flex;
@@ -751,6 +754,14 @@
751
754
  >
752
755
  👁️
753
756
  </button>
757
+ <button
758
+ class="toggle-hidden-btn"
759
+ id="toggleBirthtimeBtn"
760
+ onclick="toggleBirthtimeFiles()"
761
+ title="显示/隐藏创建时间"
762
+ >
763
+ ⌛️
764
+ </button>
754
765
  <div class="stats-info" id="statsInfo"></div>
755
766
  <div class="search-box">
756
767
  <input type="text" id="searchInput" placeholder="搜索文件名..." oninput="handleSearch()" />
@@ -803,6 +814,7 @@
803
814
  let sortBy = 'name';
804
815
  let sortAscending = true;
805
816
  let showHiddenFiles = true;
817
+ let showBirthtime = false;
806
818
  let currentPreviewContent = '';
807
819
  let currentZoom = 1;
808
820
  let currentRotation = 0;
@@ -1058,10 +1070,16 @@
1058
1070
  function updateStatsInfo(files) {
1059
1071
  const statsInfo = document.getElementById('statsInfo');
1060
1072
  if (!statsInfo) return;
1061
-
1062
- const dirCount = files.filter(f => f.isDirectory).length;
1073
+ let fileTotalSize = 0;
1074
+ const dirCount = files.filter(f => {
1075
+ if (!f.isDirectory) {
1076
+ fileTotalSize += f.size;
1077
+ }
1078
+ return f.isDirectory;
1079
+ }).length;
1063
1080
  const fileCount = files.length - dirCount;
1064
- statsInfo.textContent = `${dirCount} 个文件夹, ${fileCount} 个文件`;
1081
+ const totalSize = formatSize(fileTotalSize);
1082
+ statsInfo.textContent = `${dirCount} 个文件夹, ${fileCount} 个文件 (${totalSize})`;
1065
1083
  }
1066
1084
 
1067
1085
  function processAndRenderFiles() {
@@ -1116,6 +1134,18 @@
1116
1134
  updateStatsInfo(files);
1117
1135
  renderFiles(files);
1118
1136
  }
1137
+ function toggleBirthtimeFiles() {
1138
+ showBirthtime = !showBirthtime;
1139
+ const btn = document.getElementById('toggleBirthtimeBtn');
1140
+ if (!showBirthtime) {
1141
+ btn.classList.remove('active');
1142
+ btn.title = '显示创建时间';
1143
+ } else {
1144
+ btn.classList.add('active');
1145
+ btn.title = '隐藏创建时间';
1146
+ }
1147
+ processAndRenderFiles();
1148
+ }
1119
1149
 
1120
1150
  function toggleHiddenFiles() {
1121
1151
  showHiddenFiles = !showHiddenFiles;
@@ -1212,11 +1242,14 @@
1212
1242
 
1213
1243
  function renderFiles(files) {
1214
1244
  const fileGrid = document.getElementById('fileGrid');
1245
+ const toggleBirthtimeBtn = document.getElementById('toggleBirthtimeBtn');
1215
1246
 
1216
1247
  // 确保视图类名正确
1217
1248
  if (currentView === 'list') {
1218
1249
  fileGrid.classList.add('list-view');
1250
+ toggleBirthtimeBtn.style.display = 'inline-block';
1219
1251
  } else {
1252
+ toggleBirthtimeBtn.style.display = 'none';
1220
1253
  fileGrid.classList.remove('list-view');
1221
1254
  }
1222
1255
 
@@ -1231,6 +1264,7 @@
1231
1264
  const icon = getFileIcon(file);
1232
1265
  const size = formatSize(file.size);
1233
1266
  const mtime = formatDate(file.mtime);
1267
+ const birthtime = formatDate(file.birthtime);
1234
1268
  const hiddenClass = file.isHidden ? 'hidden-file' : '';
1235
1269
 
1236
1270
  const fileItem = document.createElement('div');
@@ -1246,6 +1280,7 @@
1246
1280
  <div class="file-meta">
1247
1281
  ${file.isDirectory ? '<span>目录</span>' : `<span>${size}</span>`}
1248
1282
  <span>${mtime}</span>
1283
+ <span class="birthtime" style="display: ${showBirthtime ? 'inline-block' : 'none'};">${birthtime}</span>
1249
1284
  </div>
1250
1285
  </div>
1251
1286
  <div class="action-buttons">
@@ -1390,6 +1425,7 @@
1390
1425
  return {
1391
1426
  size: file.size,
1392
1427
  mtime: file.mtime,
1428
+ birthtime: file.birthtime,
1393
1429
  name: file.name
1394
1430
  };
1395
1431
  }
@@ -103,6 +103,7 @@ function init() {
103
103
  isDirectory: isDirectory,
104
104
  size: hasError ? 0 : fileStats.size,
105
105
  mtime: hasError ? new Date() : fileStats.mtime,
106
+ birthtime: hasError ? new Date() : fileStats.birthtime,
106
107
  isHidden: file.name.startsWith('.'),
107
108
  error: hasError ? 'Cannot access file' : null
108
109
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mock-service-cli",
3
- "version": "3.6.5",
3
+ "version": "3.7.0",
4
4
  "description": "🦅 Local Mock/Static/SPA server, Http?s request proxy, API overview page, File explorer",
5
5
  "main": "./lib/mockServer.js",
6
6
  "bin": {