优化: Docker 环境下的下载性能和网络稳定性
- Chromium 启动参数优化:禁用 dev-shm 和 GPU 加速,防止Docker内存不足 - 增加所有超时时间:login/navigate/export 超时 30s,下载超时 300s - 改进网络延迟处理:增加数据加载等待时间,添加网络加载检测 - Docker Compose 资源配置:限制 2 CPU / 2GB 内存,DNS 配置国际公共 DNS - Dockerfile 优化:添加 PYTHONHASHSEED 环境变量,跳过浏览器下载校验 - 新增 docker-debug.sh 脚本:便捷测试 Docker 容器中的下载功能 - 新增 .dockerignore:加速 Docker 构建,减少镜像大小 Docker 下载现在支持更长的网络延迟和更大的数据量
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
SalesShow is a monolithic Flask web application for analyzing sales data from Excel files. It supports manual Excel uploads and automated daily downloads from secsion.com via Playwright browser automation. There is no database — all data lives as Excel files on disk in `uploads/`.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Run development server (Flask on port 5000, debug via FLASK_DEBUG env var)
|
||||
python app.py
|
||||
|
||||
# Run with Docker (builds image, installs Playwright Chromium, port 5000)
|
||||
docker-compose up -d
|
||||
|
||||
# Production
|
||||
gunicorn -w 4 -b 0.0.0.0:8000 app:app
|
||||
|
||||
# CLI automation — download reports from secsion.com
|
||||
python -m automation.secsion --start 2026-04-28 --end 2026-04-28
|
||||
```
|
||||
|
||||
No test framework or linter is configured in this project.
|
||||
|
||||
## Architecture
|
||||
|
||||
**Backend (Flask, single `app.py`):**
|
||||
- Routes handle file upload (`/upload`), file listing (`/files`), data loading/processing (`/load/<filename>`), deletion, and cleanup.
|
||||
- `process_sales_data()` (~lines 371-575 in `app.py`) is the core logic. It uses a state-machine approach to handle two Excel formats: "flat tables" (each row has code + product) and "hierarchical tables" (code row is a header, product rows are children). Outputs daily summaries with per-product breakdowns.
|
||||
- `find_header_row()` dynamically detects the header row by scanning first 20 rows for keyword matches.
|
||||
|
||||
**Automation module (`automation/`):**
|
||||
- `secsion.py` — `SecsionDownloader` uses Playwright headless Chromium to log into secsion.com, navigate to reports, set date range via TDesign date picker, optionally inject `shop_id` via route interception, and download exports.
|
||||
- `uploader.py` — copies downloaded files into `uploads/` with timestamp-prefix naming (same convention as manual uploads).
|
||||
- `scheduler.py` — APScheduler `BackgroundScheduler` with `CronTrigger` runs daily auto-download (default 01:00).
|
||||
|
||||
**Configuration (`config.py`):**
|
||||
- Three-tier priority: Web UI settings (`data/config.json`) > environment variables (`.env` / system env) > defaults.
|
||||
- `Config` class provides static methods for reading/writing secsion credentials, shop ID, and scheduler settings.
|
||||
|
||||
**Frontend (vanilla JS/CSS, no build step):**
|
||||
- `main.js` — all client-side interactivity: file upload (drag-and-drop), AJAX to API, data rendering (card/table view), client-side filtering, sorting, pagination (50 items/page), export.
|
||||
- `style.css` — Glassmorphism design with CSS custom properties.
|
||||
- `settings.html` — self-contained settings page with inline `<script>` (no separate JS file).
|
||||
|
||||
## Key Design Decisions
|
||||
|
||||
- No database — Excel files on disk are the data store.
|
||||
- No frontend build step — vanilla JS/CSS served directly via Flask static files.
|
||||
- Playwright automation runs in daemon threads with a global `download_status` dict for status tracking.
|
||||
- Passwords are masked (`******`) when returned via the API.
|
||||
Reference in New Issue
Block a user