@hangox/mg-cli 1.1.4 → 1.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/dist/cli.js +21 -6
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2751,7 +2751,7 @@ async function handleListExtensions(options) {
|
|
|
2751
2751
|
// src/cli/commands/open-page.ts
|
|
2752
2752
|
import { Command as Command10 } from "commander";
|
|
2753
2753
|
function createOpenPageCommand() {
|
|
2754
|
-
return new Command10("open_page").description("\u901A\u8FC7 Chrome \u6269\u5C55\u6253\u5F00\u6307\u5B9A\u7684\u9875\u9762").requiredOption("--
|
|
2754
|
+
return new Command10("open_page").description("\u901A\u8FC7 Chrome \u6269\u5C55\u6253\u5F00\u6307\u5B9A\u7684\u9875\u9762").requiredOption("--link <link>", "\u9875\u9762\u94FE\u63A5\uFF08\u652F\u6301 https:// \u6216 mgp:// \u683C\u5F0F\uFF09").option("--ext <index>", "\u6269\u5C55\u5B9E\u4F8B\u5E8F\u53F7\uFF081, 2, 3...\uFF09\uFF0C\u9ED8\u8BA4\u81EA\u52A8\u9009\u62E9\u7B2C\u4E00\u4E2A\u53EF\u7528\u6269\u5C55").option("--no-auto-start", "\u7981\u7528\u81EA\u52A8\u542F\u52A8 Server").option("--no-retry", "\u7981\u7528\u81EA\u52A8\u91CD\u8BD5").action(async (options) => {
|
|
2755
2755
|
await handleOpenPage(options);
|
|
2756
2756
|
});
|
|
2757
2757
|
}
|
|
@@ -2761,9 +2761,24 @@ async function handleOpenPage(options) {
|
|
|
2761
2761
|
noRetry: options.noRetry
|
|
2762
2762
|
});
|
|
2763
2763
|
try {
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2764
|
+
let targetUrl;
|
|
2765
|
+
if (options.link.startsWith("mgp://")) {
|
|
2766
|
+
const parsed = parseMgpLink(options.link);
|
|
2767
|
+
if (!parsed) {
|
|
2768
|
+
console.error(`\u9519\u8BEF [${"E010" /* INVALID_LINK */}]: \u65E0\u6548\u7684 mgp:// \u94FE\u63A5\u683C\u5F0F`);
|
|
2769
|
+
console.error(`\u63D0\u4F9B\u7684\u94FE\u63A5: ${options.link}`);
|
|
2770
|
+
console.error(`\u671F\u671B\u683C\u5F0F: mgp://[mastergo_page_url]?nodeId=[\u8282\u70B9ID] \u6216 mgp://[mastergo_page_url]?pageId=[\u9875\u9762ID]`);
|
|
2771
|
+
process.exit(1);
|
|
2772
|
+
}
|
|
2773
|
+
targetUrl = `https://${parsed.pageUrl}`;
|
|
2774
|
+
} else if (options.link.startsWith("https://") || options.link.startsWith("http://")) {
|
|
2775
|
+
targetUrl = options.link;
|
|
2776
|
+
} else {
|
|
2777
|
+
console.error("\u9519\u8BEF: \u94FE\u63A5\u683C\u5F0F\u65E0\u6548");
|
|
2778
|
+
console.error(`\u63D0\u4F9B\u7684\u94FE\u63A5: ${options.link}`);
|
|
2779
|
+
console.error("\u652F\u6301\u7684\u683C\u5F0F:");
|
|
2780
|
+
console.error(" \u2022 https://mastergo.netease.com/file/xxx");
|
|
2781
|
+
console.error(" \u2022 mgp://mastergo.netease.com/file/xxx?nodeId=123%3A456");
|
|
2767
2782
|
process.exit(1);
|
|
2768
2783
|
}
|
|
2769
2784
|
await client.connect();
|
|
@@ -2795,9 +2810,9 @@ async function handleOpenPage(options) {
|
|
|
2795
2810
|
process.exit(1);
|
|
2796
2811
|
}
|
|
2797
2812
|
console.log(`\u6B63\u5728\u901A\u8FC7\u6269\u5C55 #${extensionIndex} \u6253\u5F00\u9875\u9762...`);
|
|
2798
|
-
console.log(`URL: ${
|
|
2813
|
+
console.log(`URL: ${targetUrl}`);
|
|
2799
2814
|
const params = {
|
|
2800
|
-
url:
|
|
2815
|
+
url: targetUrl,
|
|
2801
2816
|
extensionIndex
|
|
2802
2817
|
};
|
|
2803
2818
|
const data = await client.requestWithRetry(
|