/** Channel config field metadata + per-platform guidance (design/16 §4.4-4.6). * Separated from Channels.tsx so the module stays under the 500-line bound and a * platform only needs a new entry here. */ /** One curated config input; `key` is the adapter Config json tag the backend decodes. */ export interface PlatformField { key: string; label: string; placeholder?: string; /** Masked [type=password] input (token / verify / encrypt / secret). */ secret?: boolean; } /** Platform-specific config fields only (the COMMON fields are rendered separately). * Keys are the adapter Config json tags verbatim. */ export const PLATFORM_FIELDS: Record = { kook: [], // KOOK is "token 即用、其余自动获取"—advanced values go in the extra JSON. "qq-obv11": [ { key: "mode", label: "mode(client/server)", placeholder: "server" }, { key: "listen_addr", label: "listen_addr(server 监听)", placeholder: "0.0.0.0:6700" }, { key: "remote_url", label: "remote_url(client 连接)", placeholder: "ws://…" }, { key: "access_token", label: "access_token(OneBot 访问 token)", secret: true }, { key: "self_id", label: "self_id(机器人 QQ 号)", placeholder: "123456789" }, ], telegram: [{ key: "webhook_url", label: "webhook_url(公网回调地址)", placeholder: "https://…" }], "weixin-ilink": [ { key: "cdn_base_url", label: "cdn_base_url(媒体 CDN)", placeholder: "https://…" }, { key: "bot_id", label: "bot_id(ilink_bot_id)", placeholder: "wx…" }, { key: "owner_id", label: "owner_id(绑定主人 uid)", placeholder: "wx…" }, { key: "cursor", label: "cursor(get_updates_buf)", placeholder: "…" }, ], webhook: [ { key: "endpointPath", label: "endpointPath(挂载路由)", placeholder: "/webhook" }, { key: "channelId", label: "channelId(渠道 id)", placeholder: "…" }, { key: "channelName", label: "channelName(渠道名)", placeholder: "…" }, { key: "secret", label: "secret(HMAC 签名密钥)", secret: true }, { key: "signatureHeader", label: "signatureHeader(签名头)", placeholder: "X-Webhook-Signature" }, ], }; /** Core-required guidance per platform: headline `guide` + auto-fetch `hint`. */ export interface PlatformGuide { guide: string; hint?: string; tokenRequired?: boolean; } export const PLATFORM_GUIDE: Record = { kook: { guide: "只需填 bot_token(必填),其余自动获取", hint: "base_url 留空即用官方地址;receive_mode 默认 ws、webhook_path 默认 /webhook/kook,均无需填写;连接后渠道列表自动显示该 bot 身份。如需 webhook(receive_mode=webhook)或 webhook_verify_token / webhook_encrypt_key,在「高级选项 → 额外 config」里以 JSON 设置。", }, "qq-obv11": { guide: "填 token(必填)并选择接入方式(mode:client / server)", hint: "mode=server 填 listen_addr(本地监听端口);mode=client 填 remote_url(连接上游)。mode / listen_addr / remote_url / access_token 在「高级选项」里配置。", }, telegram: { guide: "只需填 bot_token(必填),其余自动获取", hint: "webhook_url(公网回调,可选)在「高级选项」里配置;留空则走长轮询。", }, "weixin-ilink": { guide: "填 bot_token(必填)与 bot_id / owner_id", hint: "bot_id / owner_id / cdn_base_url / cursor 在「高级选项」里配置;媒体 CDN 可留空自动。", }, webhook: { guide: "填 endpointPath 与 secret(必填)", hint: "endpointPath / secret / channelId / signatureHeader 在「高级选项」里配置,用于接收平台回调。", tokenRequired: false, }, }; /** Human-friendly platform display name (the map key is the adapter prefix). */ export const PLATFORM_LABEL: Record = { kook: "KOOK", "qq-obv11": "QQ(OneBot v11)", telegram: "Telegram", "weixin-ilink": "微信(iLink)", webhook: "Webhook", }; /** The full set of known adapter platform types (whether or not configured yet). * Drives the "可用适配器类型(新建)" grid — every known type is creatable. */ export const PLATFORM_TYPES: string[] = Object.keys(PLATFORM_GUIDE);