Commit Graph

45 Commits

Author SHA1 Message Date
TradeMate Dev f17a6ccbac chore: post-deployment cleanup and docs update
- Make AI routing rules DB-driven (read from system_configs, removed from config.py)
- Add translation quota tracking to LLM translation (OpenAIProvider)
- Add Alibaba MT ECS RAM role support (STS token, no AccessKey needed)
- Fix admin sidebar link for AI模型配置 page
- Fix Quota.vue API path (quotas → translation-quotas)
- Fix login auto-redirect to dashboard
- Add provider dropdown selects to AI routing config UI
- Clean up stale ai_provider_* system_configs records
- Remove OpencodeGo, Spark providers (code + DB)
- Update deploy config: nginx port 8000, systemd cwd
2026-06-02 15:40:02 +08:00
TradeMate Dev fa3050a17c fix: remove CSRF requirement from login/register endpoints
Anonymous users have no CSRF cookie, so require_csrf_token always
raises 403 on first visit. This broke all first-time logins and
registrations. CSRF protection is unnecessary here since there's
no authenticated session to forge requests against.
2026-05-30 21:39:02 +08:00
TradeMate Dev 4122571f86 fix: friendly Chinese error messages on login/register pages
Map backend English error details to user-facing Chinese text on all
3 frontends (uni-app, user-frontend, admin-frontend). Previously raw
English like 'Invalid credentials' was shown directly to users.
2026-05-30 09:06:01 +08:00
TradeMate Dev 3e39cf0170 refactor: replace direct WeChat/Alipay with unified pay-api gateway
Switch from direct WeChat Pay / Alipay integrations to the unified
宇之然 pay-api gateway (HMAC-SHA256 auth). Removes wechat_pay.py,
keeps PaymentGateway abstraction, adds UnifiedPayService. Simplifies
payment.py create_order to {plan, pay_type} params. Single webhook
endpoint replaces separate WeChat/Alipay notify handlers.
2026-05-29 18:36:50 +08:00
TradeMate Dev 5d2bced39f docs: update project docs and clean up redundant files
- PROGRESS.md: update to 2026-05-29 with security hardening (T-005),
  4-frontend architecture, AI provider refactoring, discovery features,
  landing page/referral/quota, desktop layout, admin AI management
- AGENTS.md: add AI provider list (Alibaba/NVIDIA, removed Claude/DeepL/Local),
  DB-driven config, CSRF/rate-limit/CORS notes, admin_ai reload quirk
- .env.example: sync with actual config, replace deprecated providers
  with current Sensenova/OpencodeGo/NVIDIA/Spark/Alibaba
- docs/PROJECT_STATUS.md: archive (fully superseded by PROGRESS.md)
- Remove generated JS files (_bing_search.js, _batch_search.js)
- Remove empty directories (data/corpus, data/models)
- Remove backend/.coverage (test artifact)
- Fix services/.gitignore to cover _bing_search.js
- Include pending AI provider DB admin feature (admin_ai, AIProvider model,
  AIProviders.vue, migration) and T-008 test report
2026-05-29 11:15:33 +08:00
TradeMate Dev c04fa2c19f T-005: Security hardening - CORS, Rate Limit, CSRF
- CORS: Restrict allowed origins to specific frontend URLs, limit methods and headers
- Rate Limit: Add fine-grained endpoint-specific rate limits for sensitive operations
  - Login: 5 requests/minute
  - Register: 3 requests/hour
  - Password change: 3 requests/5 minutes
  - Payment: 20 requests/minute
  - Admin: 30 requests/minute
- CSRF: Add CSRF protection middleware with double-submit cookie pattern
  - New app/core/csrf.py module with CSRFMiddleware
  - Require CSRF tokens on sensitive endpoints (auth, payment, profile)
  - Skip webhook endpoints for CSRF validation
