Open
Conversation
- 修改 httpApiHost 默认值从 127.0.0.1 到 0.0.0.0 - 允许 HTTP API 服务接受外网访问 - 用户需要配置 httpApiToken 以确保安全 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更背景
当前 HTTP API 只覆盖聊天消息能力,朋友圈能力仅在 Electron IPC 内可用,外部集成时不方便直接调用。
另外,朋友圈媒体地址在 timeline 返回后通常还需要额外处理,前端接入成本较高。
本次目标
sns/usernames在不同数据库环境下的可用性。主要改动
1) 新增朋友圈 HTTP API 路由
在
electron/services/httpService.ts新增以下接口:GET /api/v1/sns/timelineGET /api/v1/sns/usernamesGET /api/v1/sns/export/statsGET /api/v1/sns/media/proxyPOST /api/v1/sns/exportGET /api/v1/sns/block-delete/statusPOST /api/v1/sns/block-delete/installPOST /api/v1/sns/block-delete/uninstallDELETE /api/v1/sns/post/{postId}并补充:
POSTJSON body 解析(1MB 上限)Allow-Methods扩展为GET, POST, DELETE, OPTIONS2) timeline 媒体返回增强(默认可直接用)
GET /api/v1/sns/timeline新增媒体解析能力:media=1&replace=1media[].url/thumb替换为可访问的代理解密地址media[].rawUrlmedia[].rawThumbmedia[].resolvedUrl/resolvedThumbUrlmedia[].proxyUrl/proxyThumbUrlinline=1,尽量返回data:URL(小批量场景)可通过参数控制:
media=0关闭媒体解析replace=0保留原url/thumb不替换3)
sns/usernames可用性修复在
electron/services/snsService.ts中,getSnsUsernames()增加 timeline 分页回退逻辑:当
SnsTimeLine直接 SQL 查询为空时,自动通过wcdbService.getSnsTimeline收集用户名,避免返回空数组的误判。4) 文档更新
更新
docs/HTTP-API.md,补充朋友圈 HTTP API 说明及 timeline 媒体参数说明。影响范围
electron/services/httpService.tselectron/services/snsService.tsdocs/HTTP-API.md兼容性说明
/api/v1/sns/timeline的默认行为有变化:默认会返回可访问媒体地址并覆盖
media.url/thumb。如需旧行为,可使用
media=0或replace=0。验证情况
已通过:
npm run typecheck建议回归(Windows 环境):
GET /api/v1/sns/timeline(默认、replace=0、inline=1)GET /api/v1/sns/usernamesGET /api/v1/sns/media/proxyPOST /api/v1/sns/export