-
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.
perf: ♻️ Optimize terminal performance
- Loading branch information
Showing
9 changed files
with
191 additions
and
43 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
44 changes: 44 additions & 0 deletions
44
src/components/Device/components/Terminal/components/TerminalDialog/composables/adb-spawn.js
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,44 @@ | ||
import { debounce } from 'lodash-es' | ||
import { createStderr, createStdout, textFormatter } from 'vue-command' | ||
import { useFixCursor } from './helper.js' | ||
|
||
const $adb = window.adbkit | ||
|
||
export function useAdb({ vShell, history, loading } = {}) { | ||
const adb = async (args) => { | ||
loading.value = true | ||
|
||
const command = args.slice(1).join(' ') | ||
|
||
const appendToHistory = debounce(vShell.value.appendToHistory, 500) | ||
|
||
let stdoutText = '' | ||
let stderrText = '' | ||
$adb.spawnShell(command, { | ||
stdout(text) { | ||
loading.value = false | ||
|
||
stdoutText += text | ||
|
||
useFixCursor(history) | ||
|
||
appendToHistory(createStdout(stdoutText)) | ||
}, | ||
stderr(text) { | ||
loading.value = false | ||
|
||
stderrText += text | ||
|
||
useFixCursor(history) | ||
|
||
appendToHistory(createStderr(stderrText)) | ||
}, | ||
}) | ||
|
||
return textFormatter('Waiting...') | ||
} | ||
|
||
return { | ||
adb, | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/components/Device/components/Terminal/components/TerminalDialog/composables/helper.js
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,8 @@ | ||
import { textFormatter } from 'vue-command' | ||
|
||
export function useFixCursor(history) { | ||
const length = history.value.length | ||
if (history.value[length - 1]?.__name === 'VueCommandQuery') { | ||
history.value.splice(length - 1, 1, textFormatter('Waiting...')) | ||
} | ||
} |
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
Oops, something went wrong.