2024-04-13 09:53:41 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { useRouter, useRoute } from "vue-router";
|
|
|
|
import {
|
|
|
|
GameControllerOutline,
|
|
|
|
LogoAndroid,
|
|
|
|
SettingsOutline,
|
|
|
|
ReturnDownBackOutline,
|
2024-04-18 16:05:34 +08:00
|
|
|
VolumeHighOutline,
|
|
|
|
VolumeLowOutline,
|
2024-04-13 09:53:41 +08:00
|
|
|
StopOutline,
|
|
|
|
ListOutline,
|
2024-04-30 21:05:17 +08:00
|
|
|
BulbOutline,
|
|
|
|
Bulb,
|
2024-04-13 09:53:41 +08:00
|
|
|
} from "@vicons/ionicons5";
|
|
|
|
import { Keyboard24Regular } from "@vicons/fluent";
|
2024-04-18 16:05:34 +08:00
|
|
|
import { NIcon, useMessage } from "naive-ui";
|
2024-04-14 17:18:12 +08:00
|
|
|
import { useGlobalStore } from "../store/global";
|
2024-04-30 21:05:17 +08:00
|
|
|
import {
|
|
|
|
sendInjectKeycode,
|
|
|
|
sendSetScreenPowerMode,
|
|
|
|
} from "../frontcommand/controlMsg";
|
2024-04-14 17:18:12 +08:00
|
|
|
import {
|
|
|
|
AndroidKeyEventAction,
|
|
|
|
AndroidKeycode,
|
|
|
|
AndroidMetastate,
|
|
|
|
} from "../frontcommand/android";
|
2024-04-30 21:05:17 +08:00
|
|
|
import { ref } from "vue";
|
2024-04-13 09:53:41 +08:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
const route = useRoute();
|
2024-04-14 17:18:12 +08:00
|
|
|
const store = useGlobalStore();
|
2024-04-18 16:05:34 +08:00
|
|
|
const message = useMessage();
|
2024-04-13 09:53:41 +08:00
|
|
|
|
2024-04-30 21:05:17 +08:00
|
|
|
const nextScreenPowerMode = ref(0);
|
|
|
|
|
2024-04-13 09:53:41 +08:00
|
|
|
function nav(name: string) {
|
|
|
|
router.replace({ name });
|
|
|
|
}
|
|
|
|
|
2024-04-14 17:18:12 +08:00
|
|
|
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,
|
|
|
|
});
|
2024-04-18 16:05:34 +08:00
|
|
|
} else {
|
|
|
|
message.error("未连接设备");
|
2024-04-14 17:18:12 +08:00
|
|
|
}
|
|
|
|
}
|
2024-04-13 09:53:41 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div data-tauri-drag-region class="sidebar">
|
|
|
|
<div data-tauri-drag-region class="logo">S M</div>
|
|
|
|
<div class="module">
|
|
|
|
<div :class="{ active: route.name == 'mask' }" @click="nav('mask')">
|
|
|
|
<NIcon>
|
|
|
|
<GameControllerOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
|
|
|
<div :class="{ active: route.name == 'device' }" @click="nav('device')">
|
|
|
|
<NIcon>
|
|
|
|
<LogoAndroid />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
:class="{ active: route.name == 'keyboard' }"
|
|
|
|
@click="nav('keyboard')"
|
|
|
|
>
|
|
|
|
<NIcon>
|
|
|
|
<Keyboard24Regular />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
|
|
|
<div :class="{ active: route.name == 'setting' }" @click="nav('setting')">
|
|
|
|
<NIcon>
|
|
|
|
<SettingsOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="nav">
|
2024-04-30 21:05:17 +08:00
|
|
|
<div
|
|
|
|
@click="
|
|
|
|
sendSetScreenPowerMode({ mode: nextScreenPowerMode });
|
|
|
|
nextScreenPowerMode = nextScreenPowerMode ? 0 : 2;
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<NIcon>
|
|
|
|
<Bulb v-if="nextScreenPowerMode" />
|
|
|
|
<BulbOutline v-else />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
2024-04-18 16:05:34 +08:00
|
|
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_VOLUME_UP)">
|
|
|
|
<NIcon>
|
|
|
|
<VolumeHighOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
|
|
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_VOLUME_DOWN)">
|
|
|
|
<NIcon>
|
|
|
|
<VolumeLowOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
2024-04-14 17:18:12 +08:00
|
|
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_BACK)">
|
2024-04-13 09:53:41 +08:00
|
|
|
<NIcon>
|
|
|
|
<ReturnDownBackOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
2024-04-14 17:18:12 +08:00
|
|
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_HOME)">
|
2024-04-13 09:53:41 +08:00
|
|
|
<NIcon>
|
|
|
|
<StopOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
2024-04-14 17:18:12 +08:00
|
|
|
<div @click="sendKeyCodeToDevice(AndroidKeycode.AKEYCODE_APP_SWITCH)">
|
2024-04-13 09:53:41 +08:00
|
|
|
<NIcon>
|
|
|
|
<ListOutline />
|
|
|
|
</NIcon>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.sidebar {
|
|
|
|
background-color: var(--bg-color);
|
|
|
|
border-right: 1px solid rgba(255, 255, 255, 0.2);
|
|
|
|
border-radius: 10px 0 0 10px;
|
|
|
|
grid-area: sidebar;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: space-between;
|
|
|
|
user-select: none;
|
2024-04-14 17:18:12 +08:00
|
|
|
-webkit-user-select: none;
|
2024-04-13 09:53:41 +08:00
|
|
|
|
|
|
|
.logo {
|
|
|
|
height: 30px;
|
|
|
|
font-size: 18px;
|
|
|
|
font-weight: bold;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
color: var(--light-color);
|
2024-04-14 17:18:12 +08:00
|
|
|
cursor: pointer;
|
2024-04-13 09:53:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.module {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
min-height: 0;
|
|
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
& > div {
|
|
|
|
flex-shrink: 0;
|
|
|
|
height: 50px;
|
|
|
|
color: var(--gray-color);
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
transition: transform 0.3s ease;
|
|
|
|
box-sizing: border-box;
|
|
|
|
font-size: 28px;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--primary-hover-color);
|
|
|
|
transform: scale(1.05);
|
|
|
|
}
|
|
|
|
&:active {
|
|
|
|
color: var(--primary-pressed-color);
|
|
|
|
transform: scale(0.9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
& > div.active {
|
|
|
|
color: var(--primary-color);
|
|
|
|
border-left: 3px solid var(--primary-color);
|
|
|
|
border-radius: 3px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav {
|
|
|
|
color: var(--light-color);
|
|
|
|
font-size: 20px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
flex-shrink: 0;
|
|
|
|
& > div {
|
|
|
|
height: 40px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
|
2024-04-18 16:05:34 +08:00
|
|
|
cursor: pointer;
|
|
|
|
transition: transform 0.3s ease;
|
2024-04-13 09:53:41 +08:00
|
|
|
|
2024-04-18 16:05:34 +08:00
|
|
|
&:hover {
|
2024-04-13 09:53:41 +08:00
|
|
|
color: var(--primary-hover-color);
|
|
|
|
transform: scale(1.1);
|
|
|
|
}
|
2024-04-18 16:05:34 +08:00
|
|
|
&:active {
|
2024-04-13 09:53:41 +08:00
|
|
|
color: var(--primary-pressed-color);
|
|
|
|
transform: scale(0.9);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|