mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 19:46:38 +08:00
支持按用户保存播放器与弹幕偏好
在 user 记录上新增播放器音量、弹幕开关、透明度、字号、显示区域、合并偏好、自定义弹幕源以及 dandanplay 应用凭据字段,并提供 PUT /danmaku/settings 局部更新接口,带取值校验。 返回脱敏后的完整渲染配置,绝不回传应用密钥,仅在响应中标记密钥是否已配置。 结果缓存键加入用户 ID 与凭据指纹,避免不同用户或凭据串用缓存;旧版实例级设置仅作为未登录与迁移期的回退。
This commit is contained in:
+32
-20
@@ -62,6 +62,33 @@ export type DanmakuFetchOptions = {
|
||||
episodeId?: number | string
|
||||
}
|
||||
|
||||
export interface DanmakuConfig {
|
||||
enabled: boolean
|
||||
source?: string
|
||||
app_id?: string
|
||||
app_key_configured: boolean
|
||||
opacity: string
|
||||
font_size: string
|
||||
area: string
|
||||
volume: number
|
||||
/** Per-user preference: merge the same episode's multiple sources. */
|
||||
merge_sources: boolean
|
||||
}
|
||||
|
||||
export interface DanmakuSettingsPatch {
|
||||
enabled?: boolean
|
||||
source?: string
|
||||
app_id?: string
|
||||
/** 留空不会修改密钥;清空请使用 clear_app_key。 */
|
||||
app_key?: string
|
||||
clear_app_key?: boolean
|
||||
opacity?: number
|
||||
font_size?: number
|
||||
area?: number
|
||||
merge_sources?: boolean
|
||||
volume?: number
|
||||
}
|
||||
|
||||
// danmakuAPI fetches danmaku comments for a media item. The backend resolves
|
||||
// the configured dandanplay source by the video's name (search for episode,
|
||||
// then fetch its comment library) and returns the raw Bilibili-format XML;
|
||||
@@ -75,26 +102,11 @@ export const danmakuAPI = {
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
// config returns the renderer knobs so the player can initialize its
|
||||
// danmaku control panel without admin privileges.
|
||||
// config returns the current user's player volume and danmaku preferences.
|
||||
config: () =>
|
||||
api
|
||||
.get<{
|
||||
enabled: boolean
|
||||
source?: string
|
||||
opacity: string
|
||||
font_size: string
|
||||
area: string
|
||||
/** Per-user preference: merge the same episode's multiple sources. */
|
||||
merge_sources: boolean
|
||||
}>('/danmaku/config')
|
||||
.then((r) => r.data),
|
||||
api.get<DanmakuConfig>('/danmaku/config').then((r) => r.data),
|
||||
|
||||
// updateSettings persists per-user danmaku preferences (survives reload).
|
||||
updateSettings: (settings: { mergeSources: boolean }) =>
|
||||
api
|
||||
.put<{ merge_sources: boolean }>('/danmaku/settings', {
|
||||
merge_sources: settings.mergeSources,
|
||||
})
|
||||
.then((r) => r.data),
|
||||
// updateSettings persists a partial per-user player/danmaku settings patch.
|
||||
updateSettings: (settings: DanmakuSettingsPatch) =>
|
||||
api.put<DanmakuConfig>('/danmaku/settings', settings).then((r) => r.data),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user