feat(mindspace): add WeChat MP config and one-click draft push on publish.

Let users bind their own official account credentials in M 配置 and push MindSpace pages to the WeChat draft box during or after publish, reusing the existing draft conversion pipeline.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-10 16:43:25 +08:00
parent 3bc2442769
commit 78b7d546c2
19 changed files with 1635 additions and 16 deletions
+8
View File
@@ -110,6 +110,14 @@ export {
redactMindSpacePage,
updatePublicationStatus,
} from './mindspace-publications';
export {
deleteMindSpaceWechatMpConfig,
getMindSpaceWechatMpConfig,
listMindSpaceWechatPageDraftRuns,
pushMindSpacePageWechatDraft,
saveMindSpaceWechatMpConfig,
verifyMindSpaceWechatMpConfig,
} from './mindspace-wechat-mp';
export {
applyPageDataPublishPolicy,
buildPageDataExportUrl,
+94
View File
@@ -0,0 +1,94 @@
import { apiFetch } from './core';
export type MindSpaceWechatMpAccountType = 'service' | 'subscription';
export type MindSpaceWechatMpConfig = {
configured: boolean;
appId: string;
accountType: MindSpaceWechatMpAccountType;
label: string;
author: string;
appSecretMasked: string;
verifiedAt: number | null;
updatedAt: number | null;
};
export type MindSpaceWechatPageDraftRun = {
id: string;
pageId: string;
status: 'success' | 'failed' | string;
pageTitle: string | null;
pageUrl: string | null;
draftMediaId: string | null;
errorMessage: string | null;
triggeredBy: string | null;
createdAt: number;
};
export type MindSpaceWechatPageDraftResult = {
ok: boolean;
draftMediaId: string;
pageTitle: string;
pageUrl: string;
run: MindSpaceWechatPageDraftRun;
};
export async function getMindSpaceWechatMpConfig(): Promise<MindSpaceWechatMpConfig> {
const result = await apiFetch<{ data: MindSpaceWechatMpConfig }>('/mindspace/v1/wechat-mp/config');
return result.data;
}
export async function saveMindSpaceWechatMpConfig(input: {
appId: string;
appSecret?: string;
accountType?: MindSpaceWechatMpAccountType;
label?: string;
author?: string;
verify?: boolean;
}): Promise<MindSpaceWechatMpConfig> {
const result = await apiFetch<{ data: MindSpaceWechatMpConfig }>('/mindspace/v1/wechat-mp/config', {
method: 'PUT',
body: JSON.stringify({
app_id: input.appId,
app_secret: input.appSecret,
account_type: input.accountType,
label: input.label,
author: input.author,
verify: input.verify,
}),
});
return result.data;
}
export async function verifyMindSpaceWechatMpConfig(): Promise<MindSpaceWechatMpConfig> {
const result = await apiFetch<{ data: MindSpaceWechatMpConfig }>(
'/mindspace/v1/wechat-mp/config/verify',
{ method: 'POST' },
);
return result.data;
}
export async function deleteMindSpaceWechatMpConfig(): Promise<{ ok: boolean }> {
const result = await apiFetch<{ data: { ok: boolean } }>('/mindspace/v1/wechat-mp/config', {
method: 'DELETE',
});
return result.data;
}
export async function pushMindSpacePageWechatDraft(pageId: string): Promise<MindSpaceWechatPageDraftResult> {
const result = await apiFetch<{ data: MindSpaceWechatPageDraftResult }>(
`/mindspace/v1/pages/${encodeURIComponent(pageId)}/wechat-draft`,
{ method: 'POST' },
);
return result.data;
}
export async function listMindSpaceWechatPageDraftRuns(
pageId: string,
limit = 10,
): Promise<MindSpaceWechatPageDraftRun[]> {
const result = await apiFetch<{ data: MindSpaceWechatPageDraftRun[] }>(
`/mindspace/v1/pages/${encodeURIComponent(pageId)}/wechat-draft/runs?limit=${limit}`,
);
return result.data;
}