zixulu 1.73.8 → 1.74.0

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/dist/index.js CHANGED
@@ -5028,6 +5028,41 @@ async function winget() {
5028
5028
  if (global.__ZIXULU_PROXY__) args.push("--proxy", "http://127.0.0.1:7890");
5029
5029
  spawnAsync("winget", args);
5030
5030
  }
5031
+ async function addOpenWith(path, { file, folder, background }) {
5032
+ if (!file && !folder && !background) throw new Error("至少选择一个");
5033
+ path = external_path_resolve(path);
5034
+ try {
5035
+ const status = await stat(path);
5036
+ if (!status.isFile()) throw new Error("路径不是文件");
5037
+ } catch (error) {}
5038
+ const { name } = parse(path);
5039
+ const escapedPath = path.replace(/[\\\/]/g, "\\\\");
5040
+ let reg = `\ufeffWindows Registry Editor Version 5.00
5041
+ `;
5042
+ if (file) reg += `
5043
+ [HKEY_CLASSES_ROOT\\*\\shell\\${name}]
5044
+ @="使用 ${name} 打开"
5045
+ "Icon"="\\"${escapedPath}\\""
5046
+
5047
+ [HKEY_CLASSES_ROOT\\*\\shell\\${name}\\command]
5048
+ @="\\"${escapedPath}\\" \\"%1\\""`;
5049
+ if (folder) reg += `
5050
+ [HKEY_CLASSES_ROOT\\Directory\\shell\\${name}]
5051
+ @="使用 ${name} 打开"
5052
+ "Icon"="\\"${escapedPath}\\""
5053
+
5054
+ [HKEY_CLASSES_ROOT\\Directory\\shell\\${name}\\command]
5055
+ @="\\"${escapedPath}\\" \\"%V\\""`;
5056
+ if (background) reg += `
5057
+ [HKEY_CLASSES_ROOT\\Directory\\Background\\shell\\${name}]
5058
+ @="使用 ${name} 打开"
5059
+ "Icon"="\\"${escapedPath}\\""
5060
+
5061
+ [HKEY_CLASSES_ROOT\\Directory\\Background\\shell\\${name}\\command]
5062
+ @="\\"${escapedPath}\\" \\"%V\\""
5063
+ `;
5064
+ await writeFile(`add_open_with_${name}.reg`, reg, "utf-16le");
5065
+ }
5031
5066
  const gdm_script = `// @ts-check
5032
5067
 
5033
5068
  import { spawnSync } from "child_process"
@@ -5129,6 +5164,18 @@ async function gdm() {
5129
5164
  await writeFile(".gdm/gdm.mjs", gdm_script);
5130
5165
  await verdaccio();
5131
5166
  }
5167
+ async function removeOpenWith(name, { file, folder, background }) {
5168
+ if (!file && !folder && !background) throw new Error("至少选择一个");
5169
+ let reg = `\ufeffWindows Registry Editor Version 5.00
5170
+ `;
5171
+ if (file) reg += `
5172
+ [-HKEY_CLASSES_ROOT\\*\\shell\\${name}]`;
5173
+ if (folder) reg += `
5174
+ [-HKEY_CLASSES_ROOT\\Directory\\shell\\${name}]`;
5175
+ if (background) reg += `
5176
+ [-HKEY_CLASSES_ROOT\\Directory\\Background\\shell\\${name}]`;
5177
+ await writeFile(`remove_open_with_${name}.reg`, reg, "utf-16le");
5178
+ }
5132
5179
  setDefaultOptions({
5133
5180
  shell: true,
5134
5181
  stdio: "inherit"
@@ -5316,6 +5363,8 @@ program.command("replace-commit-message").alias("rcm").description("替换所有
5316
5363
  });
5317
5364
  });
5318
5365
  program.command("gdm").description("同步 geshu-docker-management").action(gdm);
5366
+ program.command("add-open-with").alias("aow").description("添加打开文件的脚本").argument("path", "程序路径").option("--no-file", "是否不添加文件关联").option("--no-folder", "是否不添加文件夹关联").option("--no-background", "是否不添加文件夹空白处关联").action(addOpenWith);
5367
+ program.command("remove-open-with").alias("row").description("删除打开文件的脚本").argument("name", "脚本名称").option("--no-file", "是否不删除文件关联").option("--no-folder", "是否不删除文件夹关联").option("--no-background", "是否不删除文件夹空白处关联").action(removeOpenWith);
5319
5368
  program.parse();
5320
5369
 
5321
5370
  //# sourceMappingURL=index.js.map