mirror of
https://github.com/motajs/template.git
synced 2026-11-02 06:34:31 +08:00
21 lines
542 B
TypeScript
21 lines
542 B
TypeScript
/**
|
|
* 切换全屏状态
|
|
* @param full 是否全屏
|
|
*/
|
|
export async function triggerFullscreen(full: boolean) {
|
|
if (document.fullscreenElement && !full) {
|
|
if (window.jsinterface) {
|
|
window.jsinterface.requestPortrait();
|
|
return;
|
|
}
|
|
await document.exitFullscreen();
|
|
}
|
|
if (full && !document.fullscreenElement) {
|
|
if (window.jsinterface) {
|
|
window.jsinterface.requestLandscape();
|
|
return;
|
|
}
|
|
await document.body.requestFullscreen();
|
|
}
|
|
}
|