访问记录管理系统 & 小说分享服务 · 基础地址:http://47.98.137.35:8486
💡 所有接口返回 JSON,统一格式为 {"code": 200, "message": "...", "data": ...}。
出错时返回对应 HTTP 状态码(404 不存在 / 403 密码错误 / 422 参数校验失败)。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
device_name | string | 是 | 设备名称;IP 与访问时间由服务器自动获取 |
post_app | string | 否 | 上报设备标识(如客户端程序名/版本),可为空;不传或传 null 时存 NULL |
note | string | 否 | 备注信息,可为空;不传或传 null 时存 NULL |
# 请求(完整字段) curl -X POST http://47.98.137.35:8486/api/access \ -H "Content-Type: application/json" \ -d '{"device_name": "实验室电脑A", "post_app": "android-app-v1.2", "note": "开机自检上报"}' # 请求(只传必填字段,post_app / note 自动存 NULL) curl -X POST http://47.98.137.35:8486/api/access \ -H "Content-Type: application/json" \ -d '{"device_name": "实验室电脑A"}' # 响应 {"code":200,"message":"记录成功","data":{"id":1,"device_name":"实验室电脑A","device_ip":"x.x.x.x","access_time":"2026-09-23 19:00:00","post_app":"android-app-v1.2","note":"开机自检上报"}}
# 请求 curl http://47.98.137.35:8486/api/records # 响应(data 中每条记录均含 post_app / note 字段,可能为 null) {"code":200,"message":"查询成功","data":[{"id":1,"device_name":"...","device_ip":"...","access_time":"...","post_app":"...","note":"..."}]}
| 参数 | 类型 | 说明 |
|---|---|---|
record_id | int | 记录 ID,不存在时返回 404 |
curl http://47.98.137.35:8486/api/records/1
| 参数 | 类型 | 默认 | 范围 | 说明 |
|---|---|---|---|---|
time_range | string | 24h | 1h / 24h / 7d / all | 快捷时间窗口 |
since | string | - | YYYY-MM-DD HH:MM:SS | 自定义起始时间 |
until | string | - | YYYY-MM-DD HH:MM:SS | 自定义结束时间 |
device_name | string | - | - | 精确按设备名 |
post_app | string | - | - | 精确按应用名 |
tool | string | - | - | 精确按工具标签 |
ip | string | - | - | 精确按访问 IP |
order | string | time_desc | time_desc / time_asc / id_desc / id_asc | 排序方向 |
limit | int | 100 | 1~1000 | 本次返回条数 |
offset | int | 0 | ≥0 | 跳过条数(翻页用) |
include_active_excludes | bool | true | - | 是否附带应用当前启用的 exclude 规则 |
exclude_ips | string | - | - | 额外的排除 IP(逗号分隔) |
# 近 7 天、android 应用、按时间倒序 curl "http://47.98.137.35:8486/api/records/filter?time_range=7d&post_app=android" # 自定义时间区间 + 设备名精确筛选 curl "http://47.98.137.35:8486/api/records/filter?time_range=all&since=2026-10-01%2000:00:00&until=2026-10-11%2023:59:59&device_name=%E5%AE%9E%E9%AA%8C%E5%AE%A4%E7%94%B5%E8%84%91A" # 响应 {"code":200,"message":"查询成功,共 3 条","data":{"total":3,"limit":100,"offset":0,"items":[...],"time_range":"7d","order":"time_desc","exclude_ips":[]}}
与 /api/records/filter 一致,额外加 max_rows(1~100000,默认 10000)。
# 导出近 24 小时的所有记录 curl -OJ "http://47.98.137.35:8486/api/records/export.csv?time_range=24h" # 导出指定应用 + 自定义时间区间 curl -OJ "http://47.98.137.35:8486/api/records/export.csv?post_app=android&since=2026-10-01%2000:00:00&until=2026-10-11%2023:59:59" # CSV 头部(包含 id/device_name/device_ip/access_time/post_app/tool/note) id,device_name,device_ip,access_time,post_app,tool,note 1,实验室电脑A,192.168.1.10,2026-10-11 14:30:00,android,scanner, 2,实验室电脑B,192.168.1.11,2026-10-11 14:32:00,ios,monitor,备注
基于 access_records 表的多维度统计:按应用、按工具、按 IP 维度统计访问次数与分布,
支持 1h / 24h / 7d / all 四种时间窗口,应用「IP 白名单/排除」规则自动纳入统计口径,
并对重复查询使用 30s 内存缓存,保证响应延迟 < 500ms。
| 参数 | 类型 | 默认 | 范围 | 说明 |
|---|---|---|---|---|
time_range | string | 24h | 1h / 24h / 7d / all | 时间窗口 |
include_active_excludes | bool | true | - | 是否应用当前启用的 exclude 规则 |
exclude_ips | string | - | - | 额外排除 IP(逗号分隔) |
use_cache | bool | true | - | 是否使用 30s 缓存 |
# 响应示例
{"code":200,"message":"查询成功","data":{"time_range":"24h","exclude_ips":["10.0.0.1"],"stats":{"total_visits":142,"unique_ips":38,"unique_devices":42,"unique_apps":5,"unique_tools":3,"latest_access":"2026-10-11 14:32:00","from_cache":false}}}
| 参数 | 类型 | 默认 | 范围 | 说明 |
|---|---|---|---|---|
time_range | string | 24h | 1h / 24h / 7d / all | 时间窗口 |
order | string | count_desc | count_desc / count_asc / app_asc / app_desc | 排序方向 |
include_active_excludes | bool | true | - | 应用 exclude 规则 |
exclude_ips | string | - | - | 额外排除 IP |
# 响应示例(items 内每项:app / count / unique_ips / first_seen / last_seen)
{"code":200,"message":"查询成功,共 3 项","data":{"items":[{"app":"android","count":80,"unique_ips":25,"first_seen":"...","last_seen":"..."},{"app":"ios","count":42,"unique_ips":10,...},{"app":"(未指定)","count":20,"unique_ips":3,...}]}}
同 /api/stats/by_app,order 限定 count_desc / count_asc。
# 响应示例(items 内每项:tool / count / unique_ips / unique_devices / last_seen)
{"code":200,"message":"查询成功,共 4 项","data":{"items":[{"tool":"scanner","count":60,"unique_ips":20,"unique_devices":30,"last_seen":"..."},{"tool":"monitor","count":30,...}]}}
POST /api/access 时可传 tool 字段标识工具维度。
| 参数 | 类型 | 默认 | 范围 | 说明 |
|---|---|---|---|---|
time_range | string | 24h | 1h / 24h / 7d / all | 时间窗口 |
order | string | count_desc | count_desc / count_asc | 排序 |
limit | int | 100 | 1~1000 | 最多返回 IP 数 |
include_active_excludes | bool | true | - | 应用 exclude 规则 |
exclude_ips | string | - | - | 额外排除 IP |
# 响应(items 内每项:ip / count / unique_devices / unique_apps / first_seen / last_seen)
{"code":200,"message":"查询成功,共 30 项","data":{"items":[{"ip":"192.168.1.10","count":25,"unique_devices":3,"unique_apps":2,...}]}}
| 参数 | 类型 | 默认 | 范围 | 说明 |
|---|---|---|---|---|
time_range | string | 7d | 1h / 24h / 7d / all | 时间窗口 |
order | string | recent_desc | recent_desc / recent_asc / name_asc / name_desc | 排序 |
limit | int | 500 | 1~5000 | 最多返回条数 |
include_active_excludes | bool | true | - | 应用 exclude 规则 |
exclude_ips | string | - | - | 额外排除 IP |
# 响应(items 内每项:device_name / last_ip / last_app / last_tool / visits=1 / first_access / last_access)
{"code":200,"message":"查询成功,共 12 项","data":{"items":[{"device_name":"临时访客-张三","last_ip":"203.0.113.5","last_app":"android","last_tool":"scanner","visits":1,"first_access":"...","last_access":"..."}]}}
用于配置不纳入统计或根本不记录的 IP 列表(如开发者自身 IP),支持三种匹配写法:
精确 IP(192.168.1.10)、通配(192.168.*.*)、CIDR(192.168.1.0/24)。
规则变更会立即生效(无需重启),并自动清空统计缓存。
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
only_enabled | bool | false | true 时只返回启用的规则 |
# 响应(每项:id / ip_pattern / rule_type / note / enabled / created_at / updated_at)
{"code":200,"message":"查询成功,共 2 条","data":[{"id":1,"ip_pattern":"10.0.0.1","rule_type":"exclude","note":"开发者自身 IP","enabled":1,"created_at":"...","updated_at":"..."},{"id":2,"ip_pattern":"192.168.*.*","rule_type":"whitelist","note":"内网不统计","enabled":1,"created_at":"...","updated_at":"..."}]}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
ip_pattern | string | 是 | 精确 IP / 通配 / CIDR |
rule_type | string | 是 | whitelist(白名单,不入库)/ exclude(排除,不纳入统计) |
note | string | 否 | 备注 |
enabled | bool | 否 | 是否启用,默认 true |
admin_password | string | 是 | 管理员密码 |
# 新增示例:排除开发者自身 IP curl -X POST http://47.98.137.35:8486/api/ip_rules \ -H "Content-Type: application/json" \ -d '{"ip_pattern":"10.0.0.1","rule_type":"exclude","note":"开发者自身 IP","admin_password":"YuShare-xxxxxxxxxxxxxxxx"}' # 新增 CIDR 规则:内网整段不纳入统计 curl -X POST http://47.98.137.35:8486/api/ip_rules \ -H "Content-Type: application/json" \ -d '{"ip_pattern":"192.168.1.0/24","rule_type":"exclude","admin_password":"..."}' # 响应 {"code":200,"message":"保存成功","data":{"id":1,"ip_pattern":"10.0.0.1","rule_type":"exclude","note":"开发者自身 IP","enabled":1,"created_at":"...","updated_at":"..."}}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
enabled | bool | 是 | 目标状态 |
admin_password | string | 是 | 管理员密码 |
curl -X POST http://47.98.137.35:8486/api/ip_rules/1/toggle \
-H "Content-Type: application/json" \
-d '{"enabled":false,"admin_password":"YuShare-xxxxxxxxxxxxxxxx"}'
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
admin_password | string | 是 | 管理员密码;错误返回 403 |
curl -X DELETE "http://47.98.137.35:8486/api/ip_rules/1?admin_password=YuShare-xxxxxxxxxxxxxxxx"
| 项目 | 说明 |
|---|---|
| Content-Type | multipart/form-data |
| 表单字段 | file(图片文件,支持 PNG / JPG / BMP / WebP) |
# 请求 curl -X POST http://47.98.137.35:8486/api/ocr -F "file=@/path/to/image.png" # 响应 {"code":200,"message":"识别成功","data":{"text":"图片中识别出的文字..."}}
当前库内共 23748 条书籍记录(其中已生成分享链接 42 条,已上传 1938 条 / 待上传 21805 条)。
分享字段:fid_key(主键)、fid、filename(书名)、
size(字节)、share_url(夸克分享链接)、passcode(提取码)、
pwd_id、shared_at;
元数据字段(由 scripts/novel_meta.py 扫描写入):title、author、category、summary、
novel_path、encoding、content_hash、meta_at;
上传状态字段:pipeline_status(待上传 / 已上传)、upload_time。
用于手工登记小说之外的分享内容,字段:name(名称)、
description(描述)、share_url(夸克网盘分享链接)、
created_at(登记时间,服务器自动生成)。
图形化填写页面:其他分享内容页。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
username | string | 是 | 用户名;不能为空或纯空白字符 |
contact | string | 否 | 联系方式(手机号/邮箱/微信等),可为空 |
content | string | 是 | 反馈内容;不能为空或纯空白字符 |
# 请求 curl -X POST http://47.98.137.35:8486/api/feedback \ -H "Content-Type: application/json" \ -d '{"username": "张三", "contact": "13800000000", "content": "App 打开小说列表偶尔卡死"}' # 联系方式可不传 curl -X POST http://47.98.137.35:8486/api/feedback \ -H "Content-Type: application/json" \ -d '{"username": "张三", "content": "希望增加夜间模式"}' # 响应(id 自增,client_ip 与 created_at 由服务器自动记录,status 默认为「未处理」) {"code":200,"message":"反馈提交成功","data":{"id":4,"username":"张三","contact":"13800000000","content":"App 打开小说列表偶尔卡死","client_ip":"x.x.x.x","created_at":"2026-10-05 13:46:00","status":"未处理"}}
curl http://47.98.137.35:8486/api/feedback
# 响应(data 中每条记录含 status 处理状态:未处理/已处理/无用)
{"code":200,"message":"查询成功,共 3 条","data":[
{"id":1,"username":"张三","contact":"13800000000","content":"App 打开小说列表偶尔卡死","client_ip":"x.x.x.x","created_at":"2026-09-23 21:40:06","status":"已处理"},
{"id":2,"username":"李四","contact":null,"content":"希望增加夜间模式","client_ip":"x.x.x.x","created_at":"2026-09-23 21:40:07","status":"未处理"},
{"id":3,"username":"赵六","contact":null,"content":"反馈内容测试","client_ip":"x.x.x.x","created_at":"2026-09-23 21:40:09","status":"未处理"}
]}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
status | string | 是 | 目标状态:未处理 / 已处理 / 无用(其他值 422) |
admin_password | string | 是 | 管理员密码;错误返回 403 |
# 请求 curl -X POST http://47.98.137.35:8486/api/feedback/3/status \ -H "Content-Type: application/json" \ -d '{"status": "已处理", "admin_password": "YuShare-xxxxxxxxxxxxxxxx"}' # 响应(data 为更新后的完整记录) {"code":200,"message":"反馈 3 状态已更新为「已处理」","data":{"id":3,"username":"赵六","contact":null,"content":"...","client_ip":"x.x.x.x","created_at":"...","status":"已处理"}}
图形化操作:在 反馈查看器 中点击每行的状态按钮即可(密码输入一次后缓存在浏览器)。
提供两站之间铁路里程(公里)的查询。车站数据只来自 12306(官方车站表
station_name.js,由 scripts/sync_stations.py 同步);
里程来自本地维护的 mileage_pairs(站对 → 里程映射)——
命中即返回,未命中即无值。原铁路网络图 / 外部 API / 直线估算等降级层已随
「仅保留 12306 车站数据」一并移除。所有调用均落库到
mileage_call_log,便于排障。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
from_telecode | string | 是 | 出发站电报码(3 位大写字母,如 BJP) |
to_telecode | string | 是 | 到达站电报码,3 位大写字母;不能与出发站相同 |
| 字段 | 类型 | 说明 |
|---|---|---|
distance_km | number | null | 里程值(公里);未命中时为 null |
source | string | null | 命中时恒为 mileage_pairs |
estimated | bool | 恒 false(已无估算层,保留字段仅为兼容) |
duration_ms | int | 本次调用耗时(毫秒) |
primary_status | string | 查询状态:success / miss / error |
error | string | null | 失败原因(成功时为 null) |
# 命中(数据已在本地 mileage_pairs) curl -X POST http://47.98.137.35:8486/api/mileage/query \ -H "Content-Type: application/json" \ -d '{"from_telecode": "BJP", "to_telecode": "SHH"}' # 响应(code=200 表示命中,distance_km 才有值) {"code":200,"message":"查询成功","data":{"distance_km":1318.0,"source":"mileage_pairs","estimated":false,"duration_ms":1,"primary_status":"success","error":null,"is_manual":false,"pair_source":"manual"}} # 未命中(该站对尚未维护里程) {"code":500,"message":"里程映射未命中(当前仅保留 12306 车站数据,里程需预先维护)","data":{"distance_km":null,"source":null,"estimated":false,"primary_status":"miss","error":"..."}}
| 参数 | 类型 | 默认 | 范围 | 说明 |
|---|---|---|---|---|
limit | int | 20 | 1 ~ 500 | 本次返回条数 |
offset | int | 0 | ≥ 0 | 跳过条数(翻页用) |
curl "http://47.98.137.35:8486/api/mileage/pairs?limit=50&offset=0"
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
limit | int | 50 | 本次返回条数(1~500) |
offset | int | 0 | 跳过条数(翻页用) |
curl "http://47.98.137.35:8486/api/mileage/logs?limit=20"
curl http://47.98.137.35:8486/api/mileage/stats
# 响应
{"code":200,"message":"查询成功","data":{"total_calls":42,"hit_calls":39,"miss_calls":3,"hit_rate":0.9286,"last_call_at":"2026-10-11 14:32:01","pairs_total":120}}
curl http://47.98.137.35:8486/api/mileage/health
# 响应
{"code":200,"message":"查询成功","data":{"station_source":"12306","stations":3404,"pairs":120,"legacy_layers":[]}}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
from_telecode | string | 是 | 出发站电报码,3 位大写字母 |
to_telecode | string | 是 | 到达站电报码,3 位大写字母 |
distance_km | number | 是 | 里程值(公里,> 0) |
admin_password | string | 是 | 管理员密码(复用 share_admin_password.txt) |
reason | string | 否 | 覆盖原因,便于审计 |
# 请求
curl -X POST http://47.98.137.35:8486/api/mileage/admin/override \
-H "Content-Type: application/json" \
-d '{"from_telecode":"BJP","to_telecode":"SHH","distance_km":1318,"admin_password":"YuShare-xxxxxxxxxxxxxxxx","reason":"人工校准"}'
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
telecode | string | 是 | 电报码,3 位大写字母 |
name | string | 是 | 站名(中文) |
pinyin | string | 否 | 全拼 |
abbr | string | 否 | 简拼 |
admin_password | string | 是 | 管理员密码 |
curl -X POST http://47.98.137.35:8486/api/mileage/station/upsert \
-H "Content-Type: application/json" \
-d '{"telecode":"BJP","name":"北京","pinyin":"beijing","abbr":"bj","admin_password":"YuShare-xxxxxxxxxxxxxxxx"}'
| 参数 | 类型 | 说明 |
|---|---|---|
telecode | string | 电报码(3 位大写字母),不区分大小写 |
curl http://47.98.137.35:8486/api/mileage/station/BJP
# 不存在时返回 404
{"detail":"车站 XXX 不存在"}