- Fix pydantic-settings import in config.py
2026-05-29 10:26:23 +08:00
TradeMate Dev 7c9885f704 fix(T-002): remove sensitive info from logs
- alibaba.py: remove translated text content from log, only log char count
- nvidia.py: remove messages content reference from timing log
- push.py: replace full content with length, sanitize WeChat error response
2026-05-29 08:29:06 +08:00
TradeMate Dev bc48c220a0 Add user-friendly loading feedback for all AI/long-running operations
- Discovery: show '搜索中约需30-60秒' message, auto-save to history, timeout hint
- Discovery extract/outreach: show '正在分析网站/生成文案' loading message
- Translate: inline '翻译中...' placeholder while waiting
- Marketing: inline 'AI 生成中...' placeholder, success feedback
- Quotations AI: inline progress text + ElMessage.info during generation
- Analytics: add v-loading skeleton with '加载数据分析中...'
- Notifications: add v-loading skeleton with '加载通知中...'
- Followup: wire up '扫描跟进提醒' button with AI progress indicator
2026-05-27 16:22:07 +08:00
TradeMate Dev c1638db6b2 Add discovery search history with auto-save, fix timeout causing search failure
- Save every search result to DB for later review
- Add '搜索历史' tab with timeline view, load/delete records
- Raise discovery search timeout from 30s to 120s (Bing Puppeteer needs ~40s)
- Reduce search queries from 4 to 3 for faster response
- New model: DiscoveryRecord (user_id, product, market, companies JSON)
- API: POST/GET/DELETE /api/v1/discovery/records
- Migration: discovery_records table
2026-05-27 15:54:50 +08:00
TradeMate Dev 6f0d8b0fb4 Add contact extraction for discovery results: click to scrape email/phone/WhatsApp/WeChat from company website 2026-05-27 11:24:03 +08:00
TradeMate Dev ab06990e73 Fix API errors and improve customer discovery with real web results
- Fix usage/stats 500: use Date() not datetime.date() for SQL cast
- Fix customers 422: raise size limit to 1000
- Replace unreliable MCP client with direct Bing batch search for discovery
- Batch all search queries in one browser session (faster)
- Show real company names/URLs from Bing, not generic templates
- Smart filter for non-business results (news, blogs, forums)
- Fallback suggestions when search results are insufficient
- Frontend: clickable contact URLs, provider indicator, better layout
2026-05-27 10:29:23 +08:00
TradeMate Dev bed5c7abef Add landing page, referral system, usage quotas, search API management, and yearly pricing
- Separate workspace landing from login for better UX
- Referral system rewards both parties with Pro days
- Quota enforcement prevents abuse without breaking endpoints
- 7-day free trial with auto-downgrade on expiry
- Admin-managed search provider config (SearXNG, Bing)
- 15% discount on annual subscriptions
- MCP search server wrapping opencode search
- Fix discovery module field name mismatch causing 422
2026-05-26 11:40:13 +08:00
TradeMate Dev 52dba37f22 Add admin-frontend and user-frontend standalone projects, certification/invoice/discovery features, fix auth header and theme consistency 2026-05-22 18:35:30 +08:00
TradeMate Dev 18c6cf5406 Move sidebar nav entirely into App.vue (eliminate component boundary)
Previous attempts used a separate NavBar component (nav-bar.vue).
Even with styles in App.vue's global scope, the component wrapper
created an abstraction layer that prevented the nav from rendering.

Now the nav markup, logic, and styles are all in App.vue directly:
- <div class="app-nav"> renders inline in App.vue template
- .app-nav{display:none} on mobile, display:flex on desktop (>=1024px)
- No component boundary, no data-v-xxxxx scoping issues
- Deleted components/nav-bar.vue
2026-05-21 10:21:49 +08:00
TradeMate Dev d14c98e93c Fix NavBar sidebar not showing: move all nav CSS to App.vue global styles
Root cause: nav-bar.vue styles compiled with [data-v-xxxxx] attribute
selectors by uni-app Vite plugin, but Vue didn't add the attribute to
DOM elements (styles were not scoped). The CSS selector mismatch meant
no sidebar styles ever applied.

Fix:
- Remove all CSS from nav-bar.vue (<style> block deleted entirely)
- Move ALL nav-bar styles to App.vue's global <style>
- Use .app-wrapper > .nav-bar selector (no data-v issues)
- Mobile: display:none; Desktop (>=1024px): display:flex sidebar
- Also fixed: nav-bar was accidentally visible as block on mobile
2026-05-21 10:16:40 +08:00
TradeMate Dev b71b7e6cdf Fix desktop responsive layout: sidebar, content sizing, remove duplicate tab bar
- Replace uni-app custom-tab-bar with manual NavBar component in App.vue
  (uni-app auto-detection was not including component in build)
- Mobile: NavBar hidden via CSS display:none, uni-app default tab bar handles nav
- Desktop: NavBar visible as 220px left sidebar, uni-app tab bar hidden
- Content area: max-width 1200px with margin-left:220px, centered
- Buttons/inputs/cards: global desktop CSS overrides for reasonable sizing
- Clean approach: NavBar always in DOM, CSS media queries control visibility
  (no v-if, no conflicting !important)
2026-05-21 10:10:11 +08:00
TradeMate Dev a2a7cb893b Add responsive desktop layout with left sidebar navigation
Desktop (≥1024px):
- Tab bar becomes a 220px left sidebar with brand name and nav items
- Page content shifts right and max-width constrained to 1200px
- Base font-size reset to 16px for readable text
- AI assistant floating button stays in bottom-right corner
- No change to mobile layout (bottom tab bar preserved)
2026-05-21 09:53:30 +08:00
TradeMate Dev ef01f0dc01 Update AGENTS.md with deployment structure and vite base config note 2026-05-21 09:38:57 +08:00
TradeMate Dev 18112d5d0c Set vite base to /app/ to support landing-page + app subdirectory site structure
The marketing landing page is served at root (/), and the uni-app SPA
is served at /app/. Setting base: '/app/' ensures all static asset
references (CSS, JS, favicon) are correctly prefixed for the new
subdirectory deployment.
2026-05-21 09:38:39 +08:00
TradeMate Dev c397740748 feat: WeChat Pay integration, translation quota management, login UX fixes
- WeChat Pay APIv3 integration (JSAPI + Native) with cert-based auth
- TranslationQuota model + admin management UI (配额 tab)
- Alibaba MT provider now checks quota before translation
- Fix: admin tabs scrollable on mobile, remove header-card
- Fix: profile/login navigation - logout stays on profile, login returns to profile
- Fix: login form now visible by default (no extra click to show)
- Fix: home page translate link uses navigateTo (was switchTab to non-tabBar page)
- Add .coverage and apiclient_key.pem to gitignore
2026-05-20 18:30:12 +08:00
TradeMate Dev a60aac4638 Unify frontend config, fix marketing tracking field mismatch, expose customer notes in API
Centralizes all hardcoded page paths, storage keys, external URLs, and branding into a single uni-app/src/config.js. Fixes trackMarketingEffect sending wrong field names (action/content_preview -> event_type/content) that silently dropped tracking data. Adds notes, estimated_value, next_followup_at to Customer response. Removes '翻译' from bottom tab nav (5 tabs now), adds quick translate card on home page. Makes profile page header color consistent with app theme (#1890ff).
2026-05-20 14:30:50 +08:00
TradeMate Dev f8a23855d2 feat: AI assistant phase 2 - configurable prompt, action operations, FAQ matching, NVIDIA provider
- Admin-configurable AI prompt/quick questions from system_configs DB
- GET /api/v1/ai/quick-questions endpoint for fetching quick questions
- Local FAQ matching for instant responses (avoid AI calls for common Qs)
- AI action extraction: "add customer" intent detected, structured data returned
- Frontend action confirmation card with editable fields, calls customer API on confirm
- NVIDIA provider (stepfun-ai/step-3.5-flash) for faster chat vs deepseek-v4-flash
- Fixed httpx client timeout preventing backend hangs
- Added log_usage calls for auth events (register/login/guest/wechat)
- Admin tabs (users/stats/logs/config) fully functional with real backend
- AiAssistant component added to all tabbar pages
2026-05-20 09:39:22 +08:00
TradeMate Dev 4755cc75ba feat: 管理后台完整可用 + 注册登录记日志 + 提取信息结构化展示 + 微信配置就绪
- 管理后台用户/统计/日志/配置四页签全部对接真实后端API
- auth注册/登录/游客/微信登录事件写入usage_logs表
- 提取信息结果从原始JSON改为卡片式字段列表(中文标签)
- 管理后台搜索按钮增加加载态和结果数提示
- 配置WECHAT_APP_ID/WECHAT_APP_SECRET
- 客户/产品/报价单CRUD页面完整(导出导入批量操作)
2026-05-18 23:50:48 +08:00
TradeMate Dev 32d2b57df7 feat: 营销页面结果旁显示中文翻译 + 朗读按钮 2026-05-17 16:52:27 +08:00
TradeMate Dev 1fabad0fe9 fix: 首页TTS同样改用blob播放,解决downloadFile导致页面刷新的问题 2026-05-17 14:18:29 +08:00
TradeMate Dev 7b7f90d57a fix: TTS朗读失败且刷新内容 — 安装edge-tts,前端改用blob播放代替downloadFile 2026-05-17 14:10:45 +08:00
TradeMate Dev f33d33f980 feat: integrate WhatsApp send into customer detail with AI reply generation 2026-05-17 09:52:26 +08:00
TradeMate Dev 74a971cd6e doc: add AGENTS.md with architecture, commands, and quirks for agent onboarding 2026-05-16 08:18:07 +08:00
TradeMate Dev 8a3acbd4ee fix: dynamic loading status during AI gen; navigator.clipboard copy; competitor analysis fallback 2026-05-15 22:38:49 +08:00
TradeMate Dev 98e2542c52 feat: add OpencodeGo AI provider (deepseek-v4-flash) as primary, existing providers as fallback 2026-05-15 19:59:25 +08:00
TradeMate Dev ac51716097 fix: route ordering customer/{id}/health before /{id}; CustomerHealthService for health-overview; keywords/competitor Header decorator; onboarding product_info dict; marketing template fallback; frontend style-switching tabs 2026-05-15 09:17:26 +08:00
TradeMate Dev 566f59f0e4 fix: onboarding passes product_info dict; marketing service template fallback when no AI; frontend style-switching tabs 2026-05-14 19:23:45 +08:00
TradeMate Dev 93f6ad306a fix: change login endpoint from OAuth2PasswordRequestForm to accept JSON body 2026-05-14 17:03:24 +08:00
TradeMate Dev cc1766ef7d fix: add migration for missing users.email, last_login_at, login_count columns 2026-05-14 16:54:17 +08:00
TradeMate Dev 6d0fdc3e30 docs: add production deployment guide with baota panel compatibility 2026-05-14 10:50:20 +08:00
TradeMate Dev 3b181eeae3 fix: skip API calls on customers page when user is guest/unauthenticated 2026-05-14 10:40:16 +08:00
TradeMate Dev aacb53f111 fix: move health-overview and health-scores routes before /{customer_id} to prevent UUID matching error 2026-05-14 10:34:03 +08:00
TradeMate Dev 4460131b71 fix: make alembic use env var DATABASE_URL instead of hardcoded dev db 2026-05-14 10:24:50 +08:00
TradeMate Dev 5a1af9f82f feat: production branch with deploy config for baota panel
- Add deploy/ directory with production env, supervisor, nginx, migration configs
- Include all latest features: admin management, feedback, footer with ICP/beian
- Database: foreign_trade (PostgreSQL), user: foreign_trade
- Frontend: trade.yuzhiran.com, backend proxy via Nginx
2026-05-14 09:19:30 +08:00
TradeMate Dev 23a31f7c00 feat: silent wechat login, marketing tab optimization, admin page foundation
- Add silent WeChat login for MP/browser environments
- Fix Python 3.6 compatibility (remove typing.Annotated usage)
- Marketing page: tab-based content generation with category support
- Translate page: add auto-detect language default
- Homepage: add TTS playback, announcement ticker, remove redundant quick-actions
- Fix FAB button overlap with custom tabbar on customers/quotation pages
- Make openai/anthropic imports lazy for Python 3.6 compat
2026-05-14 00:30:48 +08:00
TradeMate Dev f70dd24c7d feat: upgrade custom tabbar with emoji support, redesign quick-actions
- Switch back to custom tabbar (custom: true) with emoji fix (line-height, font-family)
- Redesign home quick-actions: product/followup/analytics/notifications replace redundant nav items
- Refactor goToPage to auto-detect tabbar vs non-tabbar pages
- Update PROGRESS.md
2026-05-13 18:23:58 +08:00
TradeMate Dev 04f7ff0317 fix: CORS/API 500 issues, switch to native tabbar, restore quick-actions
- Backend: guest UUID format fix, /auth/me guest branch, UUID validation in deps.py, CORS config fix
- Frontend: switch to native tabbar (custom: false), cleanup App.vue, redesign quick-actions with colored icons, conditional wechat login, proxy API requests via Vite
2026-05-13 17:54:13 +08:00
TradeMate Dev 7b62c2f8b4 feat: 修复 H5 底部导航覆盖 + 更新项目进度文档
## H5 底部导航修复 (Bug #10)
- 精简 App.vue,移除重复 tabbar,仅保留全局样式
- uni-page 设置 height: calc(100% - 50px) + overflow-y: auto
- 内容区域精确停在底部导航上方,独立滚动不再叠加
- 恢复 custom-tab-bar 组件

## 项目进度文档
- PROGRESS.md 更新至 10 个 Bug 修复
- 新增 H5 底部导航修复记录
- 新增历史变更条目
2026-05-12 20:24:42 +08:00
TradeMate Dev 69e164dcae chore: remove native miniprogram (use uni-app instead) 2026-05-08 18:21:13 +08:00
TradeMate Dev c6206787da Initial commit: TradeMate 外贸小助手 MVP
项目结构:
- backend/     Python FastAPI 后端
- uni-app/     uni-app跨端前端
- docs/        设计文档
- docker-compose.yml  Docker编排
- nginx/scripts/systemd 运维配置

已完成功能:
- 用户认证 (JWT)
- 智能翻译 + 回复建议
- 营销素材生成
- 客户管理 + 沉默检测
- 报价单管理
- 产品库管理
- 汇率换算
- 推送通知 (uni-push)
- WhatsApp Webhook框架
- Celery定时任务
2026-05-08 18:17:12 +08:00