Skip to content

Feat:新增定时任务执行与 new-api 服务上传#42

Open
biubushy wants to merge 3 commits intodou-jiang:mainfrom
biubushy:feat/scheduling-new-api-upload
Open

Feat:新增定时任务执行与 new-api 服务上传#42
biubushy wants to merge 3 commits intodou-jiang:mainfrom
biubushy:feat/scheduling-new-api-upload

Conversation

@biubushy
Copy link
Copy Markdown

feat: 支持周期任务调度与 new-api 服务上传


变更摘要

本次改动主要完成两项能力:

  1. 支持周期任务调度
  2. 支持 new-api 服务独立配置与上传

主要内容

一、周期任务调度

  • 新增计划注册任务的数据模型、调度逻辑与状态管理
  • 支持计划任务的创建、更新、启停、立即执行与轮询调度
  • 支持在前端页面查看和管理计划任务
  • 支持单次注册、批量注册、Outlook 批量注册等配置进入统一调度链路
屏幕截图 2026-03-28 202436 屏幕截图 2026-03-28 202455

二、new-api 服务上传

  • 新增独立的 new-api 服务模型、CRUD、后端路由与前端设置组件
  • 支持在设置页新增、编辑、删除、测试 new-api 服务
  • 支持账号页单账号上传、批量上传到 new-api
  • 支持注册成功后自动上传到 new-api
  • 按官方接口方式适配:
    • 管理员登录 POST /api/user/login
    • 携带 New-Api-User
    • 创建 Codex 渠道 POST /api/channel/
屏幕截图 2026-03-28 202536

三、兼容与清理

  • 清理 new-api 对 Sub2API 旧兼容主路径的依赖
  • 保持 CPA、Sub2API、Team Manager 原有主流程不受影响
  • 修复账号页前端 uploadToNewApi is not defined 问题

验证情况

已完成以下验证:

  • new-api 服务测试连接成功
  • new-api 服务保存成功
  • 账号页单账号上传到 new-api 成功
  • 批量上传到 new-api 成功
  • 前端页面已显示 new-api 相关组件
  • 周期任务调度相关能力已接入

测试命令

uv run pytest "./tests/test_new_api_upload.py"
"./tests/test_new_api_services.py"
"./tests/test_registration_new_api.py"
"./tests/test_frontend_new_api_presence.py"

注意

项目启动时会通过 migrate_tables() 自动检查并补充缺失列,因此:

  • 已有数据库一般不需要手工执行 SQL
  • 只需要重启后端,系统会自动补充缺失字段

- Implemented a new scheduling form in the frontend to create and manage scheduled registration tasks.
- Added backend utilities for parsing and validating schedule configurations.
- Created a scheduler service to poll and execute due registration tasks.
- Enhanced the UI with a schedule jobs table to display existing scheduled tasks and their statuses.
- Introduced functions to handle scheduling logic, including interval and timepoint triggers.
- Integrated the scheduling feature with existing registration workflows.
- add standalone new-api service model, CRUD, routes, and frontend settings UI
- implement official new-api login and Codex channel creation flow for upload actions
- remove new-api reliance on Sub2API compatibility paths and wire registration auto-upload
- add unit and integration tests for new-api service management and upload behavior
- verify registration config mapping and frontend new-api entry visibility
- install pytest and httpx to support local API and frontend presence tests
@biubushy biubushy changed the title Feat/scheduling new api upload Feat:新增定时任务执行与 new-api 服务上传 Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant