mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-04-19 17:16:08 +08:00
fix: 工具栏存储 & 虚拟键盘缩放
This commit is contained in:
parent
430e8b2f34
commit
aac41628a9
2
idea.md
2
idea.md
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
## V2.A
|
## V2.A
|
||||||
|
|
||||||
[] 自定义工具的大小问题
|
[x] 自定义工具的大小问题
|
||||||
[] 优化 ui 布局
|
[] 优化 ui 布局
|
||||||
[] 设置条目中添加 switch 开关
|
[] 设置条目中添加 switch 开关
|
||||||
|
|
||||||
|
@ -286,12 +286,14 @@ export class CustomToolbar extends EventEmitter<CustomToolbarEvent> {
|
|||||||
|
|
||||||
static save() {
|
static save() {
|
||||||
toolbarStorage.clear();
|
toolbarStorage.clear();
|
||||||
|
const setting = Mota.require('var', 'mainSetting');
|
||||||
|
const scale = setting.getValue('ui.toolbarScale', 100) / 100;
|
||||||
this.list.forEach(v => {
|
this.list.forEach(v => {
|
||||||
const toSave: ToolbarSaveData = {
|
const toSave: ToolbarSaveData = {
|
||||||
x: v.x,
|
x: v.x,
|
||||||
y: v.y,
|
y: v.y,
|
||||||
w: v.width,
|
w: v.width / scale,
|
||||||
h: v.height,
|
h: v.height / scale,
|
||||||
items: []
|
items: []
|
||||||
};
|
};
|
||||||
v.items.forEach(v => {
|
v.items.forEach(v => {
|
||||||
|
@ -522,7 +522,7 @@ loading.once('coreInit', () => {
|
|||||||
),
|
),
|
||||||
'ui.toolbarScale': storage.getValue(
|
'ui.toolbarScale': storage.getValue(
|
||||||
'ui.toolbarScale',
|
'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),
|
'debug.frame': !!storage.getValue('debug.frame', false),
|
||||||
});
|
});
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
@click="keyboard.emitKey(key, i)"
|
@click="keyboard.emitKey(key, i)"
|
||||||
:active="checkAssist(assist, key.key)"
|
:active="checkAssist(assist, key.key)"
|
||||||
:style="{
|
:style="{
|
||||||
left: `${key.x * scale}px`,
|
left: `${key.x * caledScale}px`,
|
||||||
top: `${key.y * scale}px`,
|
top: `${key.y * caledScale}px`,
|
||||||
width: `${key.width * scale}px`,
|
width: `${key.width * caledScale}px`,
|
||||||
height: `${key.height * scale}px`
|
height: `${key.height * caledScale}px`
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -35,7 +35,6 @@ const props = defineProps<{
|
|||||||
const scale = mainSetting.getValue('screen.keyScale', 100) / 100;
|
const scale = mainSetting.getValue('screen.keyScale', 100) / 100;
|
||||||
|
|
||||||
const assist = ref(props.keyboard.assist);
|
const assist = ref(props.keyboard.assist);
|
||||||
const fontSize = `${props.keyboard.fontSize * scale}px`;
|
|
||||||
|
|
||||||
const [width, height] = (() => {
|
const [width, height] = (() => {
|
||||||
const key = props.keyboard;
|
const key = props.keyboard;
|
||||||
@ -46,9 +45,14 @@ const [width, height] = (() => {
|
|||||||
if (k.y + k.height > mh) mh = k.y + k.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() {
|
function onAssist() {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
assist.value = props.keyboard.assist;
|
assist.value = props.keyboard.assist;
|
||||||
@ -67,8 +71,8 @@ onUnmounted(() => {
|
|||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.keyboard-container {
|
.keyboard-container {
|
||||||
width: v-bind(width);
|
width: v-bind(caledWidth);
|
||||||
height: v-bind(height);
|
height: v-bind(caledHeight);
|
||||||
display: block;
|
display: block;
|
||||||
font-size: v-bind(fontSize);
|
font-size: v-bind(fontSize);
|
||||||
position: relative;
|
position: relative;
|
||||||
|
Loading…
Reference in New Issue
Block a user