Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
feat: allow edit adb type
Browse files Browse the repository at this point in the history
allow disconnect controller
  • Loading branch information
neko-para committed Nov 2, 2023
1 parent db566d4 commit 060641b
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 11 deletions.
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
dist
assets

pnpm-lock.yaml

1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"i18n-ally.enabledFrameworks": ["vue"],
"i18n-ally.localesPaths": ["app/renderer/src/i18n/locales"],
"i18n-ally.keystyle": "nested",
"i18n-ally.displayLanguage": "zh_CN",
Expand Down
111 changes: 111 additions & 0 deletions app/renderer/src/components/Device/EditAdbIOType.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<script setup lang="ts">
import { AdbControllerType } from '@maa/loader'
import { NSelect } from 'naive-ui'
import { useTr } from '@/i18n'
import GridFormlayout from '@/layouts/GridFormLayout.vue'
defineProps<{
type: number
}>()
const emits = defineEmits<{
'update:type': [number]
}>()
const { t } = useTr()
const touchOptions = [
{
label: 'adb',
value: AdbControllerType.Touch_Adb
},
{
label: 'minitouch',
value: AdbControllerType.Touch_MiniTouch
},
{
label: 'maatouch',
value: AdbControllerType.Touch_MaaTouch
}
]
const keyOptions = [
{
label: 'adb',
value: AdbControllerType.Key_Adb
},
{
label: 'maatouch',
value: AdbControllerType.Key_MaaTouch
}
]
const screencapOptions = [
{
label: t('device.type.fastest_way'),
value: AdbControllerType.Screencap_FastestWay
},
{
label: t('device.type.raw_by_netcat'),
value: AdbControllerType.Screencap_RawByNetcat
},
{
label: t('device.type.raw_with_gzip'),
value: AdbControllerType.Screencap_RawWithGzip
},
{
label: t('device.type.encode'),
value: AdbControllerType.Screencap_Encode
},
{
label: t('device.type.encode_to_file'),
value: AdbControllerType.Screencap_EncodeToFile
},
{
label: t('device.type.minicap_direct'),
value: AdbControllerType.Screencap_MinicapDirect
},
{
label: t('device.type.minicap_stream'),
value: AdbControllerType.Screencap_MinicapStream
}
]
</script>

<template>
<GridFormlayout>
<span> {{ t('device.info.touch') }} </span>
<NSelect
:value="type & AdbControllerType.Touch_Mask"
@update:value="
v => {
emits('update:type', (type & ~AdbControllerType.Touch_Mask) | v)
}
"
:options="touchOptions"
></NSelect>

<span> {{ t('device.info.key') }} </span>
<NSelect
:value="type & AdbControllerType.Key_Mask"
@update:value="
v => {
emits('update:type', (type & ~AdbControllerType.Key_Mask) | v)
}
"
:options="keyOptions"
></NSelect>

<span> {{ t('device.info.screencap') }} </span>
<NSelect
:value="type & AdbControllerType.Screencap_Mask"
@update:value="
v => {
emits('update:type', (type & ~AdbControllerType.Screencap_Mask) | v)
}
"
:options="screencapOptions"
></NSelect>
</GridFormlayout>
</template>
20 changes: 17 additions & 3 deletions app/renderer/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
"title": "information",
"name": "name",
"adb_path": "ADB path",
"target_address": "target address"
"target_address": "target address",
"touch": "",
"type": "",
"key": "",
"screencap": ""
},
"connect": {
"connect": "connect",
"connected": "connected",
"title": "connect"
"title": "connect",
"disconnect": "disconnect"
},
"hint": {
"choose": "choose a device"
Expand All @@ -18,6 +23,15 @@
"connected": "connected",
"refresh": "refresh",
"disconnected": "disconnected"
},
"type": {
"fastest_way": "fastest way",
"raw_by_netcat": "raw image via netcat",
"raw_with_gzip": "gziped raw image via pipe",
"encode": "png image via pipe",
"encode_to_file": "png image via file",
"minicap_direct": "jpg image via pipe by instant minicap",
"minicap_stream": "jpg image via pipe by stream minicap"
}
},
"setting": {
Expand Down Expand Up @@ -96,6 +110,6 @@
},
"global": {
"confirm": "confirm",
"unset": ""
"unset": "unset"
}
}
18 changes: 16 additions & 2 deletions app/renderer/src/i18n/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
"title": "信息",
"name": "名称",
"adb_path": "ADB路径",
"target_address": "目标地址"
"target_address": "目标地址",
"touch": "点击",
"type": "配置",
"key": "按键",
"screencap": "截图"
},
"connect": {
"connect": "连接",
"connected": "已连接",
"title": "连接"
"title": "连接",
"disconnect": "断开"
},
"hint": {
"choose": "选择一个设备"
Expand All @@ -18,6 +23,15 @@
"refresh": "刷新",
"connected": "已连接",
"disconnected": "未连接"
},
"type": {
"fastest_way": "最快",
"raw_by_netcat": "nc传输原始图像",
"raw_with_gzip": "管道传输gzip图像",
"encode": "管道传输png图像",
"encode_to_file": "文件传输png图像",
"minicap_direct": "单次minicap管道传输jpg图像",
"minicap_stream": "流式minicap管道传输jpg图像"
}
},
"setting": {
Expand Down
27 changes: 23 additions & 4 deletions app/renderer/src/views/Devices/DevicesMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { NButton, NCard } from 'naive-ui'
import { computed, ref } from 'vue'
import EditAdbIOType from '@/components/Device/EditAdbIOType.vue'
import { useTr } from '@/i18n'
import GridFormLayout from '@/layouts/GridFormLayout.vue'
import { useController } from '@/stores/controller'
Expand All @@ -16,7 +17,7 @@ const { t } = useTr()
const statusMessage = ref<string[]>([])
const { device } = useDevice
const { connect, find, handles } = useController
const { connect, disconnect, find, handles } = useController
const info = computed(() => {
if (curDevice.value !== null) {
Expand All @@ -40,6 +41,17 @@ async function requestConnect() {
}
}
async function requestDisconnect() {
if (info.value) {
loading.value = true
const h = find(info.value.adb_serial)
if (h) {
await disconnect(h)
}
loading.value = false
}
}
function processControllerCallback(msg: string, detail: string) {
statusMessage.value.push(translateCallback(msg, detail))
}
Expand All @@ -55,14 +67,21 @@ function processControllerCallback(msg: string, detail: string) {
<span> {{ info.adb_path }} </span>
<span> {{ t('device.info.target_address') }} </span>
<span> {{ info.adb_serial }} </span>
<span> {{ t('device.info.type') }} </span>
<EditAdbIOType v-model:type="info.adb_type"></EditAdbIOType>
</GridFormLayout>
</NCard>
<NCard :title="t('device.connect.title')">
<div class="flex flex-col gap-2">
<div class="flex gap-2">
<NButton v-if="find(info.adb_serial)" disabled>
{{ t('device.connect.connected') }} - {{ find(info.adb_serial) }}
</NButton>
<template v-if="find(info.adb_serial)">
<NButton disabled>
{{ t('device.connect.connected') }}
</NButton>
<NButton @click="requestDisconnect" :loading="loading">
{{ t('device.connect.disconnect') }}
</NButton>
</template>
<NButton v-else @click="requestConnect" :loading="loading" :disabled="!maaactive">
{{ t('device.connect.connect') }}
</NButton>
Expand Down
2 changes: 1 addition & 1 deletion pkgs/loader

0 comments on commit 060641b

Please sign in to comment.