From ccb9e2d4409ce38cda2df2089ea7e1804abdc969 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 10 Oct 2024 14:57:54 -0400 Subject: [PATCH] fix the execute command --- app/nuxt.config.ts | 1 + app/plugins/execute.js | 13 ------------- app/plugins/mirror.js | 21 --------------------- app/plugins/scrcpy-plus-core.js | 22 ++++++++++++++++++++++ app/plugins/vuetify.js | 7 ------- 5 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 app/plugins/execute.js delete mode 100644 app/plugins/mirror.js create mode 100644 app/plugins/scrcpy-plus-core.js delete mode 100644 app/plugins/vuetify.js diff --git a/app/nuxt.config.ts b/app/nuxt.config.ts index 4299c66..5afbd9d 100644 --- a/app/nuxt.config.ts +++ b/app/nuxt.config.ts @@ -3,6 +3,7 @@ export default defineNuxtConfig({ compatibilityDate: '2024-04-03', devtools: { enabled: false }, modules: ['nuxt-electron', '@nuxtjs/tailwindcss'], + plugins: ['@/plugins/scrcpy-plus-core'], runtimeConfig: { public: { version: "3.0.0-canary", diff --git a/app/plugins/execute.js b/app/plugins/execute.js deleted file mode 100644 index a88e6ea..0000000 --- a/app/plugins/execute.js +++ /dev/null @@ -1,13 +0,0 @@ -const execute = (cmd) => { - return new Promise((resolve, reject) => { - - require('./modules/execute')(cmd) - .then(res => resolve(res)) - .catch(err => reject(err)) - - }) -} - -export default ({ app }, inject) => { - inject('execute', execute) -} diff --git a/app/plugins/mirror.js b/app/plugins/mirror.js deleted file mode 100644 index b749bb6..0000000 --- a/app/plugins/mirror.js +++ /dev/null @@ -1,21 +0,0 @@ -const execute = (cmd) => { - return new Promise((resolve, reject) => { - require('./modules/execute')(cmd) - .then(res => resolve(res)) - .catch(err => reject(err)) - }) -} - - -const module = { - start(settings, callback) { - - execute(`adb exec-out screenrecord --output-format=h264 file.mp4`); - - callback(); - } -} - -export default ({ app }, inject) => { - inject('mirror', module) -} \ No newline at end of file diff --git a/app/plugins/scrcpy-plus-core.js b/app/plugins/scrcpy-plus-core.js new file mode 100644 index 0000000..469865c --- /dev/null +++ b/app/plugins/scrcpy-plus-core.js @@ -0,0 +1,22 @@ +const { exec } = require("child_process"); +const os = require('os'); + +const execute = (cmd) => { + const isWindows = os.type() == "Windows_NT" ? true : false; + return new Promise((resolve, reject) => { + exec( + (isWindows ? ('cd '+process.env.scrcpyPath+ '&') : ('')) + cmd, // CD to PreInstalled SCRCPY On Windows + (error, stdout, stderr) => { + if (error || stderr) reject(error || stderr); + resolve(stdout); + } + ); + }) +} + + +export default defineNuxtPlugin(() => { + return { + provide: { execute } + } +}) \ No newline at end of file diff --git a/app/plugins/vuetify.js b/app/plugins/vuetify.js deleted file mode 100644 index 92823f6..0000000 --- a/app/plugins/vuetify.js +++ /dev/null @@ -1,7 +0,0 @@ -import('roboto-fontface/css/roboto/roboto-fontface.css'); -import('roboto-fontface/fonts/roboto/Roboto-Thin.woff2') //100 -import('roboto-fontface/fonts/roboto/Roboto-Light.woff2') //300 -import('roboto-fontface/fonts/roboto/Roboto-Regular.woff2') //400 -import('roboto-fontface/fonts/roboto/Roboto-Medium.woff2') //500 -import('roboto-fontface/fonts/roboto/Roboto-Bold.woff2') //700 -import('roboto-fontface/fonts/roboto/Roboto-Black.woff2') //900