mirror of
https://github.com/AkiChase/scrcpy-mask
synced 2025-02-22 23:12:16 +08:00
feat(sidebar): finish nav button
This commit is contained in:
parent
9d495423f7
commit
73db78a5e1
@ -10,14 +10,47 @@ import {
|
|||||||
} from "@vicons/ionicons5";
|
} from "@vicons/ionicons5";
|
||||||
import { Keyboard24Regular } from "@vicons/fluent";
|
import { Keyboard24Regular } from "@vicons/fluent";
|
||||||
import { NIcon } from "naive-ui";
|
import { NIcon } from "naive-ui";
|
||||||
|
import { useGlobalStore } from "../store/global";
|
||||||
|
import { sendInjectKeycode } from "../frontcommand/controlMsg";
|
||||||
|
import {
|
||||||
|
AndroidKeyEventAction,
|
||||||
|
AndroidKeycode,
|
||||||
|
AndroidMetastate,
|
||||||
|
} from "../frontcommand/android";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const store = useGlobalStore();
|
||||||
|
|
||||||
function nav(name: string) {
|
function nav(name: string) {
|
||||||
router.replace({ name });
|
router.replace({ name });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sleep(time: number) {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve();
|
||||||
|
}, time);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendKeyCodeToDevice(code: AndroidKeycode) {
|
||||||
|
if (store.controledDevice) {
|
||||||
|
await sendInjectKeycode({
|
||||||
|
action: AndroidKeyEventAction.AKEY_EVENT_ACTION_DOWN,
|
||||||
|
keycode: code,
|
||||||
|
repeat: 0,
|
||||||
|
metastate: AndroidMetastate.AMETA_NONE,
|
||||||
|
});
|
||||||
|
await sleep(50);
|
||||||
|
await sendInjectKeycode({
|
||||||
|
action: AndroidKeyEventAction.AKEY_EVENT_ACTION_UP,
|
||||||
|
keycode: code,
|
||||||
|
repeat: 0,
|
||||||
|
metastate: AndroidMetastate.AMETA_NONE,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -50,17 +83,17 @@ function nav(name: string) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
<div>
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_BACK)">
|
||||||
<NIcon>
|
<NIcon>
|
||||||
<ReturnDownBackOutline />
|
<ReturnDownBackOutline />
|
||||||
</NIcon>
|
</NIcon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_HOME)">
|
||||||
<NIcon>
|
<NIcon>
|
||||||
<StopOutline />
|
<StopOutline />
|
||||||
</NIcon>
|
</NIcon>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_APP_SWITCH)">
|
||||||
<NIcon>
|
<NIcon>
|
||||||
<ListOutline />
|
<ListOutline />
|
||||||
</NIcon>
|
</NIcon>
|
||||||
@ -79,6 +112,7 @@ function nav(name: string) {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
@ -88,6 +122,7 @@ function nav(name: string) {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: var(--light-color);
|
color: var(--light-color);
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.module {
|
.module {
|
||||||
|
Loading…
Reference in New Issue
Block a user