mihomo-cli 2.7.2 → 2.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.7.3] - 2026-05-04
4
+
5
+ ### 改进
6
+
7
+ - **代码清理** - 提取 `DEFAULT_CLEAN_ROUNDS` 常量,消除重复魔数;简化进度条内部状态
8
+
9
+ ---
10
+
3
11
  ## [2.7.2] - 2026-05-04
4
12
 
5
13
  ### 修复
package/dist/index.js CHANGED
@@ -4433,6 +4433,7 @@ import path6 from "path";
4433
4433
 
4434
4434
  // src/subscription.ts
4435
4435
  var DEFAULT_UPDATE_INTERVAL_HOURS = 4;
4436
+ var DEFAULT_CLEAN_ROUNDS = 3;
4436
4437
  var YAML_DUMP_OPTS = { indent: 2, lineWidth: -1, noCompatMode: true };
4437
4438
  var HTTP_CLIENT2 = createHttpClient({ timeout: 6e4 });
4438
4439
  function isMultiUrl(url) {
@@ -4812,7 +4813,7 @@ function cleanDeadProxies(parsed, deadNames) {
4812
4813
  }
4813
4814
  async function autoCleanSubscription(subName, options = {}) {
4814
4815
  const parsed = loadSubscriptionConfig(subName);
4815
- const { onResult, onRetryRound, rounds = 3, ...testOptions } = options;
4816
+ const { onResult, onRetryRound, rounds = DEFAULT_CLEAN_ROUNDS, ...testOptions } = options;
4816
4817
  const wrapOnResult = (round) => onResult ? (r, i, t) => onResult(r, i, t, round) : void 0;
4817
4818
  const summary = await testSubscriptionProxies(subName, {
4818
4819
  ...testOptions,
@@ -5045,7 +5046,6 @@ var BAR_WIDTH = 20;
5045
5046
  function createProgressPrinter(totalRounds = 1) {
5046
5047
  let alive = 0;
5047
5048
  let dead = 0;
5048
- let started = false;
5049
5049
  const resultMap = /* @__PURE__ */ new Map();
5050
5050
  function render(done, total) {
5051
5051
  if (!IS_TTY) return;
@@ -5056,11 +5056,8 @@ function createProgressPrinter(totalRounds = 1) {
5056
5056
  }
5057
5057
  return {
5058
5058
  onResult(result, index, total, round = 1) {
5059
- if (!started) {
5060
- started = true;
5061
- if (totalRounds > 1) {
5062
- console.log(`--- \u7B2C 1 \u8F6E\u6D4B\u8BD5 (${total} \u4E2A\u8282\u70B9) ---`);
5063
- }
5059
+ if (resultMap.size === 0 && totalRounds > 1) {
5060
+ console.log(`--- \u7B2C 1 \u8F6E\u6D4B\u8BD5 (${total} \u4E2A\u8282\u70B9) ---`);
5064
5061
  }
5065
5062
  if (result.delay !== null) alive++;
5066
5063
  else dead++;
@@ -5389,7 +5386,7 @@ async function cmdSubscription(args) {
5389
5386
  }
5390
5387
  if (action === "clean") {
5391
5388
  const { target, timeout, concurrency } = resolveTestTarget(args);
5392
- const rounds = parseIntArg(args, "-r", "--rounds", 3);
5389
+ const rounds = parseIntArg(args, "-r", "--rounds", DEFAULT_CLEAN_ROUNDS);
5393
5390
  console.log(`\u6E05\u7406\u8BA2\u9605 "${target.name}"...`);
5394
5391
  console.log(`\u8D85\u65F6: ${timeout}ms \u5E76\u53D1: ${concurrency}`);
5395
5392
  console.log("");
@@ -5500,7 +5497,7 @@ async function cmdStart(args) {
5500
5497
  console.log(`\u8282\u70B9\u6570 ${configInfo.proxies} \u8D85\u8FC7 ${AUTO_CLEAN_THRESHOLD}\uFF0C\u81EA\u52A8\u6E05\u7406...`);
5501
5498
  console.log("");
5502
5499
  await sleep(1e3);
5503
- const progress = createProgressPrinter(3);
5500
+ const progress = createProgressPrinter(DEFAULT_CLEAN_ROUNDS);
5504
5501
  const cleanResult = await autoCleanSubscription(sub.name, {
5505
5502
  onResult: progress.onResult,
5506
5503
  onRetryRound: progress.onRetryRound
@@ -5812,7 +5809,7 @@ async function cmdClean(args) {
5812
5809
  const activeSub = requireActiveSub();
5813
5810
  const timeout = parseIntArg(args, "-t", "--timeout", 1500);
5814
5811
  const concurrency = parseIntArg(args, "-j", "--concurrency", 100);
5815
- const rounds = parseIntArg(args, "-r", "--rounds", 3);
5812
+ const rounds = parseIntArg(args, "-r", "--rounds", DEFAULT_CLEAN_ROUNDS);
5816
5813
  console.log(`\u6E05\u7406 "${activeSub.name}" \u5931\u8D25\u8282\u70B9...`);
5817
5814
  console.log(`\u8D85\u65F6: ${timeout}ms \u5E76\u53D1: ${concurrency}`);
5818
5815
  console.log("");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mihomo-cli",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "type": "module",
5
5
  "description": "A terminal-based mihomo (Clash.Meta) client for macOS",
6
6
  "bin": {