dudu-converter-cli 1.0.6 → 1.0.8

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.
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>嘟嘟转换器 · 本地万能文件转换</title>
7
- <script type="module" crossorigin src="/assets/index-DHhDe2lo.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-Dtm93uHj.css">
7
+ <script type="module" crossorigin src="/assets/index-crdoK3FU.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-D0N1_kqG.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="app"></div>
@@ -1,8 +1,10 @@
1
- # 嘟嘟转换器(dudu-converter-cli)Windows 一键安装脚本(PowerShell 5.1+)
2
- # 用法:$w=New-Object Net.WebClient;$w.Encoding=[Text.Encoding]::UTF8;iex $w.DownloadString('https://duduer.com/install.ps1')
1
+ # DuDu Converter (dudu-converter-cli) Windows installer (PowerShell 5.1+)
2
+ # Usage: $w=New-Object Net.WebClient;$w.Encoding=[Text.Encoding]::UTF8;iex $w.DownloadString('https://duduer.com/install.ps1')
3
+ # NOTE: All messages are in English to avoid encoding issues in PS 5.1 (Chinese Windows defaults to GBK console).
4
+ # The Chinese user experience lives in the web UI at http://127.0.0.1:3456
3
5
  $ErrorActionPreference = 'Stop'
4
6
 
5
- # 中文控制台双保险:代码页切 UTF-8 + 输出编码切 UTF-8
7
+ # Ensure UTF-8 console (for any Chinese output from Node.js subprocesses like `converter autostart enable`)
6
8
  try { chcp.com 65001 | Out-Null } catch { }
