Skip to content

余额查询在 macOS/Linux 上必定失败(无法启动查询进程):仅尝试了 Windows 二进制 curl.exe / powershell.exe #3

Description

@zailaiyiping

现象

在 macOS(Apple Silicon)上,账户余额卡片显示「查询失败 / 余额查询失败(无法启动查询进程)」,点"刷新"重试无效;热力图、Token 统计、工作区别名等其他功能均正常。

原因

lib/index.jsfetchBalance() 只尝试两个外部进程候选,均为 Windows 专用二进制

const attempts = [
  { argv: ['curl.exe', ...], ... },        // Windows 版 curl
  { argv: ['powershell.exe', ...], ... },  // Windows PowerShell
]

在 macOS / Linux 上 curl.exepowershell.exe 都不存在,subprocess.spawn 启动即失败,runAttempt 返回 null,最终 lastDiag = '无法启动查询进程'。这是平台相关的 bug,与 API Key 是否有效无关(Key 已正确解析,只是卡在"启动进程"这一步),所以 Windows 上正常、macOS/Linux 上必定失败。

建议修复

按平台选择候选命令:Windows 维持原 curl.exepowershell.exe;其他平台改用 curlnode -e(宿主 Node 内置 fetch)兜底。以下改动已在 macOS 上本地验证通过(余额可正常返回):

const isWindows = process.platform === 'win32'
const nodeBin = typeof process.execPath === 'string' && process.execPath.length > 0 ? process.execPath : 'node'
const nodeScript = "fetch('https://api.deepseek.com/user/balance',{headers:{Accept:'application/json',Authorization:'Bearer '+process.env.DSH_UBK}}).then(async(r)=>{process.stdout.write(await r.text())}).catch((e)=>{console.error(String(e));process.exit(1)})"
const attempts = isWindows
  ? [
      { argv: ['curl.exe', '-sS', '-L', '-m', '30', '-H', 'Accept: application/json', '-H', 'Authorization: Bearer ' + key, url], env: undefined },
      { argv: ['powershell.exe', '-NoProfile', '-NonInteractive', '-Command', psCommand], env: { DSH_UBK: key } },
    ]
  : [
      { argv: ['curl', '-sS', '-L', '-m', '30', '-H', 'Accept: application/json', '-H', 'Authorization: Bearer ' + key, url], env: undefined },
      { argv: [nodeBin, '-e', nodeScript], env: { DSH_UBK: key } },
    ]

环境

  • macOS 25.5 (arm64)
  • dsh web profile,插件 v1.0.0(github:Make0209/dsh-usage-stats

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions