From 7c8b179104a19384ef9a0f55e51929a2e7d4a64f Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 19 Apr 2024 22:48:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=8B=E6=9C=BAAPP=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E6=A8=AA=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- idea.md | 2 +- src/plugin/utils.ts | 6 +++++- src/types/util.d.ts | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/idea.md b/idea.md index eea01dc..dfc21da 100644 --- a/idea.md +++ b/idea.md @@ -34,7 +34,7 @@ ## V2.A [x] 自定义工具的大小问题 -[] 优化 ui 布局 +[x] 优化 ui 布局 [] 设置条目中添加 switch 开关 ## V2.A.1 diff --git a/src/plugin/utils.ts b/src/plugin/utils.ts index 21110c0..4e8cea6 100644 --- a/src/plugin/utils.ts +++ b/src/plugin/utils.ts @@ -274,7 +274,11 @@ export async function triggerFullscreen(full: boolean) { if (!Mota.Plugin.inited) return; const { maxGameScale } = Mota.Plugin.require('utils_g'); if (!!document.fullscreenElement && !full) { - await document.exitFullscreen(); + if (window.jsinterface) { + window.jsinterface.requireLandscape?.(); + } else { + await document.exitFullscreen(); + } requestAnimationFrame(() => { maxGameScale(1); }); diff --git a/src/types/util.d.ts b/src/types/util.d.ts index 9f6a046..cf2f5ce 100644 --- a/src/types/util.d.ts +++ b/src/types/util.d.ts @@ -547,6 +547,20 @@ interface Utils { declare const utils: new () => Utils; +/** + * APP接口,使用前应先判断是否存在 + */ +interface JSInterface { + /** 强制横屏 */ + requireLandscape(): void; +} + +declare const jsinterface: JSInterface; + +interface Window { + readonly jsinterface: JSInterface; +} + /** * 移动的方向 */