Files
Cyrene_v2/frontend/web/src/admin/modules/channelFields.ts
T
Aska 0a597cfa42
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled
feat(weixin): 微信iLink面板配置/启用逻辑对齐真实桥接(token即用)
面板此前让用户手填 bot_id/owner_id/cursor(实为扫码登录后自动获取/自动落盘),与参考
weixin_ClawBot_Bridge 流程不符。对齐成 kook/telegram 的'token即用、其余自动获取':
- channelFields.ts: weixin-ilink 字段只留 cdn_base_url(可选,留空自动),移除 bot_id/owner_id/
  cursor; guide/hint 改为'只需填 bot_token(必填,或连接时触发扫码登录自动获取),其余自动获取'
- AdapterDetailPage/GenericAdapterPanel: 账号身份区显示自动获取的 bot_id(account.botId)
- 后端确认无需改: cmd/cyrene 仅校验 bot_token;Connect(BotToken空)自动扫码并持久化 bot_token/
  bot_id/owner_id;游标自动落盘;与参考一致
验收: 前端 build 100模块绿 + 后端相关包 build/test ok(无Go改动)
2026-09-07 20:29:56 +08:00

81 lines
4.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 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://…" },
],
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(必填,或连接时触发扫码登录自动获取),其余自动获取",
hint: "连接后自动获取 bot 身份(ilink_bot_id / bot_id)并持续维护 get_updates_buf 游标;需要媒体 CDN 时可在「高级选项」配 cdn_base_url(留空自动)。",
},
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);