agent-120 .env只留必要回退: - .env.example KOOK移4可选业务字段(RECEIVE_MODE/WEBHOOK_PATH/VERIFY_TOKEN/ENCRYPT_KEY),只留token/base_url; channelAccountsFromEnv不读这4个; 说明业务字段走channelConfigForm.channels.json - 黑名单/限流/receive_mode等走管理面板热更新, env仅必要连接回退 agent-121 删除渠道列表同步(根因: adminListChannels枚举caps,删除不同步caps): - adminListChannels 以channels.json为准: 遍历caps时已删账号adapter跳过(s.channels注入时), 删除/保存后列表=channels.json, 删除即消失 - (capReg Remove后续可加,范围外标注) agent-122 渠道管理分两块显示(主人:不割裂): - ①可用适配器类型(顶部PLATFORM_TYPES全集grid卡片,已配置/未配置Tag,点新建配置) - ②已保存配置(下方AdminTable过滤accounts>0,账号+bot身份+掩码token提示+连接/断开/删除) - 拆 channelConfigForm.tsx(248行) 表单抽出; Channels.tsx 463→306行; token只回填hint不写值(保存留空不改secret) 全仓 build/vet/test绿+前端build绿(356KB)
84 lines
4.2 KiB
TypeScript
84 lines
4.2 KiB
TypeScript
/** 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<string, PlatformField[]> = {
|
||
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<string, PlatformGuide> = {
|
||
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<string, string> = {
|
||
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);
|