Skip to content

Commit

Permalink
feat: ✨ File Manager Download/Delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Frontesque committed Jul 3, 2022
1 parent bbfba90 commit 16b559d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/renderer/pages/tools/files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
<back />
File Manager
</v-card-title>
<v-text-field v-model="path" label="Path" outlined style="margin: 0 1em -1.5em 1em" disabled />
<v-card-actions>
<div v-for="(item, i) in actions" :key="i" style="margin-right: 0.5em;">
<v-btn rounded :color="item.color" @click="item.action()" :disabled="selected == null && item.requireSelected != false"><v-icon v-text="item.icon" style="margin-right: 0.5em;" />{{ item.name }}</v-btn>
</div>
</v-card-actions>
<div>Path: {{ path }}</div>

</v-card>
<!-- End Actions Menu -->

Expand Down Expand Up @@ -85,16 +86,16 @@ export default {
requireSelected: false,
},
{
name: "Transfer",
name: "Download",
icon: "mdi-download",
color: "green",
action: this.enable,
action: this.download,
},
{
name: "Delete",
icon: "mdi-delete",
color: "red",
action: this.uninstall,
action: this.delete,
}
]
}
Expand Down Expand Up @@ -154,15 +155,13 @@ export default {
this.rebuild();
},
async enable() {
const app = this.apps[this.selected];
const output = await this.$execute(`adb shell pm enable ${app.name}`)
this.showMsg(output);
download() {
this.$fm.download(this.path + this.files[this.selected].name);
},
async uninstall() {
const app = this.apps[this.selected];
const output = await this.$execute(`adb shell pm uninstall -k --user 0 ${app.name}`)
this.showMsg(output);
async delete() {
await this.$fm.delete(this.path + this.files[this.selected].name);
this.rebuild();
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/renderer/plugins/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ For SCRCPY+ & ADB compatable devices
This code uses file browsing via the `ls` command
*/

const execute = require('./modules/execute');
async function shell(cmd) {
return require('./modules/execute')(`adb shell "${cmd}"`);
return execute(`adb shell "${cmd}"`);
}

module = {
Expand All @@ -18,7 +19,21 @@ module = {
if (directories) directories = directories.replace(/\r/g,"").split('\n');

return { files: files || [], directories: directories || [] }
},

async download(file) {
if (!file) return;
const desktop = `${require('os').homedir()}/Desktop`;

return execute(`adb pull ${file} ${desktop}`);
},

async delete(file) {
if (!file) return;

return await execute(`adb shell "rm ${file}"`);
}

}

export default ({ app }, inject) => {
Expand Down

0 comments on commit 16b559d

Please sign in to comment.