87e329207c
Wires up Baijiahao (百家号) and Jianshu (简书) as first-class desktop publish targets, with risk-control prompts surfaced in the runtime controller and a normalized error message in publish records. Adds external-link buttons in the publish management table, an asset format conversion endpoint for cover image compatibility, and reorders publish-status display priority so failures take precedence over partial successes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
145 lines
3.9 KiB
TypeScript
145 lines
3.9 KiB
TypeScript
import type { PublisherLocalPlatformState } from "@geo/shared-types";
|
|
|
|
export interface StoredPlatformState extends PublisherLocalPlatformState {
|
|
platform_name: string;
|
|
short_name: string;
|
|
accent_color: string;
|
|
login_url: string | null;
|
|
logo_path: string;
|
|
}
|
|
|
|
const platformDefinitions = [
|
|
{
|
|
platform_id: "toutiaohao",
|
|
platform_name: "头条号",
|
|
short_name: "头",
|
|
accent_color: "#f5222d",
|
|
login_url: "https://mp.toutiao.com/auth/page/login",
|
|
logo_path: "logos/logo_toutiao.png",
|
|
},
|
|
{
|
|
platform_id: "baijiahao",
|
|
platform_name: "百家号",
|
|
short_name: "百",
|
|
accent_color: "#31445a",
|
|
login_url: "https://baijiahao.baidu.com/builder/theme/bjh/login",
|
|
logo_path: "logos/logo_baijiahao.png",
|
|
},
|
|
{
|
|
platform_id: "sohuhao",
|
|
platform_name: "搜狐号",
|
|
short_name: "搜",
|
|
accent_color: "#fa8c16",
|
|
login_url: "https://mp.sohu.com/mpfe/v4/login",
|
|
logo_path: "logos/logo_souhu.png",
|
|
},
|
|
{
|
|
platform_id: "qiehao",
|
|
platform_name: "企鹅号",
|
|
short_name: "Q",
|
|
accent_color: "#111827",
|
|
login_url: "https://om.qq.com",
|
|
logo_path: "logos/logo_qiehao.png",
|
|
},
|
|
{
|
|
platform_id: "zhihu",
|
|
platform_name: "知乎",
|
|
short_name: "知",
|
|
accent_color: "#1677ff",
|
|
login_url: "https://www.zhihu.com/signin",
|
|
logo_path: "logos/logo_zhihu.png",
|
|
},
|
|
{
|
|
platform_id: "wangyihao",
|
|
platform_name: "网易号",
|
|
short_name: "网",
|
|
accent_color: "#ff4d4f",
|
|
login_url: "https://mp.163.com/login.html",
|
|
logo_path: "logos/logo_wangyihao.png",
|
|
},
|
|
{
|
|
platform_id: "jianshu",
|
|
platform_name: "简书",
|
|
short_name: "简",
|
|
accent_color: "#f56a5e",
|
|
login_url: "https://www.jianshu.com/sign_in",
|
|
logo_path: "logos/logo_jianshu.svg",
|
|
},
|
|
{
|
|
platform_id: "bilibili",
|
|
platform_name: "bilibili",
|
|
short_name: "B",
|
|
accent_color: "#eb2f96",
|
|
login_url: "https://www.bilibili.com",
|
|
logo_path: "logos/logo_bilibili.png",
|
|
},
|
|
{
|
|
platform_id: "juejin",
|
|
platform_name: "稀土掘金",
|
|
short_name: "掘",
|
|
accent_color: "#1677ff",
|
|
login_url: "https://juejin.cn/login",
|
|
logo_path: "logos/logo_juejin.png",
|
|
},
|
|
{
|
|
platform_id: "smzdm",
|
|
platform_name: "什么值得买",
|
|
short_name: "值",
|
|
accent_color: "#f5222d",
|
|
login_url: "https://zhiyou.smzdm.com/user/login",
|
|
logo_path: "logos/logo_smzdm.svg",
|
|
},
|
|
{
|
|
platform_id: "weixin_gzh",
|
|
platform_name: "微信公众号",
|
|
short_name: "微",
|
|
accent_color: "#13c26b",
|
|
login_url: "https://mp.weixin.qq.com/cgi-bin/loginpage",
|
|
logo_path: "logos/logo_weixin_gzh.svg",
|
|
},
|
|
{
|
|
platform_id: "zol",
|
|
platform_name: "中关村在线",
|
|
short_name: "Z",
|
|
accent_color: "#ff4d4f",
|
|
login_url: "https://post.zol.com.cn/v2/manage/works/all",
|
|
logo_path: "logos/logo_zol.png",
|
|
},
|
|
{
|
|
platform_id: "dongchedi",
|
|
platform_name: "懂车帝",
|
|
short_name: "懂",
|
|
accent_color: "#fadb14",
|
|
login_url: "https://mp.dcdapp.com/login",
|
|
logo_path: "logos/logo_dongchedi.svg",
|
|
},
|
|
] satisfies Array<Pick<StoredPlatformState, "platform_id" | "platform_name" | "short_name" | "accent_color" | "login_url" | "logo_path">>;
|
|
|
|
export const supportedPlatforms = platformDefinitions;
|
|
|
|
export function createDefaultPlatformStates(): StoredPlatformState[] {
|
|
return supportedPlatforms.map((platform) => ({
|
|
...platform,
|
|
connected: false,
|
|
platform_uid: null,
|
|
nickname: null,
|
|
avatar_url: null,
|
|
message: null,
|
|
}));
|
|
}
|
|
|
|
export function buildPublishedUrl(platformId: string, externalArticleId: string): string | null {
|
|
switch (platformId) {
|
|
case "toutiaohao":
|
|
return `https://www.toutiao.com/article/${externalArticleId}/`;
|
|
case "zhihu":
|
|
return `https://zhuanlan.zhihu.com/p/${externalArticleId}`;
|
|
case "jianshu":
|
|
return `https://www.jianshu.com/p/${externalArticleId}`;
|
|
case "baijiahao":
|
|
return `https://baijiahao.baidu.com/s?id=${externalArticleId}`;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|