文档: 完善项目命名、协议与使用指南

This commit is contained in:
Christ committed 2026-07-25 14:17:48 +08:00
1 parent 16b2b84fa2
commit 614bae4b2b
25 files changed
+572 -45

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
# 复制为 .env 后再填写。不要提交包含真实密钥的 .env。
COMPOSE_PROJECT_NAME=xianyu
COMPOSE_PROJECT_NAME=ydisks-xianyu-helper
# PostgreSQL 17
POSTGRES_IMAGE=postgres:17-trixie
@@ -10,7 +10,7 @@ POSTGRES_PASSWORD=请替换为高强度数据库密码
DATABASE_URL=postgres://xianyu:请替换为URL编码后的数据库密码@postgres:5432/xianyu?sslmode=disable
# 应用:默认 compose.yml 仅拉取 GHCR 镜像,不会在服务器上构建源码。
XIANYU_IMAGE=ghcr.io/christ9038/xinayu-go:latest
XIANYU_IMAGE=ghcr.io/christ9038/ydisks-xianyu-helper:latest
XIANYU_DATA_KEY=请替换为稳定且足够长的随机密钥
XIANYU_BIND_ADDRESS=0.0.0.0
XIANYU_HTTP_PORT=8080
+2 -2
View File
@@ -21,7 +21,7 @@ The active application contains:
## Common commands
```bash
cd /Users/christ/Workspace/git/xianyu/xianyu-go
cd /Users/christ/Workspace/git/xianyu/Ydisks-Xianyu-Helper
make build # go build ./cmd/server
make test # go test ./...
@@ -74,7 +74,7 @@ go test ./internal/db -run TestMultiDB -v
Build the frontend:
```bash
cd /Users/christ/Workspace/git/xianyu/xianyu-go/frontend
cd /Users/christ/Workspace/git/xianyu/Ydisks-Xianyu-Helper/frontend
npm install
npm run build
```
+1 -1
View File
@@ -2,7 +2,7 @@ FROM golang:1.26-trixie AS go-toolchain
# 复用生产运行镜像中已经安装并验证过的 Chromium、Node 和 Playwright driver,
# 只补 Go 工具链来执行真实浏览器集成测试。
FROM xianyu-go:functional
FROM ydisks-xianyu-helper:functional
ENV PATH=/usr/local/go/bin:${PATH}
ENV CGO_ENABLED=0
WORKDIR /src
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+1 -1
View File
@@ -1,4 +1,4 @@
# xianyu-go 常用命令入口。详见各 target 注释。
# Ydisks-Xianyu-Helper 常用命令入口。详见各 target 注释。
GO ?= go
GOLANGCI_LINT ?= golangci-lint
+5
View File
@@ -0,0 +1,5 @@
Ydisks闲鱼助手 / Ydisks-Xianyu-Helper
Copyright 2026 Christ9038
This product includes software developed by Christ9038 and is licensed under
the Apache License, Version 2.0.
+25 -14
View File
@@ -1,14 +1,17 @@
# Xianyu Go
# Ydisks闲鱼助手
基于 Go 与 React 构建的闲鱼多账号管理、消息回复与自动发货系统
[![Go](https://img.shields.io/badge/Go-1.26-00ADD8?logo=go&logoColor=white)](go.mod)
[![React](https://img.shields.io/badge/React-19-61DAFB?logo=react&logoColor=black)](frontend/package.json)
[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-17-4169E1?logo=postgresql&logoColor=white)](compose.yml)
[![Docker Image](https://github.com/Christ9038/xinayu-go/actions/workflows/docker-publish.yml/badge.svg?branch=dev)](https://github.com/Christ9038/xinayu-go/actions/workflows/docker-publish.yml)
[![Docker Image](https://github.com/Christ9038/Ydisks-Xianyu-Helper/actions/workflows/docker-publish.yml/badge.svg?branch=dev)](https://github.com/Christ9038/Ydisks-Xianyu-Helper/actions/workflows/docker-publish.yml)
[功能特性](#功能特性) · [快速开始](#快速开始) · [配置说明](#配置说明) ·
[Docker 部署](#docker-部署) · [开发指南](#开发指南)
[Docker 部署](#docker-部署) · [开发指南](#开发指南) · [开源协议](#开源协议)
操作手册见仓库内的 [GitHub Wiki 文档](docs/wiki/Home.md):包含数据库选择、账号接入、
批量铺货、自动化发货、AI、通知和运维流程。
> [!IMPORTANT]
> 本项目是社区维护的非官方工具,与闲鱼、阿里巴巴集团及其关联公司无隶属、合作或
@@ -17,7 +20,7 @@
## 项目简介
Xianyu Go 是一个面向闲鱼卖家的自托管管理系统。它将账号运行、即时消息、订单、
Ydisks闲鱼助手(英文项目名:Ydisks-Xianyu-Helper)是一个面向闲鱼卖家的自托管管理系统。它将账号运行、即时消息、订单、
商品、卡密库存、自动化规则、AI 回复和异常通知整合到同一个 Web 管理后台,适合需要
同时维护多个闲鱼账号或交付数字商品的个人与小型团队。
@@ -25,6 +28,14 @@ Xianyu Go 是一个面向闲鱼卖家的自托管管理系统。它将账号运
不是业务请求代理,仅用于读取真实浏览器指纹以及处理必须依赖浏览器环境的滑块风控。
扫码登录、人脸验证流程、消息连接、凭证更新和绝大部分业务逻辑均由 Go 客户端完成。
## 开源协议
本项目采用 [Apache License 2.0](LICENSE) 开源,版权所有 © 2026 Christ9038。
你可以使用、复制、修改和分发本项目代码;分发原始或衍生代码时,必须附带许可证文本,
保留 [NOTICE](NOTICE) 中 Ydisks闲鱼助手(Ydisks-Xianyu-Helper)的版权与署名声明,并在
修改过的文件中明确标注已修改。
### 适用场景
- 多个闲鱼账号的统一在线状态与消息管理
@@ -84,8 +95,8 @@ flowchart LR
Docker Desktop,并使用 Docker Compose v2。
```bash
git clone https://github.com/Christ9038/xinayu-go.git
cd xinayu-go
git clone https://github.com/Christ9038/Ydisks-Xianyu-Helper.git
cd Ydisks-Xianyu-Helper
cp .env.example .env
```
@@ -133,8 +144,8 @@ docker compose up -d
构建前端:
```bash
git clone https://github.com/Christ9038/xinayu-go.git
cd xinayu-go
git clone https://github.com/Christ9038/Ydisks-Xianyu-Helper.git
cd Ydisks-Xianyu-Helper
npm --prefix frontend ci
npm --prefix frontend run build
```
@@ -207,12 +218,12 @@ Docker Compose 还支持:
| 变量 | 默认值 | 说明 |
| --- | --- | --- |
| `COMPOSE_PROJECT_NAME` | `xianyu` | Compose 项目名及命名卷前缀 |
| `COMPOSE_PROJECT_NAME` | `ydisks-xianyu-helper` | Compose 项目名及命名卷前缀 |
| `POSTGRES_IMAGE` | `postgres:17-trixie` | PostgreSQL 镜像 |
| `POSTGRES_DB` | 必填 | 数据库名 |
| `POSTGRES_USER` | 必填 | 数据库用户 |
| `POSTGRES_PASSWORD` | 必填 | 数据库密码 |
| `XIANYU_IMAGE` | `ghcr.io/christ9038/xinayu-go:latest` | 应用镜像与标签 |
| `XIANYU_IMAGE` | `ghcr.io/christ9038/ydisks-xianyu-helper:latest` | 应用镜像与标签 |
| `XIANYU_BIND_ADDRESS` | `0.0.0.0` | 应用在宿主机上的绑定地址 |
| `XIANYU_HTTP_PORT` | `8080` | 应用在宿主机上的端口 |
@@ -282,7 +293,7 @@ LocalAI 或兼容网关。只有在明确了解数据流向时才应向外部 AI
GitHub Actions 会将同一标签发布为多架构镜像:
```text
ghcr.io/christ9038/xinayu-go:dev
ghcr.io/christ9038/ydisks-xianyu-helper:dev
├── linux/amd64
└── linux/arm64
```
@@ -315,7 +326,7 @@ docker compose up -d
| 服务 | 用途 |
| --- | --- |
| `postgres` | PostgreSQL 17 数据库,仅在 Compose 内部网络开放 5432 |
| `app` | Xianyu Go 主服务、前端和 Chromium |
| `app` | Ydisks闲鱼助手主服务、前端和 Chromium |
`app` 会在首次启动时自动创建 `admin`;如果管理员已存在,后续 `up`、重启或升级均不会
修改其密码。
@@ -334,8 +345,8 @@ docker compose up -d
### 完整部署步骤
```bash
git clone https://github.com/Christ9038/xinayu-go.git
cd xinayu-go
git clone https://github.com/Christ9038/Ydisks-Xianyu-Helper.git
cd Ydisks-Xianyu-Helper
cp .env.example .env
```
+1 -1
View File
@@ -38,7 +38,7 @@ services:
start_period: 10s
app:
image: ${XIANYU_IMAGE:-ghcr.io/christ9038/xinayu-go:latest}
image: ${XIANYU_IMAGE:-ghcr.io/christ9038/ydisks-xianyu-helper:latest}
pull_policy: always
restart: unless-stopped
depends_on:
+2 -2
View File
@@ -36,7 +36,7 @@ services:
start_period: 10s
app:
image: ${XIANYU_IMAGE:-xianyu-go:debian13}
image: ${XIANYU_IMAGE:-ydisks-xianyu-helper:debian13}
build:
context: .
dockerfile: Dockerfile.debian13
@@ -57,7 +57,7 @@ services:
start_period: 30s
init-admin:
image: ${XIANYU_IMAGE:-xianyu-go:debian13}
image: ${XIANYU_IMAGE:-ydisks-xianyu-helper:debian13}
build:
context: .
dockerfile: Dockerfile.debian13
+11 -11
View File
@@ -1,4 +1,4 @@
name: xianyu-functional
name: ydisks-xianyu-helper-functional
x-mysql-url: &mysql-url mysql://root:xianyu_root_password@tcp(mysql:3306)/xianyu?parseTime=true&loc=UTC
x-postgres-url: &postgres-url postgres://xianyu:xianyu_postgres_password@postgres:5432/xianyu?sslmode=disable&timezone=UTC
@@ -65,7 +65,7 @@ services:
sqlite3 /seed/xianyu_data.db "PRAGMA quick_check" | grep -qx ok
seed-mysql:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
build:
context: .
dockerfile: Dockerfile.debian13
@@ -82,7 +82,7 @@ services:
command: ["/app/xianyu-dbseed", "-source", "/seed/xianyu_data.db", "-target", *mysql-url, "-limit", "20"]
seed-sqlite:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
build:
context: .
dockerfile: Dockerfile.debian13
@@ -98,7 +98,7 @@ services:
command: ["/app/xianyu-dbseed", "-source", "/seed/xianyu_data.db", "-target", "/app/data/xianyu-functional.db", "-limit", "20"]
seed-postgres:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
restart: "no"
depends_on:
postgres:
@@ -112,7 +112,7 @@ services:
command: ["/app/xianyu-dbseed", "-source", "/seed/xianyu_data.db", "-target", *postgres-url, "-limit", "20"]
app-mysql:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
restart: unless-stopped
depends_on:
seed-mysql:
@@ -134,7 +134,7 @@ services:
retries: 30
app-sqlite:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
restart: unless-stopped
depends_on:
seed-sqlite:
@@ -156,7 +156,7 @@ services:
retries: 30
app-postgres:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
restart: unless-stopped
depends_on:
seed-postgres:
@@ -223,7 +223,7 @@ services:
command: ["sh", "-c", "npm run typecheck && npm test && npm run build"]
dbverify-mysql:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
depends_on:
mysql:
condition: service_healthy
@@ -232,7 +232,7 @@ services:
command: ["/app/xianyu-dbverify", *mysql-url]
dbverify-sqlite:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
environment:
XIANYU_DATA_KEY: *data-key
volumes:
@@ -240,7 +240,7 @@ services:
command: ["/app/xianyu-dbverify", "/app/data/verify.db"]
dbverify-postgres:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
depends_on:
postgres:
condition: service_healthy
@@ -249,7 +249,7 @@ services:
command: ["/app/xianyu-dbverify", *postgres-url]
functional-test:
image: xianyu-go:functional
image: ydisks-xianyu-helper:functional
restart: "no"
depends_on:
app-sqlite:
+1 -1
View File
@@ -2,7 +2,7 @@
## 目标
参考 `zhinianboke/xianyu-auto-reply` 的实现,把当前项目缺少的登录态续期、MTOP 风控识别、扫码人脸验证能力补齐。改造重点是提升账号长期在线能力和风控状态的可恢复性,同时保持 `xianyu-go` 现有单进程架构清晰、可测试、可回滚。
参考 `zhinianboke/xianyu-auto-reply` 的实现,把当前项目缺少的登录态续期、MTOP 风控识别、扫码人脸验证能力补齐。改造重点是提升账号长期在线能力和风控状态的可恢复性,同时保持 `Ydisks-Xianyu-Helper` 现有单进程架构清晰、可测试、可回滚。
## 非目标
+46
View File
@@ -0,0 +1,46 @@
# AI、通知与运维
## 配置 AI 服务
系统级连接在“系统与 AI”设置,仅管理员可修改:
1. 填写 OpenAI 兼容的 API 地址,填到版本根路径即可,例如 `https://api.openai.com/v1` 或通义兼容地址 `https://dashscope.aliyuncs.com/compatible-mode/v1`;不要填 `/chat/completions`。
2. 填入 API Key,点击“读取模型”。若服务不支持模型列表,也可手动填模型名。
3. 保存系统设置。API Key 会作为敏感字段保存;仍应限制数据库和管理员访问。
4. 前往“账号管理”,在目标账号行打开“AI 设置”。
5. 打开“启用 AI 自动回复”,配置最大折扣比例、最大降价金额、最大砍价轮次和自定义提示词,保存。
6. 使用真实但无风险的砍价对话测试输出;确认金额边界和措辞均符合预期后再开启正式账号。
AI 用于处理买家的砍价消息。`0` 的最大折扣比例或金额表示不允许对应降价;砍价轮次应设置保守值。提示词应明确产品边界、禁止承诺事项、语气和转人工条件,不应放入 Cookie、密码、完整订单隐私或其他机密。
## 配置通知
1. 打开“通知设置”,先按需要配置系统 SMTP(仅邮件渠道需要)。
2. 新建通知渠道,选择 Bark、钉钉、飞书、企业微信、Telegram、邮件或自定义 Webhook,并填写该渠道所需地址/令牌。
3. 选择接收事件;不选择表示接收全部。可选事件包括掉线、恢复、禁用、安全验证、续期和交易结果。
4. 保存后点击“测试通知”,在目标渠道确认收到。
5. 回到“账号管理 → 编辑”,把通知渠道绑定到具体账号。仅创建渠道不会自动让账号使用它。
Webhook 和机器人令牌通常等同于密码。不要贴进截图、Issue 或聊天记录;更换令牌后立即更新渠道并重测。
## 日常巡检
每天或每次大促前检查:
- Dashboard 的在线账号、订单、库存和异常趋势;
- 自动化异常/延迟任务是否有待处理项;
- 批量卡密库存是否低于安全线;
- 最近一次通知是否可达;
- 登录续期和安全验证是否需要人工操作。
## 故障排查顺序
1. **账号不在线**:检查账号是否被暂停、Cookie 是否失效、是否需要扫码或安全验证;完成后确认恢复通知。
2. **未自动发货**:核对订单所属账号、商品/规格匹配、规则启用、卡密库存和自动化异常。先确认是否已经实际发送过内容。
3. **AI 无回复**:确认系统 API 地址、Key 和模型可用;再确认该账号 AI 已启用,且消息属于砍价场景。
4. **通知未达**:先点击测试通知,再核对事件筛选与账号绑定;邮件还需检查 SMTP 配置。
5. **数据库无法连接**:检查 `DATABASE_URL`、网络/TLS、数据库账号权限和服务日志。不要通过删除数据库来“修复”。
## 备份与恢复
备份至少包含数据库、`.env`(特别是 `XIANYU_DATA_KEY`)和必要的上传资源。恢复到新机器时先恢复数据库与同一把密钥,再启动服务;若密钥不一致,已加密的 Cookie、AI 和通知配置不可读取。恢复后先禁用高风险自动化,用测试订单逐项确认。
+34
View File
@@ -0,0 +1,34 @@
# Ydisks闲鱼助手 Wiki
本 Wiki 面向管理后台操作人员。先完成“部署与数据库”和“账号接入”,再配置库存、商品、自动化与 AI。
## 推荐上线路径
1. 选择并启动数据库;生产环境推荐 PostgreSQL。
2. 设置并备份 `XIANYU_DATA_KEY`,初始化管理员后登录后台。
3. 在“账号管理”扫码接入账号,确认账号为启用且在线状态。
4. 在“卡密库存”建立可交付内容。
5. 同步已有商品,或通过“商品管理”发布商品。
6. 在“自动化规则”建立付款发货、评价赠品或求评价规则。
7. 可选:在“系统与 AI”配置模型,再为每个账号启用 AI。
8. 建立通知渠道并绑定到账号;用测试通知验证。
9. 用小额测试订单验证“卡密发送 → 确认发货”全过程后,再开放正式商品。
## 先读这些页面
- [部署与数据库](部署与数据库)
- [账号、库存与商品](账号、库存与商品)
- [批量铺货](批量铺货)
- [自动化发货与回复](自动化发货与回复)
- [AI、通知与运维](AI、通知与运维)
## 关键安全规则
- 不要提交 `.env`、数据库备份、Cookie、API Key 或通知 Webhook 地址。
- `XIANYU_DATA_KEY` 用于加密 Cookie、密码、AI/SMTP 和通知凭据;换密钥会导致旧数据无法解密。务必和数据库一同离线备份。
- 自动化必须先用测试商品、测试卡密和小额订单验证。库存耗尽、账号掉线或风控时,不应假设发货已完成。
- 本项目为非官方工具。请确保使用方式符合平台规则、当地法律及账号授权范围。
## GitHub Wiki 同步
这些 Markdown 文件位于仓库 `docs/wiki/`,可直接复制到 GitHub Wiki 对应页面;文件名即页面名。`_Sidebar.md` 是 Wiki 导航。仓库内保留副本便于在 Pull Request 中审阅和版本化维护。
+8
View File
@@ -0,0 +1,8 @@
### Ydisks闲鱼助手
- [首页](Home)
- [部署与数据库](部署与数据库)
- [账号、库存与商品](账号、库存与商品)
- [批量铺货](批量铺货)
- [自动化发货与回复](自动化发货与回复)
- [AI、通知与运维](AI、通知与运维)
+51
View File
@@ -0,0 +1,51 @@
# 批量铺货
批量铺货会先预检,再启动后台发布任务。它最多一次处理 50 行商品;建议先用 1 行测试资料包验证后再跑正式批次。
## 1. 准备资料包
必需文件为 CSV、XLSX 或 TSV 表格;如引用本地图片,再提供 ZIP 图片包。下载“商品管理 → 批量铺货”中的模板可避免表头错误。
推荐中文表头:
```text
账号ID,标题,描述,价格,原价,库存,邮费模式,邮费,图片,付款发货启用,付款发货内容,评价赠品启用,评价赠品内容,求评价启用,求评价等待小时,求评价文案,求评价最多次数
```
也支持英文表头,但不能与中文混用。每行一个商品;`账号ID` 可留空并在上传页选择默认账号。
### 必填与格式
- 标题非空,价格大于 0;库存为正整数,留空默认 1。
- 邮费模式为 `free`/`包邮` 或 `fixed`/`固定邮费`;固定邮费时必须填邮费。
- 每件商品 1–9 张图片,多个用英文分号 `;` 分隔。可用公开 `https://` URL,或 ZIP 内相对路径。
- 本地图片 ZIP 最大 200 MiB,单图最大 10 MiB;表格最大 20 MiB。
- CSV 使用 UTF-8,建议带 BOM;不要在表头增加空格。
### 自动化列
“付款发货内容”和“评价赠品内容”格式相同:
```text
卡密组ID:每件份数:延迟秒;卡密组ID:每件份数:延迟秒
```
例如 `101:1;102:2:30`:先从组 101 发 1 份,再等待 30 秒从组 102 发 2 份。份数省略时为 1,延迟省略时为 0。卡密组 ID 从“卡密库存”复制。启用值可写“是”、`true`、`1` 或 `on`;不启用写“否”、`false`、`0` 或留空。
完整字段规范和示例见仓库 [批量铺货资料包准备规格](../批量铺货使用文档.md)。
## 2. 后台操作
1. 在“商品管理”点击“批量铺货”。
2. 选择表格;表格引用本地图片时同时选择 ZIP。
3. 未填账号 ID 时,在页面选择默认账号。
4. 点击预检,逐行处理错误。常见错误是账号未授权、卡密组不存在、图片路径不匹配、固定邮费缺失或价格为 0。
5. 所有需发布行确认无误后启动任务;不要关闭正在运行的任务页面。
6. 在任务详情查看成功、失败与进行中行。需要时取消任务;正在提交的单件商品可能继续完成。
7. 对可重试失败项使用“重试失败”,并下载结果 CSV 留档。
## 3. 常见问题
- **图片找不到**:ZIP 内路径必须与表格完全一致,使用 `/`,不能以 `/` 开头或包含 `..`。
- **自动化不生效**:检查卡密组 ID、账号归属、启用列和库存;发布成功后仍应查看自动化规则是否已创建。
- **任务中断**:先重新打开批次详情确认状态,避免重复新建整批任务;仅重试失败行。
+47
View File
@@ -0,0 +1,47 @@
# 自动化发货与回复
## 自动化的三种触发器
| 触发器 | 触发时机 | 标准流程 |
| --- | --- | --- |
| 付款后自动发货 | 收到付款系统卡片 | 匹配商品/规格 → 发送卡密 → 成功后确认发货。 |
| 评价后发送赠品 | 收到评价系统卡片 | 匹配商品/规格 → 发送赠品卡密。 |
| 超时未评价求评价 | 定时扫描已发货未评价订单 | 到达等待时间 → 发送提醒文案。 |
系统通知卡片只进入自动化判断;买家普通消息走关键词、默认回复和 AI 规则。
## 配置付款自动发货
前提:账号在线、商品已同步、卡密组已建立且有库存。
1. 进入“自动化规则”,选择“付款后自动发货”,点击新增。
2. 设置规则名称,选择目标账号和商品;商品有规格时为每个需要交付的规格建立对应配置。
3. 添加“发送卡密”动作,选择卡密库存、每件发送数量与是否启用。
4. 如需覆盖卡密组默认延迟,打开延迟覆盖并填写秒数;否则使用卡密组的默认延时。
5. 保存并确认规则处于启用状态。
6. 用测试订单确认:卡密内容已发送、卡密库存扣减正确、随后才确认发货。
按购买数量发货:动作中的“每件发送数量”会乘以订单购买数量。不要把每单总量误填为每件数量。
## 配置评价赠品与求评价
评价赠品的配置与付款发货相同,但触发器选择“评价后发送赠品”。赠品应使用独立卡密组,便于核对和补货。
配置求评价:
1. 新建“超时未评价求评价”规则,选择账号和商品。
2. 填写等待时间(发货后多少小时开始检查)、重复间隔及最多提醒次数。
3. 填写发送给买家的求评价文案,保存并启用。
4. 在测试订单上确认不会提前发送;达到最大次数后不再重复提醒。
## 异常处理与补发
“自动化规则”页面的异常区会列出可处理的自动化运行和延迟任务。先查看订单、库存、聊天记录和失败原因,再使用页面的“处理/解决”操作。不要在不确定已发货状态时直接重试,以免重复发卡。
需要人工补发时,在订单管理中定位订单,确认买家、商品和历史交付记录,再使用手动发货/补发能力。处理后记录原因并检查库存。
## 关键词与默认回复
在“自动化规则”的“关键词回复”页:选择账号 → 新增规则 → 填写关键词与文本或图片 URL → 保存。关键词规则用于买家普通消息。
“账号默认回复”只在关键词和 AI 都未处理该消息时使用。可设置文本、图片 URL 和“同一会话只回复一次”。上线前避免关键词、默认回复和 AI 提示词对同类问题给出互相矛盾的答案。
+42
View File
@@ -0,0 +1,42 @@
# 账号、库存与商品
## 1. 接入账号
1. 进入“账号管理”,选择添加账号/扫码登录。
2. 用目标闲鱼账号在官方客户端完成扫码;若出现人脸或安全验证,按页面提示在官方流程中完成。
3. 等待后台保存登录信息,确认昵称、账号 ID 和运行状态正常。
4. 为账号填写备注,按需开启或暂停账号,并进入编辑页绑定通知渠道。
5. 首次接入后同步一次商品;开始自动化前确认账号处于启用状态。
不要手工向他人发送 Cookie。登录态、指纹和密码等敏感值由系统加密存储,依赖固定的 `XIANYU_DATA_KEY`。
## 2. 创建卡密库存
付款自动发货和评价赠品都先依赖卡密库存。进入“卡密库存”后点击“添加新卡密”:
| 类型 | 适用内容 | 填写方式 |
| --- | --- | --- |
| 文本 | 固定说明、链接 | 填写文本内容。 |
| 批量卡密(`data`) | 一次性兑换码、序列号 | 每行一个卡密;发货会按库存消费。 |
| 图片 | 固定图片资源 | 填写公开可访问的图片 URL。 |
| API | 外部发码接口 | 填写 URL、GET/POST、超时、请求头和参数;先用无敏感测试数据验证。 |
通用字段包括名称、描述、启用状态和默认延时秒数。保存后复制“卡密组 ID”;它是自动化规则和批量铺货表格引用库存的唯一标识。
批量卡密可用“批量导入”创建,也可选择已有 `data` 类型卡密组追加新卡密。上架前检查库存余量;库存不足时应先补货,不要依赖人工补救。
## 3. 同步或发布商品
进入“商品管理”:
- 对已在闲鱼上存在的商品,选择同步全部或按页同步,确认商品归属到正确账号。
- 对单个新商品,使用发布入口填写标题、描述、价格、库存、邮费和图片。图片必须可用;提交前复核目标账号。
- 商品发布成功不等于已开启自动发货。仍需在“自动化规则”中按商品/规格绑定卡密组,或在批量铺货表格中一并声明自动化配置。
## 4. 上线前检查
1. 账号在线并已启用。
2. 商品已同步或发布成功,价格、库存和图片正确。
3. 所需卡密组启用且余量充足。
4. 自动化规则准确匹配商品;有规格时逐个规格确认。
5. 先用测试订单验证,检查订单列表、自动化异常列表和通知记录。
+82
View File
@@ -0,0 +1,82 @@
# 部署与数据库
## 选择数据库
| 场景 | 建议 | 原因 |
| --- | --- | --- |
| 本机试用、单人低频使用 | SQLite | 无需额外服务,数据库是一个文件。 |
| Docker 生产部署 | PostgreSQL 17 | 默认 Compose 已提供服务、持久化卷和健康检查。 |
| 已有 MySQL 运维体系 | MySQL 8+ | 可复用现有备份、监控和权限管理。 |
| 多人或长期运行 | PostgreSQL / MySQL | 更适合并发、备份和独立运维。 |
三种数据库均会在应用启动时自动执行内置迁移。连接优先级是:`DATABASE_URL` > `-db-url` > `-db`。升级生产库前先备份。
## Docker + PostgreSQL(推荐)
1. 复制配置:`cp .env.example .env`。
2. 编辑 `.env`,至少设置 `POSTGRES_DB`、`POSTGRES_USER`、`POSTGRES_PASSWORD`、`XIANYU_DATA_KEY`、`XIANYU_ADMIN_PASSWORD`。
3. 为 `XIANYU_DATA_KEY` 生成一次长期固定的随机值,例如 `openssl rand -base64 48`;不要在后续升级时更换。
4. 启动:`docker compose up -d`。
5. 查看:`docker compose ps` 和 `docker compose logs -f app`。
6. 打开 `http://服务器地址:8080`,用管理员账号登录。若未自动初始化,可按 README 的 `-init-admin` 命令执行。
默认连接已由 `compose.yml` 注入,不需要手写 PostgreSQL URL。若修改 `COMPOSE_PROJECT_NAME`,新卷名前缀也会变化;已有部署升级时保留原 `.env`,避免误用新空卷。
## SQLite
适合开发或轻量单机。默认数据库路径为 `data/xianyu_data.db`:
```bash
go run ./cmd/server -db data/xianyu_data.db -addr :8080
```
也可显式指定:
```bash
DATABASE_URL="sqlite://data/xianyu_data.db" ./xianyu-server
```
备份时先停服务,或使用 SQLite 在线备份工具;不要只复制正在写入的 WAL 数据库主文件。恢复时同时恢复数据库和原有 `XIANYU_DATA_KEY`。
## MySQL
先创建 UTF-8 数据库和最小权限账号,再为应用提供 URL:
```bash
DATABASE_URL="mysql://user:URL编码后的密码@tcp(db.example:3306)/xianyu" \
./xianyu-server -addr :8080
```
应用会补齐所需 MySQL 连接参数。密码中出现 `@`、`:`、`/` 等字符时必须 URL 编码。使用 TLS 的环境请按数据库驱动/基础设施要求配置安全连接,不要把真实密码写进命令历史。
## PostgreSQL(外部服务)
```bash
DATABASE_URL="postgres://user:URL编码后的密码@db.example:5432/xianyu?sslmode=require" \
./xianyu-server -addr :8080
```
仅在受信任的本机网络可考虑 `sslmode=disable`;公网或跨网络部署应使用 TLS。数据库账号只应拥有该应用数据库的必要权限。
## 初始化、备份和升级
初始化管理员:
```bash
go run ./cmd/server -init-admin -db data/xianyu_data.db -admin-password '强密码'
```
已有管理员时,仅确保其存在而不重置密码:
```bash
go run ./cmd/server -ensure-admin -admin-password '强密码'
```
PostgreSQL 备份示例:
```bash
docker compose exec -T postgres pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
> ydisks-backup.sql
```
升级顺序:备份数据库和 `.env` → 拉取/构建新镜像 → `docker compose up -d` → 查看日志确认迁移成功 → 登录检查账号和自动化任务。若迁移失败,停止继续操作并从备份恢复。
+3 -3
View File
@@ -1,6 +1,6 @@
# 闲鱼管家前端
# Ydisks闲鱼助手前端
React + Vite + TypeScript 单页应用,作为闲鱼管家 Go 后端的管理面板。
React + Vite + TypeScript 单页应用,作为 Ydisks闲鱼助手 Go 后端的管理面板。
## 目录结构
@@ -19,7 +19,7 @@ frontend/
## 开发
```bash
cd /Users/christ/Workspace/git/xianyu/xianyu-go/frontend
cd /Users/christ/Workspace/git/xianyu/Ydisks-Xianyu-Helper/frontend
npm install
npm run dev # http://localhost:3000,API 代理到 localhost:8080
```
+1 -1
View File
@@ -31,7 +31,7 @@ const CHANNEL_TYPES: Record<NotificationChannelType, ChannelTypeMeta> = {
fields: [
{ key: 'server_url', label: 'Bark 服务器', placeholder: 'https://api.day.app', required: true },
{ key: 'device_key', label: 'Device Key', placeholder: '你的 Bark 设备 Key', required: true },
{ key: 'title', label: '标题(可选)', placeholder: '闲鱼助手' },
{ key: 'title', label: '标题(可选)', placeholder: 'Ydisks闲鱼助手' },
{ key: 'sound', label: '铃声(可选)', placeholder: 'default' },
{ key: 'group', label: '分组(可选)', placeholder: 'xianyu' },
],
+2 -2
View File
@@ -1,11 +1,11 @@
{
"name": "闲鱼自动发货-pro",
"name": "ydisks-xianyu-helper",
"version": "0.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "闲鱼自动发货-pro",
"name": "ydisks-xianyu-helper",
"version": "0.0.0",
"dependencies": {
"axios": "^1.13.2",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "闲鱼自动发货-pro",
"name": "ydisks-xianyu-helper",
"private": true,
"version": "0.0.0",
"type": "module",
+1 -1
View File
@@ -147,7 +147,7 @@ func (s *Server) testChannel(w http.ResponseWriter, r *http.Request) {
if !s.requireChannelOwner(w, r, id) {
return
}
body := "🧪 通知渠道测试\n\n这是一条来自闲鱼助手的测试通知,收到说明渠道配置正常。\n时间: " +
body := "🧪 通知渠道测试\n\n这是一条来自Ydisks闲鱼助手的测试通知,收到说明渠道配置正常。\n时间: " +
time.Now().Format("2006-01-02 15:04:05")
if err := s.notifier.SendToChannel(id, body); err != nil {
writeErr(w, http.StatusInternalServerError, "发送失败: "+err.Error())
@@ -16,4 +16,4 @@ CODE-789012
`).filter(i=>i.trim()).length})," 条"]})]}),j.type==="api"&&e.jsxs("div",{className:"border-t border-gray-100 pt-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求方法"}),e.jsxs("select",{value:j.api_method,onChange:i=>G({...j,api_method:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl",children:[e.jsx("option",{value:"GET",children:"GET"}),e.jsx("option",{value:"POST",children:"POST"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"超时时间(秒)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:j.api_timeout,onChange:i=>G({...j,api_timeout:parseInt(i.target.value)||10}),className:"w-full ios-input px-4 py-3 rounded-xl"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求头(JSON)"}),e.jsx("textarea",{value:j.api_headers,onChange:i=>G({...j,api_headers:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"Authorization":"Bearer token"}'})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"请求参数(JSON)"}),e.jsx("textarea",{value:j.api_params,onChange:i=>G({...j,api_params:i.target.value}),className:"w-full ios-input px-4 py-3 rounded-xl h-24 resize-none font-mono text-xs",placeholder:'{"order_id":"{order_id}"}'})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-[1fr_180px] gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"描述"}),e.jsx("input",{value:j.description,onChange:i=>G({...j,description:i.target.value}),placeholder:"卡密用途描述(可选)",className:"w-full ios-input px-4 py-3 rounded-xl"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-bold text-gray-700",children:"延时发货(秒)"}),e.jsx("input",{type:"number",value:j.delay_seconds,onChange:i=>G({...j,delay_seconds:parseInt(i.target.value)||0}),className:"w-full ios-input px-4 py-3 rounded-xl",min:"0",max:"3600"})]})]})]})}),e.jsx("div",{className:"modal-footer",children:e.jsxs("div",{className:"flex gap-3 w-full",children:[e.jsx("button",{onClick:()=>f(!1),className:"flex-1 px-6 py-3 rounded-xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"取消"}),e.jsxs("button",{onClick:m,className:"flex-1 ios-btn-primary px-6 py-3 rounded-xl font-bold flex items-center justify-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4"}),"添加卡密"]})]})})]})}),document.body),Y&&Se.createPortal(e.jsx("div",{className:"modal-overlay",children:e.jsxs("div",{className:"modal-container",style:{maxWidth:"40rem"},children:[e.jsxs("div",{className:"px-6 py-5 border-b border-gray-100 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xl font-extrabold text-gray-900",children:"批量导入卡密"}),e.jsx("button",{onClick:()=>X(!1),className:"w-10 h-10 rounded-2xl bg-gray-100 hover:bg-gray-200 flex items-center justify-center",children:e.jsx(we,{className:"w-5 h-5 text-gray-600"})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-100/50 rounded-2xl",children:[e.jsxs("button",{onClick:()=>C("create"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${de==="create"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(fa,{className:"w-4 h-4"}),"批量创建卡密组"]}),e.jsxs("button",{onClick:()=>C("append"),className:`flex-1 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all ${de==="append"?"bg-[#0094f7] text-white shadow-md":"bg-white text-gray-600 hover:bg-gray-50"}`,children:[e.jsx(js,{className:"w-4 h-4"}),"往单个组充卡密"]})]}),de==="create"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl bg-blue-50 border border-blue-100 p-4 text-xs text-blue-900 leading-5",children:["上传表格,每行一个卡密组。表头:",e.jsx("code",{className:"bg-blue-100/70 px-1.5 py-0.5 rounded",children:"名称,类型,内容,描述,启用,延迟秒,多规格,规格名,规格值"}),'。 类型填 text/data/image;data 类型的"内容"按行存卡密(CSV 单元格内换行需用引号包裹)。']}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:se,className:"px-4 py-2.5 bg-gray-100 hover:bg-gray-200 rounded-xl font-bold text-gray-700 flex items-center gap-2 text- Line truncated
VIP-002
VIP-003`,className:"w-full ios-input px-4 py-3 rounded-xl text-sm font-mono h-40 resize-y"}),e.jsx("p",{className:"text-xs text-gray-500",children:"一行一个卡密号,空行自动忽略。会追加到该组现有库存末尾。"})]}),J&&e.jsxs("div",{className:"rounded-xl bg-green-50 border border-green-200 p-3 text-sm text-green-700 font-bold",children:["已追加 ",J.added," 个卡密"]})]})})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 flex items-center justify-end gap-3",children:[e.jsx("button",{onClick:()=>X(!1),className:"px-5 py-2.5 rounded-xl bg-gray-100 hover:bg-gray-200 font-bold text-gray-700 transition-colors",children:"关闭"}),de==="create"?e.jsxs("button",{onClick:z,disabled:!M||O,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[O?e.jsx(Te,{className:"w-4 h-4 animate-spin"}):e.jsx(js,{className:"w-4 h-4"}),O?"处理中...":"上传创建"]}):e.jsxs("button",{onClick:re,disabled:!D||!$.trim()||O||S.length===0,className:"ios-btn-primary px-6 py-2.5 rounded-xl font-bold flex items-center gap-2 disabled:opacity-50",children:[O?e.jsx(Te,{className:"w-4 h-4 animate-spin"}):e.jsx(Qe,{className:"w-4 h-4"}),O?"处理中...":"追加卡密"]})]})]})}),document.body)]})},gr=s=>s.find(t=>t.status==="running"||t.status==="canceling"),br=s=>{const t=String(s||"").trim();return t?/^[¥¥]/.test(t)?t:`¥${t}`:"-"},fr=({onConfigureDelivery:s})=>{const[t,l]=n.useState([]),[c,h]=n.useState([]),[f,L]=n.useState([]),[F,g]=n.useState(""),[I,j]=n.useState(""),[G,Y]=n.useState(!1),[X,de]=n.useState(!1),[C,M]=n.useState(!1),[oe,ee]=n.useState(!1),[xe,O]=n.useState(!1),[le,D]=n.useState(!1),[N,$]=n.useState(!1),[T,J]=n.useState("upload"),[ue,Q]=n.useState(null),[A,b]=n.useState(null),[v,B]=n.useState(null),[R,K]=n.useState(null),[H,m]=n.useState(null),p=n.useRef(!1),[y,S]=n.useState(null),[U,se]=n.useState({}),[z,re]=n.useState({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""}),[E,i]=n.useState({cookie_id:"",title:"",description:"",price:"",original_price:"",quantity:"1",postage_mode:"free",postage:"",images:[]}),[q,d]=n.useState([]);n.useEffect(()=>{if(!le||E.images.length===0){d([]);return}const r=E.images.map((a,u)=>({key:a.name+u,url:URL.createObjectURL(a)}));return d(r),()=>{r.forEach(a=>URL.revokeObjectURL(a.url))}},[le,E.images]);const _=async()=>{const r=await ps();l(r)},te=async()=>{h(await Is())};n.useEffect(()=>{Promise.all([Rs(),ps(),Is(),yt(20)]).then(([r,a,u,w])=>{L(r),l(a),h(u);const W=w.find(ae=>["running","canceling"].includes(ae.status))||w.find(ae=>ae.status!=="preview");m(W||null)}).catch(r=>console.error("加载商品配置失败:",r))},[]),n.useEffect(()=>{if(!N||!(R!=null&&R.id)||!["running","canceling"].includes(R.status))return;const r=window.setInterval(async()=>{if(!p.current){p.current=!0;try{const a=await os(R.id);K(a),m(a),["running","canceling"].includes(a.status)||(J("done"),await _(),await te())}catch(a){console.error("刷新批量铺货进度失败:",a)}finally{p.current=!1}}},3e3);return()=>{window.clearInterval(r)}},[N,R==null?void 0:R.id,R==null?void 0:R.status]);const Z=async()=>{if(!F)return alert("请先选择账号");Y(!0);try{const r=await _l(F);await _(),alert((r==null?void 0:r.message)||"商品同步完成")}catch(r){console.error("同步商品失败:",r),alert((r==null?void 0:r.message)||"同步失败,请重试")}finally{Y(!1)}},pe=r=>{S(r),se({...r}),ee(!0)},Ne=async()=>{if(y)try{await Rl(y.cookie_id,y.item_id,{item_title:U.item_title||"",item_description:U.item_description||"",item_category:U.item_category||"",item_price:U.item_price||"",item_detail:U.item_detail||y.item_detail||""}),await _(),await te(),ee(!1),S(null)}catch(r){console.error("更新商品失败:",r),alert("更新失败,请重试")}},ce=async r=>{if(confirm(`确认删除商品"${r.item_title}"吗?`))try{await wl(r.cookie_id,r.item_id),l(a=>a.filter(u=>!(u.cookie_id===r.cookie_id&&u.item_id===r.item_id)))}catch(a){console.error("删除商品失败:",a),alert("删除失败,请重试")}},_e=async()=>{try{if(!z.cookie_id||!z.item_id){alert("请选择账号并填写商品ID");return}await kl(z.cookie_id,{item_id:z.item_id,item_title:z.item_title,item_price:z.item_price,item_detail:z.item_image?JSON.stringify({item_image:z.item_image}):""}),await _(),O(!1),re({cookie_id:"",item_id:"",item_title:"",item_price:"",item_image:""})}catch(r){console.error("添加商品失败:",r),alert("添加失败,请重试")}},Re=async()=>{if(!E.cookie_id)return alert("请选择发布账号");if(!E.title.trim())return alert("请填写商品标题");if(!E.price.trim())return alert("请填写商品价格");if(!E.quantity||Number(E.quantity)<=0)return alert("库存数量必须大于 0");if(E.images.length===0)return alert("至少上传 1 张商品图片");if(E.postage_mode==="fixed"&&!E.postage.trim())return alert("请填写一口价邮费");de(!0);try{const r=await Cl(E);if(await _(),D(!1),i({cookie_id:F||"",title:" Line truncated
`),w=new Blob(["\uFEFF"+u],{type:"text/csv;charset=utf-8"}),W=URL.createObjectURL(w),ae=document.createElement("a");ae.href=W,ae.download="批量铺货模板.csv",document.body.appendChild(ae),ae.click(),ae.remove(),URL.revokeObjectURL(W)},ss=()=>{re(r=>({...r,cookie_id:F||r.cookie_id})),O(!0)},Ze=()=>{i(r=>({...r,cookie_id:F||r.cookie_id})),D(!0)},Xe=r=>c.filter(a=>a.cookie_id===r.cookie_id&&a.item_id===r.item_id).length>0?c.filter(a=>a.cookie_id===r.cookie_id&&a.item_id===r.item_id):c.filter(a=>a.cookie_id===r.cookie_id&&!a.item_id),He=r=>{switch(r){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return r||"-"}},x=r=>{switch(r){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},P=n.useMemo(()=>new Map(f.map(r=>[r.id,r])),[f]),me=n.useMemo(()=>I?t.filter(r=>r.cookie_id===I):t,[I,t]),fe=r=>{const a=P.get(r),u=(a==null?void 0:a.remark)||(a==null?void 0:a.nickname);return u?`${u} · ${r.slice(0,6)}`:`账号 ${r.slice(0,8)}`},ze=r=>{const a=P.get(r);return(a==null?void 0:a.remark)||(a==null?void 0:a.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Na,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:I,onChange:r=>j(r.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),f.map(r=>e.jsx("option",{value:r.id,children:fe(r.id)},r.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ns,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:F,onChange:r=>g(r.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),f.map(r=>e.jsx("option",{value:r.id,children:fe(r.id)},r.id))]})]})]}),e.jsxs("button",{onClick:Z,disabled:G||!F,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(qe,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ss,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(Qe,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ze,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Ts,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void ye(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(_s,{className:"w-4 h-4"}),H&&["running","canceling"].includes(H.status)?"继续批量任务":"批量铺货"]}),H&&!["running","canceling"].includes(H.status)&&e.jsx("button",{onClick:()=>void Ae(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[me.map(r=>{const a=Xe(r),u=a.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex- Line truncated
`),w=new Blob(["\uFEFF"+u],{type:"text/csv;charset=utf-8"}),W=URL.createObjectURL(w),ae=document.createElement("a");ae.href=W,ae.download="批量铺货模板.csv",document.body.appendChild(ae),ae.click(),ae.remove(),URL.revokeObjectURL(W)},ss=()=>{re(r=>({...r,cookie_id:F||r.cookie_id})),O(!0)},Ze=()=>{i(r=>({...r,cookie_id:F||r.cookie_id})),D(!0)},Xe=r=>c.filter(a=>a.cookie_id===r.cookie_id&&a.item_id===r.item_id).length>0?c.filter(a=>a.cookie_id===r.cookie_id&&a.item_id===r.item_id):c.filter(a=>a.cookie_id===r.cookie_id&&!a.item_id),He=r=>{switch(r){case"preview":return"待确认";case"pending":return"等待中";case"running":return"发布中";case"canceling":return"正在安全取消";case"success":return"成功";case"failed":return"失败";case"completed":return"已完成";case"partially_failed":return"部分失败";case"canceled":return"已取消";default:return r||"-"}},x=r=>{switch(r){case"success":case"completed":return"bg-emerald-50 text-emerald-700 border-emerald-100";case"partially_failed":case"failed":return"bg-red-50 text-red-700 border-red-100";case"running":return"bg-blue-50 text-blue-700 border-blue-100";case"canceled":return"bg-gray-100 text-gray-600 border-gray-200";default:return"bg-amber-50 text-amber-700 border-amber-100"}},P=n.useMemo(()=>new Map(f.map(r=>[r.id,r])),[f]),me=n.useMemo(()=>I?t.filter(r=>r.cookie_id===I):t,[I,t]),fe=r=>{const a=P.get(r),u=(a==null?void 0:a.remark)||(a==null?void 0:a.nickname);return u?`${u} · ${r.slice(0,6)}`:`账号 ${r.slice(0,8)}`},ze=r=>{const a=P.get(r);return(a==null?void 0:a.remark)||(a==null?void 0:a.nickname)||"未命名账号"};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col xl:flex-row xl:justify-between xl:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"商品管理"}),e.jsx("p",{className:"text-gray-500 mt-2 text-sm",children:"监控并管理所有账号下的闲鱼商品。"})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-account-filter",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"商品列表筛选"}),e.jsxs("div",{className:"relative",children:[e.jsx(Na,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-account-filter","aria-label":"按账号筛选商品列表",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:I,onChange:r=>j(r.target.value),children:[e.jsx("option",{value:"",children:"全部账号"}),f.map(r=>e.jsx("option",{value:r.id,children:fe(r.id)},r.id))]})]})]}),e.jsxs("div",{className:"flex min-w-[200px] flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"item-sync-account",className:"px-1 text-[11px] font-extrabold tracking-wide text-gray-500",children:"同步商品账号"}),e.jsxs("div",{className:"relative",children:[e.jsx(ns,{className:"w-4 h-4 absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{id:"item-sync-account","aria-label":"选择要同步商品的账号",className:"ios-input w-full pl-10 pr-9 py-3 rounded-xl text-sm",value:F,onChange:r=>g(r.target.value),children:[e.jsx("option",{value:"",children:"请选择账号"}),f.map(r=>e.jsx("option",{value:r.id,children:fe(r.id)},r.id))]})]})]}),e.jsxs("button",{onClick:Z,disabled:G||!F,className:"ios-btn-primary flex items-center gap-2 px-6 py-3 rounded-2xl font-bold shadow-lg shadow-blue-200 disabled:opacity-50",children:[e.jsx(qe,{className:`w-4 h-4 ${G?"animate-spin":""}`}),"同步商品"]}),e.jsxs("button",{onClick:ss,className:"px-5 py-3 rounded-2xl font-bold bg-gray-900 text-white hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-lg",children:[e.jsx(Qe,{className:"w-4 h-4"}),"添加商品"]}),e.jsxs("button",{onClick:Ze,className:"px-5 py-3 rounded-2xl font-bold bg-emerald-600 text-white hover:bg-emerald-700 transition-colors flex items-center gap-2 shadow-lg shadow-emerald-100",children:[e.jsx(Ts,{className:"w-4 h-4"}),"发布商品"]}),e.jsxs("button",{onClick:()=>void ye(),className:"px-5 py-3 rounded-2xl font-bold bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-2 shadow-lg shadow-blue-100",children:[e.jsx(_s,{className:"w-4 h-4"}),H&&["running","canceling"].includes(H.status)?"继续批量任务":"批量铺货"]}),H&&!["running","canceling"].includes(H.status)&&e.jsx("button",{onClick:()=>void Ae(),className:"px-4 py-3 rounded-2xl font-bold bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors",children:"最近批次结果"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:[me.map(r=>{const a=Xe(r),u=a.length>0;return e.jsxs("div",{className:"ios-card p-3 rounded-2xl hover:shadow-lg transition-all group relative flex flex- Line truncated
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ydisks闲鱼助手 - 自动发货与管家系统</title>
<meta name="description" content="Ydisks闲鱼助手 - 自动回复、自动发货、订单管理、AI智能议价一体化解决方案" />
<script type="module" crossorigin src="/static/assets/index-DWScSBc3.js"></script>
<script type="module" crossorigin src="/static/assets/index-ZWBpSY5a.js"></script>
<link rel="modulepreload" crossorigin href="/static/assets/react-vendor-DZnRGM0-.js">
<link rel="modulepreload" crossorigin href="/static/assets/icons-vendor-RenKjhri.js">
<link rel="modulepreload" crossorigin href="/static/assets/vendor-w5t2K9ux.js">