-
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.
- Loading branch information
Showing
13 changed files
with
126 additions
and
19 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
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
96 changes: 96 additions & 0 deletions
96
src/components/Device/components/MoreDropdown/components/RecordCamera/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,96 @@ | ||
<template> | ||
<slot :loading="loading" :trigger="handleClick" /> | ||
</template> | ||
|
||
<script> | ||
import { sleep } from '$/utils' | ||
import { openFloatControl } from '$/utils/device/index.js' | ||
export default { | ||
props: { | ||
row: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
toggleRowExpansion: { | ||
type: Function, | ||
default: () => () => false, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
loading: false, | ||
} | ||
}, | ||
methods: { | ||
async handleClick() { | ||
const row = this.row | ||
this.loading = true | ||
this.toggleRowExpansion(row, true) | ||
const savePath = this.getRecordPath(row) | ||
let args = this.$store.preference.scrcpyParameter(row.id, { | ||
isRecord: true, | ||
excludes: ['--otg', '--mouse=aoa', '--keyboard=aoa', '--video-source'], | ||
}) | ||
args += ' --video-source=camera' | ||
try { | ||
const recording = this.$scrcpy.record(row.id, { | ||
title: this.$store.device.getLabel(row, 'recording'), | ||
savePath, | ||
args, | ||
stdout: this.onStdout, | ||
stderr: this.onStderr, | ||
}) | ||
await sleep(1 * 1000) | ||
this.loading = false | ||
openFloatControl(toRaw(this.row)) | ||
await recording | ||
await this.handleSuccess(savePath) | ||
} | ||
catch (error) { | ||
console.error('record.args', args) | ||
console.error('record.error', error) | ||
if (error.message) { | ||
this.$message.warning(error.message) | ||
} | ||
} | ||
}, | ||
onStdout() {}, | ||
onStderr() {}, | ||
getRecordPath(row) { | ||
const config = this.$store.preference.getData(row.id) | ||
const basePath = config.savePath | ||
const extension = config['--record-format'] || 'mp4' | ||
const fileName = this.$store.device.getLabel( | ||
row, | ||
({ time }) => `record-${time}.${extension}`, | ||
) | ||
const joinValue = this.$path.join(basePath, fileName) | ||
const value = this.$path.normalize(joinValue) | ||
return value | ||
}, | ||
async handleSuccess(savePath) { | ||
return this.$message.success( | ||
`${this.$t('device.record.success.title')}: ${savePath}`, | ||
) | ||
}, | ||
}, | ||
} | ||
</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
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