change-image-suffix 2.1.6 → 2.1.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.
- package/CHANGELOG.md +14 -0
- package/dist/index.js +47 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.8](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.7...v2.1.8) (2026-05-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* remove nested quotes from bat set commands to handle paths with spaces ([becd55f](https://github.com/GuoSirius/change-image-suffix/commit/becd55f3dbf669b295b7e8f5b006e9939da910ac))
|
|
11
|
+
|
|
12
|
+
### [2.1.7](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.6...v2.1.7) (2026-05-25)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* add %1 to context menu bat commands so selected files are passed ([db6cf30](https://github.com/GuoSirius/change-image-suffix/commit/db6cf300839e12ec0229057b25299e50f37f4b6b))
|
|
18
|
+
|
|
5
19
|
### [2.1.6](https://github.com/GuoSirius/change-image-suffix/compare/v2.1.5...v2.1.6) (2026-05-25)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.js
CHANGED
|
@@ -89,13 +89,13 @@ if "%~1"=="" (
|
|
|
89
89
|
set "format=%~1"
|
|
90
90
|
shift
|
|
91
91
|
|
|
92
|
-
set
|
|
92
|
+
set args=
|
|
93
93
|
:parse
|
|
94
94
|
if "%~1"=="" goto :run
|
|
95
95
|
if exist "%~1\\*" (
|
|
96
|
-
set
|
|
96
|
+
set args=!args! -p "%~1"
|
|
97
97
|
) else (
|
|
98
|
-
set
|
|
98
|
+
set args=!args! -f "%~1"
|
|
99
99
|
)
|
|
100
100
|
shift
|
|
101
101
|
goto :parse
|
|
@@ -108,7 +108,7 @@ if "!args!"=="" (
|
|
|
108
108
|
)
|
|
109
109
|
|
|
110
110
|
"!CIS_CMD!" -t !format! !args!
|
|
111
|
-
|
|
111
|
+
pause
|
|
112
112
|
endlocal
|
|
113
113
|
`;
|
|
114
114
|
fs.writeFileSync(batPath, batContent, 'utf8');
|
|
@@ -120,37 +120,42 @@ endlocal
|
|
|
120
120
|
{ verb: 'avif', label: '📺 AVIF' },
|
|
121
121
|
{ verb: 'tiff', label: '📋 TIFF' },
|
|
122
122
|
];
|
|
123
|
-
// ── 使用
|
|
123
|
+
// ── 使用 ExtendedSubCommandsKey 方式 ──
|
|
124
|
+
// 文件右键和目录右键均使用 bat 脚本,混合选择时自动分类文件和目录
|
|
124
125
|
const menuBases = [
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
},
|
|
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 },
|
|
140
129
|
];
|
|
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
|
+
// bat 脚本接收格式参数,%1 为 Windows 传入的文件/目录路径
|
|
138
|
+
cmd = `"${batPath}" ${fmt.verb} "%1"`;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
cmd = `"${cisCmd}" -t ${fmt.verb} ${menu.arg}`;
|
|
142
|
+
}
|
|
143
|
+
execSync(`reg add "${shellKey}" /ve /d "${fmt.label}" /f`, { stdio: 'ignore' });
|
|
144
|
+
execSync(`reg add "${shellKey}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
|
|
145
|
+
execSync(`reg add "${shellKey}\\command" /ve /d "${cmd}" /f`, { stdio: 'ignore' });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// 2. 注册主菜单项(使用 ExtendedSubCommandsKey 关联各自的子菜单)
|
|
141
149
|
for (const menu of menuBases) {
|
|
142
|
-
// 注册主菜单项
|
|
143
150
|
execSync(`reg add "${menu.base}" /ve /d "🖼 转换图片 (cis)" /f`, { stdio: 'ignore' });
|
|
144
151
|
execSync(`reg add "${menu.base}" /v Icon /d "${iconPath}" /f`, { stdio: 'ignore' });
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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' });
|
|
152
|
+
execSync(`reg add "${menu.base}" /v ExtendedSubCommandsKey /d "${menu.subMenu}" /f`, { stdio: 'ignore' });
|
|
153
|
+
// 使用 bat 的菜单(文件右键和目录右键):设置 command 接收文件路径 %1
|
|
154
|
+
// Windows 会将父命令收到的 %1 自动传递给子命令
|
|
155
|
+
if (menu.useBat) {
|
|
156
|
+
execSync(`reg add "${menu.base}\\command" /ve /d "cmd /c echo %1 > nul" /f`, { stdio: 'ignore' });
|
|
157
|
+
// 注意:不添加 AppliesTo 限制,让菜单始终显示
|
|
158
|
+
// bat 脚本会检查文件扩展名,自动忽略非图片文件
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
161
|
// 写入版本标记,用于检测 npm update 后自动刷新菜单
|
|
@@ -178,6 +183,18 @@ function uninstallContextMenu() {
|
|
|
178
183
|
}
|
|
179
184
|
catch { /* ignore */ }
|
|
180
185
|
}
|
|
186
|
+
// 删除公共子菜单(三个:目录空白、目录图标、文件)
|
|
187
|
+
const subMenuRoots = [
|
|
188
|
+
'HKCU\\Software\\Classes\\Directory\\ContextMenus\\cis',
|
|
189
|
+
'HKCU\\Software\\Classes\\Directory\\ContextMenus\\cis_dir',
|
|
190
|
+
'HKCU\\Software\\Classes\\Directory\\ContextMenus\\cis_file',
|
|
191
|
+
];
|
|
192
|
+
for (const root of subMenuRoots) {
|
|
193
|
+
try {
|
|
194
|
+
execSync(`reg delete "${root}" /f`, { stdio: 'ignore' });
|
|
195
|
+
}
|
|
196
|
+
catch { /* ignore */ }
|
|
197
|
+
}
|
|
181
198
|
// 删除批处理文件、图标和版本标记
|
|
182
199
|
const appDataDir = path.join(os.homedir(), 'AppData', 'Roaming', 'change-image-suffix');
|
|
183
200
|
const batPath = path.join(appDataDir, 'cis_file.bat');
|