From 361a6bafeeaad098a0a1e061ea479329c200a77b Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 4 May 2024 13:30:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=BB=98=E8=AE=A4=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E5=9C=A8resize=E5=90=8E=E8=87=AA=E5=8A=A8=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/main.js | 1 - src/core/main/custom/toolbar.ts | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/main.js b/public/main.js index 975bd5c..671e67b 100644 --- a/public/main.js +++ b/public/main.js @@ -37,7 +37,6 @@ function main() { floorNameLabel: document.getElementById('floorNameLabel'), statusBar: document.getElementById('statusBar'), status: document.getElementsByClassName('status'), - toolBar: document.getElementById('toolBar'), tools: document.getElementsByClassName('tools'), gameCanvas: document.getElementsByClassName('gameCanvas'), gif: document.getElementById('gif'), diff --git a/src/core/main/custom/toolbar.ts b/src/core/main/custom/toolbar.ts index cbdf3e7..502d7ab 100644 --- a/src/core/main/custom/toolbar.ts +++ b/src/core/main/custom/toolbar.ts @@ -427,3 +427,22 @@ Mota.require('var', 'hook').once('reset', () => { CustomToolbar.save(); } }); + +window.addEventListener('resize', () => { + requestAnimationFrame(() => { + const defaultsTool = CustomToolbar.list.find(v => v.id === '@defaults'); + if (!defaultsTool) return; + // 计算位置 + if (isMobile) { + // 手机端显示在最下方 + defaultsTool.setPos(25, window.innerHeight - 100); + defaultsTool.setSize(window.innerWidth - 50, 100); + } else { + // 电脑显示在屏幕右方 + const x = window.innerWidth / 2 + core.domStyle.scale * 240 + 75; + defaultsTool.setPos(x, window.innerHeight / 2 + 100); + defaultsTool.setSize(window.innerWidth - x - 75, 200); + } + defaultsTool.refresh(true); + }); +});