This repository has been archived on 2026-10-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
NeteaseUrl/core/__init__.py
T
snowy-yang c2a8da3e43 refactor(core): 抽出框架无关核心层 core/,为 FastAPI 迁移铺路
第一步模块拆分(纯搬运,零行为变化):
- 新增 core/ 包:config(常量/配置) + state(运行时状态) + utils(纯函数) + security(音频签名)
- main.py 改为从 core 导入并以原下划线名再导出,250+ 既有调用点零改动

关键设计:
- 状态全部原地修改,import 即共享同一对象(21 项身份断言 + 10 项冒烟全绿)
- 音频签名密钥由启动时 _init_audio_secret(app.secret_key) 注入,
  解除 core.security 对 Flask app 的依赖,新老应用可互认 token

验证:py_compile 通过;冒烟 10/10 PASS;对象身份 22/22 PASS;
waitress 真实启动 /health 200 version=2.4.0。main.py 减 229 行。
2026-09-26 00:16:04 +08:00

13 lines
670 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""框架无关的核心层(Flask → FastAPI 迁移期两边共用)。
分层约定:
- core.config —— 常量、配置类、路径(无框架依赖,可被任意层导入)
- core.state —— 进程内运行时状态容器与锁(纯 threading/collections)
- core.utils —— 纯函数工具(字符串/时间/歌词/SRT、短链展开)
- core.security —— 音频直链签名与校验(密钥由启动时注入,不依赖 Flask)
本包**不得**导入 flask / fastapi,也不得持有路由或请求上下文相关知识,
以便同一套状态与工具在迁移期被新老两个应用同时复用。
"""