refactor(api)!: 平台 id 改两字母短码——qian→bd、joox→jx、5sing→5s、bili→bl
对外 id 统一为两字母短码,与既有的 kw/kg/tx/wy/qs/xm/me/qt/lr 对齐; migu 与 apple 保持原样(Apple Music 没有自然的短码)。 **破坏性变更**:id 出现在所有 URL、/sources 返回、OpenAPI 示例以及 data/auth.json 的凭据键里,这四个平台已存的登录态会失效,需重新登录。 - sdk/index.ts:id 与 supportQuality 映射键 - sdk/types.ts:Source 联合类型 - src/routes.ts 与 routes-login.ts:路由路径与 schema 描述 (/login/bili/qr → /login/bl/qr 等)、/login/status 的响应键 - test/smoke-test.ts、README.md、docs/API.md 同步 有意未改:sdk 目录与文件名仍用平台名(sdk/qian/、sdk/apis/joox.ts …), 规则定为「目录=平台名,id=对外短码」,映射只在 SUPPORTED_SOURCES 一处声明。 域名与正则(joox.com、5sing.kugou.com、/joox\.com\//)、jooxSign 等标识符、 错误文案里的中文平台名、以及 kg 榜单名(含「joox本地热歌榜」)全部保持原样—— 它们只是恰好含平台名,并不是 id。 验证:typecheck ✓、pnpm test 112/112 ✓;另起临时实例实证 /sources 与 /login/status 的新 id 与展示名,新旧 id 均无残留。
This commit is contained in:
1 parent
14f7295fd4
commit
3381e9b906
33 files changed
+155
-155
No files matched your search
+3
-3
@@ -5,7 +5,7 @@
|
||||
// 0 成功 / 86038 过期 / 86090 已扫码待确认 / 86101 未扫码
|
||||
// 成功时登录态 Cookie 在 poll 响应的 Set-Cookie 与 data.url 的 crossDomain 查询串里(两处都收集)。
|
||||
// 凭据落盘到 sdk/auth/store.ts 的 `bili` 记录(cookie / refreshToken / 账号资料),与 kg/wy 一致;
|
||||
// 上游 New(cookie) 的实例化语义由 getCredentials('bili') 承担(见 util.ts getCookie)。
|
||||
// 上游 New(cookie) 的实例化语义由 getCredentials('bl') 承担(见 util.ts getCookie)。
|
||||
// 状态码沿用本仓库约定:800 过期 / 801 等待扫码 / 802 已扫码待确认 / 803 登录成功。
|
||||
import QRCode from 'qrcode'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
@@ -125,7 +125,7 @@ export const checkQRLogin = async(key: string) => {
|
||||
const cookie = cookieString(jar)
|
||||
if (!cookie) throw new Error('B站登录成功但未获取到 Cookie,请重试')
|
||||
const profile = await fetchProfile(cookie)
|
||||
setCredentials('bili', {
|
||||
setCredentials('bl', {
|
||||
cookie,
|
||||
refreshToken: String(data.refresh_token || ''),
|
||||
mid: profile.mid,
|
||||
@@ -148,7 +148,7 @@ export const checkQRLogin = async(key: string) => {
|
||||
|
||||
/** 当前登录态(凭据存在性 + 落盘时保存的账号资料) */
|
||||
export const status = () => {
|
||||
const cred = getCredentials('bili') as any
|
||||
const cred = getCredentials('bl') as any
|
||||
return cred?.cookie
|
||||
? {
|
||||
logged: true,
|
||||
|
||||
Reference in new issue
Block a user