fix(desktop/weixin-gzh): tolerate numeric appMsgId and classify login timeout
The MP draft API sometimes returns appMsgId as a number or under the appmsgid alias; coerce both shapes before treating the response as a success. Also extend the platform auth adapter to recognize 登录超时/ 请重新登录 wording so the runtime drives the account back to re-auth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,8 @@ type WeixinCropResponse = {
|
||||
};
|
||||
|
||||
type WeixinOperateResponse = {
|
||||
appMsgId?: string;
|
||||
appMsgId?: string | number;
|
||||
appmsgid?: string | number;
|
||||
ret?: number;
|
||||
base_resp?: {
|
||||
ret?: number;
|
||||
@@ -376,6 +377,17 @@ function formatWeixinError(response: WeixinOperateResponse | null | undefined):
|
||||
return typeof ret === "number" ? map[ret] || `同步到草稿箱失败 (错误码: ${ret})` : "同步到草稿箱失败";
|
||||
}
|
||||
|
||||
function normalizeWeixinArticleId(response: WeixinOperateResponse | null | undefined): string {
|
||||
const value = response?.appMsgId ?? response?.appmsgid;
|
||||
if (typeof value === "number") {
|
||||
return Number.isFinite(value) ? String(value) : "";
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return value.trim();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function buildOperateForm(
|
||||
context: PublishAdapterContext,
|
||||
meta: WeixinMeta,
|
||||
@@ -558,7 +570,7 @@ export const weixinGzhAdapter: PublishAdapter = {
|
||||
},
|
||||
}));
|
||||
|
||||
const articleId = response.appMsgId?.trim() || "";
|
||||
const articleId = normalizeWeixinArticleId(response);
|
||||
if (!articleId) {
|
||||
const message = formatWeixinError(response);
|
||||
if (isWeixinChallengeMessage(message)) {
|
||||
|
||||
Reference in New Issue
Block a user