diff --git a/apps/desktop-client/src/main/adapters/wangyihao-links.ts b/apps/desktop-client/src/main/adapters/wangyihao-links.ts new file mode 100644 index 0000000..38fe5b9 --- /dev/null +++ b/apps/desktop-client/src/main/adapters/wangyihao-links.ts @@ -0,0 +1,6 @@ +const WANGYI_PUBLIC_ARTICLE_URL_PREFIX = "https://www.163.com/dy/article"; + +export function wangyihaoPublicArticleUrl(articleId: string): string | null { + const normalized = articleId.trim(); + return normalized ? `${WANGYI_PUBLIC_ARTICLE_URL_PREFIX}/${encodeURIComponent(normalized)}.html` : null; +} diff --git a/apps/desktop-client/src/main/adapters/wangyihao.test.ts b/apps/desktop-client/src/main/adapters/wangyihao.test.ts index 0750315..16f639c 100644 --- a/apps/desktop-client/src/main/adapters/wangyihao.test.ts +++ b/apps/desktop-client/src/main/adapters/wangyihao.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { prepareWangyihaoArticleHtml } from "./wangyihao-content"; +import { wangyihaoPublicArticleUrl } from "./wangyihao-links"; describe("wangyihao article content", () => { it("downgrades markdown tables to paragraph rows before saving drafts", () => { @@ -24,3 +25,15 @@ describe("wangyihao article content", () => { expect(html).toContain("
下一段中文说明
"); }); }); + +describe("wangyihao publish result", () => { + it("builds the public article URL from the NetEase doc id", () => { + expect(wangyihaoPublicArticleUrl(" IK5K461I05561G2M ")).toBe( + "https://www.163.com/dy/article/IK5K461I05561G2M.html", + ); + }); + + it("does not build an external URL without a doc id", () => { + expect(wangyihaoPublicArticleUrl(" ")).toBeNull(); + }); +}); diff --git a/apps/desktop-client/src/main/adapters/wangyihao.ts b/apps/desktop-client/src/main/adapters/wangyihao.ts index f33cc27..4024b9f 100644 --- a/apps/desktop-client/src/main/adapters/wangyihao.ts +++ b/apps/desktop-client/src/main/adapters/wangyihao.ts @@ -10,6 +10,7 @@ import { import { fetchImageAssetBlob } from "./media-image"; import type { PublishAdapter, PublishAdapterContext } from "./base"; import { prepareWangyihaoArticleHtml } from "./wangyihao-content"; +import { wangyihaoPublicArticleUrl } from "./wangyihao-links"; import { WANGYIHAO_DRAFT_SAVE_PARAMETER_MESSAGE, WANGYIHAO_PUBLISH_CLICK_MESSAGE, @@ -820,7 +821,7 @@ function buildResultPayload(articleId: string, mediaName: string): Record