UNPKG

vue-danmaku

Version:

基于 Vue 的弹幕交互组件 | A danmaku component for Vue

102 lines (101 loc) 2.88 kB
/** * 性能监控模块 * 提供FPS监控和弹幕性能监控功能 */ type PerformanceWarningCallback = (data: { count: number; threshold: number; message: string; }) => void; type FpsDropCallback = (data: { fps: number; threshold: number; }) => void; /** * FPS监控类 */ declare class FpsMonitor { private fpsMonitorTimer; private lastTime; private frames; private fps; private fpsThreshold; private running; private onFpsDrop; constructor(fpsThreshold?: number, onFpsDrop?: FpsDropCallback); /** * 开始监控FPS */ start(): void; /** * 停止监控FPS */ stop(): void; /** * 获取当前FPS */ getCurrentFps(): number; /** * 设置FPS下降回调函数 */ setFpsDropCallback(callback: FpsDropCallback): void; /** * 设置FPS阈值 */ setFpsThreshold(threshold: number): void; } /** * 弹幕性能监控器 */ declare class DanmakuPerformanceMonitor { private warningThreshold; private onPerformanceWarning; constructor(warningThreshold?: number, onPerformanceWarning?: PerformanceWarningCallback); /** * 检查弹幕数量是否超过阈值 * @param count 当前弹幕数量 */ checkPerformance(count: number): void; /** * 设置性能警告回调函数 */ setWarningCallback(callback: PerformanceWarningCallback): void; /** * 设置警告阈值 */ setWarningThreshold(threshold: number): void; } /** * 创建FPS监控器 * @param fpsThreshold FPS阈值,低于此值触发回调 * @param onFpsDrop FPS下降回调函数 */ export declare function createFpsMonitor(fpsThreshold?: number, onFpsDrop?: FpsDropCallback): FpsMonitor; /** * 创建弹幕性能监控器 * @param warningThreshold 弹幕数量警告阈值 * @param onPerformanceWarning 性能警告回调函数 */ export declare function createDanmakuPerformanceMonitor(warningThreshold?: number, onPerformanceWarning?: PerformanceWarningCallback): DanmakuPerformanceMonitor; /** * 为vue-danmaku组件创建性能监控 * 便捷方法,同时创建FPS监控和弹幕性能监控 * @param options 配置选项 */ export declare function createDanmakuMonitor(options?: { fpsThreshold?: number; warningThreshold?: number; onFpsDrop?: FpsDropCallback; onPerformanceWarning?: PerformanceWarningCallback; }): { fpsMonitor: FpsMonitor; performanceMonitor: DanmakuPerformanceMonitor; startAll(): void; stopAll(): void; checkDanmakuCount(count: number): void; }; export declare const PERFORMANCE_CONSTANTS: { DEFAULT_FPS_THRESHOLD: number; DEFAULT_WARNING_DANMU_COUNT: number; }; export type { FpsDropCallback, PerformanceWarningCallback };