mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-02-23 15:32:17 +08:00
feat(KeyBoad): click to hide setting
This commit is contained in:
parent
24745548b4
commit
881efbedf4
@ -7,19 +7,32 @@ import { useGlobalStore } from "../../store/global";
|
|||||||
import { useDialog } from "naive-ui";
|
import { useDialog } from "naive-ui";
|
||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
|
|
||||||
// TODO 左键空白区域,关闭设置或active设为-1
|
|
||||||
// TODO 右键空白区域添加按键
|
// TODO 右键空白区域添加按键
|
||||||
// TODO 左键可拖动按钮(并显示到顶部),右键按钮进行修改、删除
|
// TODO 左键可拖动按钮(并显示到顶部),右键按钮进行修改、删除
|
||||||
// TODO 设置界面添加本地数据编辑器(类似utools)
|
// TODO 设置界面添加本地数据编辑器(类似utools)
|
||||||
// TODO 添加开发者工具打开按钮
|
// TODO 添加开发者工具打开按钮
|
||||||
|
|
||||||
const keyInfoShowFlag = ref(false);
|
const showKeyInfoFlag = ref(false);
|
||||||
|
const showSettingFlag = ref(false);
|
||||||
const store = useGlobalStore();
|
const store = useGlobalStore();
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
|
|
||||||
const activeButtonIndex = ref(-1);
|
const activeButtonIndex = ref(-1);
|
||||||
let edited = ref(false);
|
let edited = ref(false);
|
||||||
|
|
||||||
|
function handleClick(event: MouseEvent) {
|
||||||
|
if (
|
||||||
|
event.button === 0 &&
|
||||||
|
event.target === document.getElementById("keyboardElement")
|
||||||
|
) {
|
||||||
|
if (showSettingFlag.value) {
|
||||||
|
showSettingFlag.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeButtonIndex.value = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onBeforeRouteLeave(() => {
|
onBeforeRouteLeave(() => {
|
||||||
if (edited.value) {
|
if (edited.value) {
|
||||||
dialog.warning({
|
dialog.warning({
|
||||||
@ -41,9 +54,13 @@ onBeforeRouteLeave(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="keyboardElement" class="keyboard">
|
<div id="keyboardElement" class="keyboard" @click="handleClick">
|
||||||
<KeySetting v-model="keyInfoShowFlag" />
|
<KeySetting
|
||||||
<KeyInfo v-model="keyInfoShowFlag" />
|
v-model:showKeyInfoFlag="showKeyInfoFlag"
|
||||||
|
v-model:showSettingFlag="showSettingFlag"
|
||||||
|
v-model:edited="edited"
|
||||||
|
/>
|
||||||
|
<KeyInfo v-model:showKeyInfoFlag="showKeyInfoFlag" />
|
||||||
<template v-for="(_, index) in store.editKeyMappingList">
|
<template v-for="(_, index) in store.editKeyMappingList">
|
||||||
<KeyCommon
|
<KeyCommon
|
||||||
@edit="edited = true"
|
@edit="edited = true"
|
||||||
|
@ -4,7 +4,7 @@ import { CloseCircle } from "@vicons/ionicons5";
|
|||||||
import { Ref, onActivated, ref } from "vue";
|
import { Ref, onActivated, ref } from "vue";
|
||||||
import { onBeforeRouteLeave } from "vue-router";
|
import { onBeforeRouteLeave } from "vue-router";
|
||||||
|
|
||||||
const showFlag = defineModel({ required: true });
|
const showKeyInfoFlag = defineModel("showKeyInfoFlag", { required: true });
|
||||||
|
|
||||||
const mouseX = ref(0);
|
const mouseX = ref(0);
|
||||||
const mouseY = ref(0);
|
const mouseY = ref(0);
|
||||||
@ -94,10 +94,10 @@ function dragHandler(downEvent: MouseEvent) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-show="showFlag" class="key-info" @contextmenu.prevent>
|
<div v-show="showKeyInfoFlag" class="key-info" @contextmenu.prevent>
|
||||||
<div class="key-info-header" @mousedown="dragHandler">
|
<div class="key-info-header" @mousedown="dragHandler">
|
||||||
Key Info
|
Key Info
|
||||||
<div class="key-info-close" @click="showFlag = false">
|
<div class="key-info-close" @click="showKeyInfoFlag = false">
|
||||||
<NIcon><CloseCircle></CloseCircle></NIcon>
|
<NIcon><CloseCircle></CloseCircle></NIcon>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,9 +23,10 @@ const store = useGlobalStore();
|
|||||||
const localStore = new Store("store.bin");
|
const localStore = new Store("store.bin");
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
|
|
||||||
const showKeyInfoFlag = defineModel({ required: true });
|
const showKeyInfoFlag = defineModel("showKeyInfoFlag", { required: true });
|
||||||
|
const showSettingFlag = defineModel("showSettingFlag", { required: true });
|
||||||
|
const edited = defineModel("edited", { required: true });
|
||||||
|
|
||||||
const showSetting = ref(false);
|
|
||||||
const showImportModal = ref(false);
|
const showImportModal = ref(false);
|
||||||
const showRenameModal = ref(false);
|
const showRenameModal = ref(false);
|
||||||
const importModalInputValue = ref("");
|
const importModalInputValue = ref("");
|
||||||
@ -121,7 +122,7 @@ function dragHandler(downEvent: MouseEvent) {
|
|||||||
localStore.set("keySettingPos", keySettingPos.value);
|
localStore.set("keySettingPos", keySettingPos.value);
|
||||||
} else {
|
} else {
|
||||||
// click up
|
// click up
|
||||||
showSetting.value = !showSetting.value;
|
showSettingFlag.value = !showSettingFlag.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener("mouseup", upHandler);
|
window.addEventListener("mouseup", upHandler);
|
||||||
@ -233,6 +234,16 @@ function exportKeyMappingConfig() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveKeyMappingConfig() {
|
||||||
|
store.applyEditKeyMappingList();
|
||||||
|
edited.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetKeyMappingConfig() {
|
||||||
|
store.resetEditKeyMappingList();
|
||||||
|
edited.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
function checkConfigSize() {
|
function checkConfigSize() {
|
||||||
const keyboardElement = document.getElementById(
|
const keyboardElement = document.getElementById(
|
||||||
"keyboardElement"
|
"keyboardElement"
|
||||||
@ -309,8 +320,8 @@ function migrateKeyMappingConfig() {
|
|||||||
<NIcon><Settings /></NIcon>
|
<NIcon><Settings /></NIcon>
|
||||||
</template>
|
</template>
|
||||||
</NButton>
|
</NButton>
|
||||||
<div class="key-setting" v-show="showSetting">
|
<div class="key-setting" v-show="showSettingFlag">
|
||||||
<NButton text class="key-setting-close" @click="showSetting = false">
|
<NButton text class="key-setting-close" @click="showSettingFlag = false">
|
||||||
<NIcon><CloseCircle></CloseCircle></NIcon>
|
<NIcon><CloseCircle></CloseCircle></NIcon>
|
||||||
</NButton>
|
</NButton>
|
||||||
<NH4 prefix="bar">按键方案</NH4>
|
<NH4 prefix="bar">按键方案</NH4>
|
||||||
@ -321,6 +332,10 @@ function migrateKeyMappingConfig() {
|
|||||||
/>
|
/>
|
||||||
<NP> Relative Size:{{ curRelativeSize.w }}x{{ curRelativeSize.h }} </NP>
|
<NP> Relative Size:{{ curRelativeSize.w }}x{{ curRelativeSize.h }} </NP>
|
||||||
<NFlex style="margin-top: 20px">
|
<NFlex style="margin-top: 20px">
|
||||||
|
<template v-if="edited">
|
||||||
|
<NButton type="success" @click="saveKeyMappingConfig">保存方案</NButton>
|
||||||
|
<NButton type="error" @click="resetKeyMappingConfig">还原方案</NButton>
|
||||||
|
</template>
|
||||||
<NButton @click="createKeyMappingConfig">新建方案</NButton>
|
<NButton @click="createKeyMappingConfig">新建方案</NButton>
|
||||||
<NButton @click="copyCurKeyMappingConfig">复制方案</NButton>
|
<NButton @click="copyCurKeyMappingConfig">复制方案</NButton>
|
||||||
<NButton @click="migrateKeyMappingConfig">迁移方案</NButton>
|
<NButton @click="migrateKeyMappingConfig">迁移方案</NButton>
|
||||||
|
Loading…
Reference in New Issue
Block a user