-
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.
feat: 🚀 Support execution script function
- Loading branch information
Showing
9 changed files
with
145 additions
and
14 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
80 changes: 80 additions & 0 deletions
80
src/components/Device/components/ControlBar/Shell/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,80 @@ | ||
<template> | ||
<div class="" @click="handleClick(device)"> | ||
<slot :loading="loading" /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ElMessage } from 'element-plus' | ||
const props = defineProps({ | ||
device: { | ||
type: Object, | ||
default: () => null, | ||
}, | ||
loading: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}) | ||
const invokeTerminal = inject('invokeTerminal') | ||
async function handleClick(device) { | ||
let files = null | ||
try { | ||
files = await window.electron.ipcRenderer.invoke('show-open-dialog', { | ||
properties: ['openFile'], | ||
filters: [ | ||
{ | ||
name: window.t('device.control.shell.select'), | ||
extensions: ['sh'], | ||
}, | ||
], | ||
}) | ||
} | ||
catch (error) { | ||
if (error.message) { | ||
const message = error.message?.match(/Error: (.*)/)?.[1] | ||
ElMessage.warning(message || error.message) | ||
} | ||
return false | ||
} | ||
const closeMessage = ElMessage.loading( | ||
window.t('device.control.shell.pushing'), | ||
).close | ||
const filePath = files[0] | ||
let pushFilePath = '' | ||
try { | ||
pushFilePath = await window.adbkit.push(device.id, filePath) | ||
} | ||
catch (error) { | ||
closeMessage() | ||
ElMessage.warning(error.message) | ||
return false | ||
} | ||
if (!pushFilePath) { | ||
closeMessage() | ||
ElMessage.warning('Push script failed') | ||
return false | ||
} | ||
await window.adbkit.deviceShell(device.id, `sh ${pushFilePath}`) | ||
closeMessage() | ||
await ElMessage.success(window.t('device.control.shell.success')) | ||
const command = `adb -s ${device.id} shell sh ${pushFilePath}` | ||
invokeTerminal(command) | ||
} | ||
</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