change-image-suffix 2.1.5 → 2.1.6

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
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [2.1.6](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.5...v2.1.6) (2026-05-25)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * use inline shell sub-keys instead of ExtendedSubCommandsKey for context menu ([2f50376](https://github.com/GuoSirius/change-image-suffix/commit/2f50376a62a17bcf317530e0662f5b2d718d53d0))
11
+
12
+
13
+ ### Chores
14
+
15
+ * update local settings permissions and refresh lockfile ([71d0c1e](https://github.com/GuoSirius/change-image-suffix/commit/71d0c1e6124006e827a3c0d078f9cc47699a3f4c))
16
+
5
17
  ### [2.1.5](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.4...v2.1.5) (2026-05-23)
6
18
 
7
19
 
package/dist/index.js CHANGED
@@ -120,44 +120,37 @@ endlocal
120
120
  { verb: 'avif', label: '📺 AVIF' },
121
121
  { verb: 'tiff', label: '📋 TIFF' },
122
122
  ];
123
- // ── 使用 ExtendedSubCommandsKey 方式 ──
124
- // 文件右键和目录右键均使用 bat 脚本,混合选择时自动分类文件和目录
123
+ // ── 使用 inline shell 子菜单(比 ExtendedSubCommandsKey 更可靠地传递参数)──
125
124
  const menuBases = [
126
- { base: 'HKCU\\Software\\Classes\\Directory\\Background\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis', arg: '-p "%V"' },
127
- { base: 'HKCU\\Software\\Classes\\Directory\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_dir', useBat: true },
128
- { base: 'HKCU\\Software\\Classes\\*\\shell\\cis', subMenu: 'Directory\\ContextMenus\\cis_file', useBat: true },
125
+ {
126
+ base: 'HKCU\\Software\\Classes\\*\\shell\\cis',
127
+ cmd: (fmt) => `"${batPath}" ${fmt} "%1"`,
128
+ multiSelect: true,
129
+ },
130
+ {
131
+ base: 'HKCU\\Software\\Classes\\Directory\\shell\\cis',
132
+ cmd: (fmt) => `"${batPath}" ${fmt} "%1"`,
133
+ multiSelect: false,
134
+ },
135
+ {
136
+ base: 'HKCU\\Software\\Classes\\Directory\\Background\\shell\\cis',
137
+ cmd: (fmt) => `"${cisCmd}" -t ${fmt} -p "%V"`,
138
+ multiSelect: false,
139
+ },
129
140
  ];
130
- // 1. 注册公共子菜单(每种菜单类型独立注册)
131
- const REG_ROOT = 'HKCU\\Software\\Classes\\';
132
- for (const menu of menuBases) {
133
- for (const fmt of formats) {
134
- const shellKey = `${REG_ROOT}${menu.subMenu}\\shell\\${fmt.verb}`;
135
- let cmd;
136
- if (menu.useBat) {
137
- // 文件右键:子命令传递格式参数,Windows 自动追加文件路径
138
- // 最终执行: cmd /c "bat" "格式" "文件路径"
139
- cmd = `"${batPath}" ${fmt.verb}`;
140
- }
141
- else {
142
- cmd = `"${cisCmd}" -t ${fmt.verb} ${menu.arg}`;
143
- }
144
- execSync(`reg add "${shellKey}" /ve /d "${fmt.label}" /f`, { stdio: 'ignore' });
145
- execSync(`reg add "${shellKey}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
146
- // 直接调用 bat,不需要 cmd /c,Windows 会自动追加文件路径
147
- execSync(`reg add "${shellKey}\\command" /ve /d "${cmd}" /f`, { stdio: 'ignore' });
148
- }
149
- }
150
- // 2. 注册主菜单项(使用 ExtendedSubCommandsKey 关联各自的子菜单)
151
141
  for (const menu of menuBases) {
142
+ // 注册主菜单项
152
143
  execSync(`reg add "${menu.base}" /ve /d "🖼 转换图片 (cis)" /f`, { stdio: 'ignore' });
153
144
  execSync(`reg add "${menu.base}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
154
- execSync(`reg add "${menu.base}" /v ExtendedSubCommandsKey /d "${menu.subMenu}" /f`, { stdio: 'ignore' });
155
- // 使用 bat 的菜单(文件右键和目录右键):设置 command 接收文件路径 %1
156
- // Windows 会将父命令收到的 %1 自动传递给子命令
157
- if (menu.useBat) {
158
- execSync(`reg add "${menu.base}\\command" /ve /d "cmd /c echo %1 > nul" /f`, { stdio: 'ignore' });
159
- // 注意:不添加 AppliesTo 限制,让菜单始终显示
160
- // bat 脚本会检查文件扩展名,自动忽略非图片文件
145
+ if (menu.multiSelect) {
146
+ execSync(`reg add "${menu.base}" /v MultiSelectModel /d Player /f`, { stdio: 'ignore' });
147
+ }
148
+ // 注册格式子菜单(inline shell 子键,确保参数正确传递)
149
+ for (const fmt of formats) {
150
+ const subKey = `${menu.base}\\shell\\${fmt.verb}`;
151
+ execSync(`reg add "${subKey}" /ve /d "${fmt.label}" /f`, { stdio: 'ignore' });
152
+ execSync(`reg add "${subKey}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
153
+ execSync(`reg add "${subKey}\\command" /ve /d "${menu.cmd(fmt.verb)}" /f`, { stdio: 'ignore' });
161
154
  }
162
155
  }
163
156
  // 写入版本标记,用于检测 npm update 后自动刷新菜单
@@ -185,18 +178,6 @@ function uninstallContextMenu() {
185
178
  }
186
179
  catch { /* ignore */ }
187
180
  }
188
- // 删除公共子菜单(三个:目录空白、目录图标、文件)
189
- const subMenuRoots = [
190
- 'HKCU\\Software\\Classes\\Directory\\ContextMenus\\cis',
191
- 'HKCU\\Software\\Classes\\Directory\\ContextMenus\\cis_dir',
192
- 'HKCU\\Software\\Classes\\Directory\\ContextMenus\\cis_file',
193
- ];
194
- for (const root of subMenuRoots) {
195
- try {
196
- execSync(`reg delete "${root}" /f`, { stdio: 'ignore' });
197
- }
198
- catch { /* ignore */ }
199
- }
200
181
  // 删除批处理文件、图标和版本标记
201
182
  const appDataDir = path.join(os.homedir(), 'AppData', 'Roaming', 'change-image-suffix');
202
183
  const batPath = path.join(appDataDir, 'cis_file.bat');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "change-image-suffix",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "type": "module",
5
5
  "description": "批量转换图片格式的CLI工具,支持递归搜索、深度限制、指定后缀、Windows右键菜单等功能",
6
6
  "main": "dist/index.js",