-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: 💄 Optimize volume control and gnirehtet
- Loading branch information
Showing
7 changed files
with
137 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/components/Device/components/ControlBar/Volume/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<el-dropdown :hide-on-click="false" @command="handleCommand"> | ||
<div class=""> | ||
<slot :loading="loading" /> | ||
</div> | ||
<template #dropdown> | ||
<el-dropdown-menu> | ||
<el-dropdown-item | ||
v-for="item of options" | ||
:key="item.value" | ||
:command="item.value" | ||
> | ||
{{ $t(item.label) }} | ||
</el-dropdown-item> | ||
</el-dropdown-menu> | ||
</template> | ||
</el-dropdown> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
device: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
}, | ||
data() { | ||
return { | ||
loading: false, | ||
commandMap: { | ||
'volume-down': 'input keyevent KEYCODE_VOLUME_DOWN', | ||
'volume-up': 'input keyevent KEYCODE_VOLUME_UP', | ||
'volume-mute': 'input keyevent KEYCODE_VOLUME_MUTE', | ||
}, | ||
options: [ | ||
{ | ||
label: 'device.control.volume-up.name', | ||
value: 'volume-up', | ||
}, | ||
{ | ||
label: 'device.control.volume-down.name', | ||
value: 'volume-down', | ||
}, | ||
{ | ||
label: 'device.control.volume-mute.name', | ||
value: 'volume-mute', | ||
}, | ||
], | ||
} | ||
}, | ||
methods: { | ||
async handleCommand(value) { | ||
this.loading = true | ||
const command = this.commandMap[value] | ||
this.$adb.deviceShell(this.device.id, command) | ||
this.loading = false | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters