Skip to content

Commit

Permalink
perf: ♻️ Supports retrieving a list of applications
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Nov 8, 2024
1 parent 344b385 commit b1a6ba7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"husky": "9.0.11",
"lodash-es": "4.17.21",
"pinia": "2.1.7",
"pinyin-pro": "^3.26.0",
"postcss": "8.4.38",
"postcss-nested": "6.0.1",
"postcss-scss": "4.0.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
:hide-on-click="false"
:disabled="loading || floating"
max-height="300px"
@mouseenter="getAppData"
trigger="click"
@visible-change="onVisibleChange"
>
<slot :loading :trigger="handleTrigger" />

<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="search" @click.stop>
<el-input v-model="keyword" class="!w-[calc(100%+18px)] !-mx-[9px] !-mt-1" :placeholder="$t('common.search')" prefix-icon="Search"></el-input>
</el-dropdown-item>
<el-dropdown-item
v-for="item of options"
:key="item.value"
Expand All @@ -27,6 +31,9 @@
<script>
import { openFloatControl } from '$/utils/device/index.js'
import { pinyin } from 'pinyin-pro'
import { sleep } from '$/utils'
export default {
props: {
device: {
Expand All @@ -42,6 +49,7 @@ export default {
return {
loading: false,
appList: [],
keyword: '',
}
},
computed: {
Expand All @@ -58,8 +66,13 @@ export default {
icon: 'HomeFilled',
})
if (value[1]) {
value[1].divided = true
value[0].divided = true
if (this.keyword) {
return value.filter((item) => {
const pinyinLabel = pinyin(item.label, { toneType: 'none' })
return (item.label + pinyinLabel).includes(this.keyword)
})
}
return value
Expand All @@ -69,6 +82,12 @@ export default {
this.getAppData()
},
methods: {
async onVisibleChange(val) {
if (!val) {
await sleep()
this.keyword = ''
}
},
async getAppData() {
const data = await window.scrcpy.getAppList(this.device.id)
Expand Down

0 comments on commit b1a6ba7

Please sign in to comment.