7
9
  try {
8
10
  [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
@@ -15,11 +17,11 @@ function Say($msg) { Write-Host $msg -ForegroundColor Green }
15
17
  function Warn($msg) { Write-Host $msg -ForegroundColor Yellow }
16
18
  function Show-Manual {
17
19
  Write-Host ''
18
- Warn '自动安装未完成,可按以下步骤手动安装:'
19
- Write-Host ' 1. 打开 https://nodejs.org 下载并安装 Node.js 18 或更高版本(安装时保持默认选项)'
20
- Write-Host ' 2. 重新打开 PowerShell,执行: npm install -g dudu-converter-cli'
21
- Write-Host ' 3. 启动服务: converter start'
22
- Write-Host ' 4. 浏览器访问 http://127.0.0.1:3456'
20
+ Warn 'Automatic installation did not complete. Manual steps:'
21
+ Write-Host ' 1. Download Node.js 18+ from https://nodejs.org (or a CN mirror like https://mirrors.ustc.edu.cn/node/) and install'
22
+ Write-Host ' 2. Open a NEW PowerShell window, run: npm install -g dudu-converter-cli'
23
+ Write-Host ' 3. Start the service: converter start'
24
+ Write-Host ' 4. Open http://127.0.0.1:3456 in your browser'
23
25
  }
24
26
  function Die($msg) { Write-Host $msg -ForegroundColor Red; Show-Manual; exit 1 }
25
27
 
@@ -39,54 +41,66 @@ function Refresh-Path {
39
41
  }
40
42
 
41
43
  if (Test-Node) {
42
- Say "检测到 Node $(node -v),满足要求(需 18+),跳过安装"
44
+ Say "Found Node $(node -v) (18+ required) - skipping Node installation"
43
45
  } else {
44
- Say '未检测到 Node.js 18+,准备安装…'
46
+ Say 'Node.js 18+ not found, installing...'
45
47
  if (Get-Command winget -ErrorAction SilentlyContinue) {
46
48
  winget install --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements
47
- if ($LASTEXITCODE -ne 0) { Die 'Node.js 安装失败' }
49
+ if ($LASTEXITCODE -ne 0) { Die 'Node.js installation via winget failed' }
48
50
  }
49
51
  elseif (Get-Command choco -ErrorAction SilentlyContinue) {
50
52
  choco install nodejs-lts -y
51
- if ($LASTEXITCODE -ne 0) { Die 'Node.js 安装失败' }
53
+ if ($LASTEXITCODE -ne 0) { Die 'Node.js installation via Chocolatey failed' }
52
54
  }
53
55
  elseif (Get-Command scoop -ErrorAction SilentlyContinue) {
54
56
  scoop install nodejs-lts
55
- if ($LASTEXITCODE -ne 0) { Die 'Node.js 安装失败' }
57
+ if ($LASTEXITCODE -ne 0) { Die 'Node.js installation via Scoop failed' }
56
58
  }
57
59
  else {
58
- Say '未检测到 winget / choco / scoop,直接下载 Node.js 官方安装包…'
60
+ Say 'No package manager found, downloading Node.js installer directly...'
59
61
  $nodeArch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
60
- $msiUrl = "https://nodejs.org/dist/v22.20.0/node-v22.20.0-$nodeArch.msi"
62
+ # CN mirror first (USTC, tested ~0.1s), fallback to official
61
63
  $msiFile = Join-Path $env:TEMP 'dudu-node-installer.msi'
62
- Invoke-WebRequest -Uri $msiUrl -OutFile $msiFile -UseBasicParsing
63
- Say '正在安装 Node.js(可能弹出系统授权窗口,请点「是」)…'
64
+ $mirrors = @(
65
+ "https://mirrors.ustc.edu.cn/node/v22.20.0/node-v22.20.0-$nodeArch.msi",
66
+ "https://nodejs.org/dist/v22.20.0/node-v22.20.0-$nodeArch.msi"
67
+ )
68
+ $downloaded = $false
69
+ foreach ($u in $mirrors) {
70
+ try {
71
+ Say " Trying: $u"
72
+ Invoke-WebRequest -Uri $u -OutFile $msiFile -UseBasicParsing
73
+ $downloaded = $true
74
+ break
75
+ } catch { Warn ' Mirror unreachable, trying next...' }
76
+ }
77
+ if (-not $downloaded) { Die 'Node.js download failed from all mirrors' }
78
+ Say 'Installing Node.js (a UAC prompt may appear, click "Yes")...'
64
79
  Start-Process msiexec.exe -ArgumentList '/i', $msiFile, '/qn' -Verb RunAs -Wait
65
80
  }
66
- # 刚安装的 Node 不会出现在当前会话的 PATH 中,需从注册表重新加载
67
81
  Refresh-Path
68
- if (-not (Test-Node)) { Die 'Node.js 安装后仍未检测到,请重新打开 PowerShell 再执行本脚本' }
82
+ if (-not (Test-Node)) { Die 'Node.js installed but not detected. Please reopen PowerShell and re-run this script' }
69
83
  }
70
84
 
71
- Say "正在安装嘟嘟转换器($PackageSpec)…"
85
+ Say "Installing DuDu Converter ($PackageSpec)..."
72
86
  npm install -g $PackageSpec
73
- if ($LASTEXITCODE -ne 0) { Die '安装失败,请检查网络后重试' }
87
+ if ($LASTEXITCODE -ne 0) { Die 'npm install failed. Please check your network and retry' }
74
88
 
75
89
  Refresh-Path
76
90
  $converter = Get-Command converter -ErrorAction SilentlyContinue
77
- if (-not $converter) { Die '安装完成但找不到 converter 命令,请重新打开 PowerShell 后执行:converter start' }
78
- Say "安装成功:converter $(converter --version)"
91
+ if (-not $converter) { Die 'Installed but converter command not found. Please reopen PowerShell and run: converter start' }
92
+ Say "Installed: converter $(converter --version)"
79
93
 
80
94
  if ($env:NO_START -eq '1') {
81
- Say '已跳过启动。之后可随时运行:converter start'
95
+ Say 'Skipped startup. Run anytime: converter start'
82
96
  exit 0
83
97
  }
84
98
 
85
- Say '正在开启开机自启…'
99
+ Say 'Enabling auto-start on login...'
86
100
  converter autostart enable
87
- if ($LASTEXITCODE -ne 0) { Warn '开机自启开启失败(不影响本次使用),可稍后在终端执行:converter autostart enable' }
101
+ if ($LASTEXITCODE -ne 0) { Warn 'Auto-start setup failed (non-fatal). Run later: converter autostart enable' }
88
102
 
89
- Say '正在启动服务,浏览器将自动打开…'
103
+ Say 'Starting service, browser will open...'
90
104
  Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'converter', 'start'
91
105
  Start-Sleep -Seconds 2
92
- Say '完成!若浏览器未自动打开,请访问 http://127.0.0.1:3456'
106
+ Say 'Done! If browser did not open, visit http://127.0.0.1:3456'
@@ -33,12 +33,14 @@ if command -v node >/dev/null 2>&1; then
33
33
  fi
34
34
  fi
35
35
  if [ "$node_major" -lt 18 ]; then
36
- # 裸机也全自动:直接下载 Node.js 官方 pkg 安装(不依赖 Homebrew)
36
+ # 裸机也全自动:直接下载 Node.js pkg 安装(不依赖 Homebrew)。
37
+ # 国内网络优先走中科大镜像(实测 0.1s 响应),失败自动回退官方源
37
38
  NODE_VERSION="22.20.0"
38
- NODE_PKG_URL="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg"
39
39
  PKG_FILE="${TMPDIR:-/tmp}/dudu-node-installer.pkg"
40
- say "未检测到 Node.js 18+,正在下载官方安装包(约 70MB)…"
41
- curl -fsSL "$NODE_PKG_URL" -o "$PKG_FILE" || die "Node.js 安装包下载失败,请检查网络后重试,或到 https://nodejs.org 下载安装"
40
+ say "未检测到 Node.js 18+,正在下载安装包(约 70MB,国内镜像加速)…"
41
+ curl -fsSL --connect-timeout 8 "https://mirrors.ustc.edu.cn/node/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" -o "$PKG_FILE" \
42
+ || curl -fsSL --connect-timeout 8 "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" -o "$PKG_FILE" \
43
+ || die "Node.js 安装包下载失败。国内镜像与官方源均不可达,请检查网络后重试,或到 https://nodejs.org 下载安装"
42
44
  say "正在安装 Node.js(可能需要输入一次开机密码)…"
43
45
  sudo installer -pkg "$PKG_FILE" -target / || die "Node.js 安装失败,请到 https://nodejs.org 手动安装后重跑本脚本"
44
46
  rm -f "$PKG_FILE"