Files
MeBox/web/src/utils/withoutVideoFrame.test.ts
T
truewhile b7f1cd85f8 支持按用户保存播放器与弹幕偏好
在 user 记录上新增播放器音量、弹幕开关、透明度、字号、显示区域、合并偏好、自定义弹幕源以及 dandanplay 应用凭据字段,并提供 PUT /danmaku/settings 局部更新接口,带取值校验。
返回脱敏后的完整渲染配置,绝不回传应用密钥,仅在响应中标记密钥是否已配置。
结果缓存键加入用户 ID 与凭据指纹,避免不同用户或凭据串用缓存;旧版实例级设置仅作为未登录与迁移期的回退。
2026-09-13 23:01:43 +08:00

31 lines
878 B
TypeScript

import { runWithoutGlobalVideoFrame } from './withoutVideoFrame.ts'
function check(name: string, cond: boolean) {
if (!cond) throw new Error(`runWithoutGlobalVideoFrame: ${name}`)
}
const FakeVideoFrame = function VideoFrame() {
return undefined
}
Object.defineProperty(globalThis, 'VideoFrame', {
configurable: true,
writable: true,
value: FakeVideoFrame,
})
let seenInside = typeof (globalThis as { VideoFrame?: unknown }).VideoFrame
const result = runWithoutGlobalVideoFrame(() => {
seenInside = typeof (globalThis as { VideoFrame?: unknown }).VideoFrame
return 7
})
check('hides VideoFrame inside the callback', seenInside === 'undefined')
check('returns the callback result', result === 7)
check(
'restores VideoFrame afterwards',
(globalThis as { VideoFrame?: unknown }).VideoFrame === FakeVideoFrame,
)
console.log('withoutVideoFrame.test.ts ok')