web tv模式增加上下键可改为菜单模式

This commit is contained in:
mtvpls
2026-06-12 20:55:06 +08:00
parent 33aa0443e8
commit 98e114ca42
3 changed files with 172 additions and 18 deletions
+33
View File
@@ -0,0 +1,33 @@
export type TVPlayerUpDownAction = 'wake-menu' | 'volume';
export const TV_PLAYER_UP_DOWN_ACTION_KEY = 'tv_player_up_down_action';
export const DEFAULT_TV_PLAYER_UP_DOWN_ACTION: TVPlayerUpDownAction =
'wake-menu';
export function normalizeTVPlayerUpDownAction(
value: unknown
): TVPlayerUpDownAction {
return value === 'volume' ? 'volume' : DEFAULT_TV_PLAYER_UP_DOWN_ACTION;
}
export function loadTVPlayerUpDownAction(): TVPlayerUpDownAction {
if (typeof window === 'undefined') return DEFAULT_TV_PLAYER_UP_DOWN_ACTION;
try {
return normalizeTVPlayerUpDownAction(
localStorage.getItem(TV_PLAYER_UP_DOWN_ACTION_KEY)
);
} catch {
return DEFAULT_TV_PLAYER_UP_DOWN_ACTION;
}
}
export function saveTVPlayerUpDownAction(action: TVPlayerUpDownAction): void {
if (typeof window === 'undefined') return;
try {
localStorage.setItem(TV_PLAYER_UP_DOWN_ACTION_KEY, action);
} catch {
// ignore localStorage failures in private/limited modes
}
}