Files
geo/apps/browser-extension/src/platforms.ts
T
root 134dd063c3 feat: Add platform adapters for various content publishing platforms
- Implemented Dongchedi adapter for user detection and publishing.
- Implemented Jianshu adapter for user detection and publishing.
- Implemented Juejin adapter for user detection and publishing.
- Implemented Qiehao adapter for user detection and publishing.
- Implemented Smzdm adapter for user detection and publishing.
- Implemented Sohuhao adapter for user detection and publishing.
- Implemented Toutiaohao adapter for user detection and publishing.
- Implemented Wangyihao adapter for user detection and publishing.
- Implemented Weixin Gzh adapter for user detection and publishing.
- Implemented Zol adapter for user detection and publishing.
- Added documentation for manual testing of media publishing.
2026-04-03 17:48:30 +08:00

143 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}`;
default:
return null;
}
}