From aac41628a9dd49a4b2d350d924391cc4100f875a Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 19 Apr 2024 21:48:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=85=B7=E6=A0=8F=E5=AD=98?= =?UTF-8?q?=E5=82=A8=20&=20=E8=99=9A=E6=8B=9F=E9=94=AE=E7=9B=98=E7=BC=A9?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- idea.md | 2 +- src/core/main/custom/toolbar.ts | 6 ++++-- src/core/main/setting.ts | 2 +- src/panel/keyboard.vue | 20 ++++++++++++-------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/idea.md b/idea.md index 4db6548..eea01dc 100644 --- a/idea.md +++ b/idea.md @@ -33,7 +33,7 @@ ## V2.A -[] 自定义工具的大小问题 +[x] 自定义工具的大小问题 [] 优化 ui 布局 [] 设置条目中添加 switch 开关 diff --git a/src/core/main/custom/toolbar.ts b/src/core/main/custom/toolbar.ts index 38b7a82..53b23ac 100644 --- a/src/core/main/custom/toolbar.ts +++ b/src/core/main/custom/toolbar.ts @@ -286,12 +286,14 @@ export class CustomToolbar extends EventEmitter { static save() { toolbarStorage.clear(); + const setting = Mota.require('var', 'mainSetting'); + const scale = setting.getValue('ui.toolbarScale', 100) / 100; this.list.forEach(v => { const toSave: ToolbarSaveData = { x: v.x, y: v.y, - w: v.width, - h: v.height, + w: v.width / scale, + h: v.height / scale, items: [] }; v.items.forEach(v => { diff --git a/src/core/main/setting.ts b/src/core/main/setting.ts index 1e47f52..ab5b5ed 100644 --- a/src/core/main/setting.ts +++ b/src/core/main/setting.ts @@ -522,7 +522,7 @@ loading.once('coreInit', () => { ), 'ui.toolbarScale': storage.getValue( 'ui.toolbarScale', - isMobile ? 40 : Math.floor(window.innerWidth / 1700 * 10) * 10 + isMobile ? 50 : Math.floor(window.innerWidth / 1700 * 10) * 10 ), 'debug.frame': !!storage.getValue('debug.frame', false), }); diff --git a/src/panel/keyboard.vue b/src/panel/keyboard.vue index bb7af69..4a32df4 100644 --- a/src/panel/keyboard.vue +++ b/src/panel/keyboard.vue @@ -6,10 +6,10 @@ @click="keyboard.emitKey(key, i)" :active="checkAssist(assist, key.key)" :style="{ - left: `${key.x * scale}px`, - top: `${key.y * scale}px`, - width: `${key.width * scale}px`, - height: `${key.height * scale}px` + left: `${key.x * caledScale}px`, + top: `${key.y * caledScale}px`, + width: `${key.width * caledScale}px`, + height: `${key.height * caledScale}px` }" > { const key = props.keyboard; @@ -46,9 +45,14 @@ const [width, height] = (() => { if (k.y + k.height > mh) mh = k.y + k.height; } - return [`${mw}px`, `${mh}px`]; + return [mw, mh]; })(); +const caledScale = Math.min(scale, (window.innerWidth / width) * 0.9); +const caledWidth = `${width * caledScale}px`; +const caledHeight = `${height * caledScale}px`; +const fontSize = `${props.keyboard.fontSize * caledScale}px`; + function onAssist() { nextTick(() => { assist.value = props.keyboard.assist; @@ -67,8 +71,8 @@ onUnmounted(() => {