ChristandClaude Opus 4.8 57f9090dd2 refactor: automation 中心落地 + 清理 delivery_rules/SystemMessage 死代码
把卡密自动发货从 engine.DeliveryService 收敛到统一的 automation.Center:
WS 事件/计划任务/手动触发统一为 Task,trigger_key 持久化防重,付款发货、
评价赠品、超时求评价共用一套规则+动作编排。新增 internal/automation 包、
db.AutomationRules repository、00007 迁移。

同步删除被取代的并行死系统:
- engine.DeliveryService + delivery_test.go(已无引用)
- db.DeliveryRules/DeliveryRule + 3 个 Match 方法(生产零调用)
- card_handlers 的 /delivery-rules CRUD(前端早已只走 automation-rules)
- engine.SystemMessage + extractSystemMessage(dispatch 不再单独路由 message["3"])
- store.DeliveryRules 字段、Cards.IncrementDeliveryTimes
- 00008 迁移 DROP delivery_rules/delivery_rule_variants + email_verifications/
  captcha_codes/ai_item_cache/risk_control_logs + publish 批次 3 个死列
- isAPIPath 清理 ~15 个未挂载的前缀,stub_handlers.go 内联删除
- vite.config 删 /delivery-rules proxy

其它:orders.Upsert 注释改为诚实描述(version 列不参与并发控制);
dispatch.cleanupDedupLocked 用 sort.Slice 取代 O(n²) 选择排序;
删自定义 min 用内置;deliveryRuleItemOwned 改名 itemOwnedByUser。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 21:40:15 +08:00
2026-06-28 11:54:39 +08:00
2026-06-28 12:01:39 +08:00
2026-06-28 11:54:39 +08:00
2026-06-28 11:54:39 +08:00
2026-06-28 12:01:39 +08:00

闲鱼管家

这是当前活跃版本:Go 后端 + React 前端。

旧目录 ../xianyu-super-butler/ 是历史 Python/FastAPI 版本。当前 xianyu-go 仓库已经包含自己的前端源码,后续功能迭代应改这里:

xianyu-go/
  cmd/server/              Go 服务入口
  internal/                Go 后端代码
  frontend/                当前活跃 React 前端源码
  internal/webui/static/   前端构建产物,Go 会内置并提供给浏览器

首次运行

1. 安装前端依赖并构建

cd /Users/christ/Workspace/git/xianyu/xianyu-go/frontend
npm install
npm run build

构建产物会写入:

xianyu-go/internal/webui/static/

2. 初始化管理员

cd /Users/christ/Workspace/git/xianyu/xianyu-go
go run ./cmd/server -init-admin -db data/xianyu_data.db

也可以非交互传密码:

go run ./cmd/server \
  -init-admin \
  -db data/xianyu_data.db \
  -admin-password '你的密码'

3. 启动服务

cd /Users/christ/Workspace/git/xianyu/xianyu-go
go run ./cmd/server -db data/xianyu_data.db -addr :8080

浏览器访问:

http://localhost:8080

不传 -web 时,Go 会使用 internal/webui/static 中的内置前端资源。

开发模式

后端:

cd /Users/christ/Workspace/git/xianyu/xianyu-go
go run ./cmd/server -db data/xianyu_data.db -addr :8080

前端开发服务器:

cd /Users/christ/Workspace/git/xianyu/xianyu-go/frontend
npm run dev

访问:

http://localhost:3000

Vite 会把 API 请求代理到 http://localhost:8080。

编译运行

cd /Users/christ/Workspace/git/xianyu/xianyu-go
go build -o xianyu-server ./cmd/server
./xianyu-server -db data/xianyu_data.db -addr :8080

如果要使用外部前端目录,也可以传:

./xianyu-server -db data/xianyu_data.db -addr :8080 -web /path/to/static

Docker 部署注意

批量铺货会用到上传目录。容器部署时建议挂载持久化数据:

-v ./data:/app/data

并设置:

XIANYU_UPLOAD_DIR=/app/data/uploads

数据库建议放在:

/app/data/xianyu_data.db

常用参数

参数 说明
-db SQLite 数据库路径,默认 data/xianyu_data.db
-addr HTTP 监听地址,默认 :8080
-web 外部前端静态资源目录;不传则用内置前端
-init-admin 初始化或重置管理员后退出
-admin-email 初始化管理员邮箱
-admin-password 初始化管理员密码
-no-browser 禁用内置浏览器自动化
-secure HTTPS 模式,Cookie 加 Secure
-v 调试日志

验证

cd /Users/christ/Workspace/git/xianyu/xianyu-go
go test ./...

cd /Users/christ/Workspace/git/xianyu/xianyu-go/frontend
npm run build
S
Description
闲鱼多账号自动发货、消息回复系统——基于 Go 与 React 构建
Readme Apache-2.0
17 MiB
0 Stars 1 Watchers 0 Forks
Languages
Go 74.2%
TypeScript 23.4%
JavaScript 1.1%
Inno Setup 0.5%
Shell 0.4%
Other 0.3%