From 0fbfdb2fc81d0a5124f34841cbbdd74eab988f3e Mon Sep 17 00:00:00 2001 From: guozehui Date: Tue, 27 Aug 2024 18:06:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0logcat=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=B8=8B=E8=BD=BD=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/RemoteEmulator/AndroidRemote.vue | 41 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/views/RemoteEmulator/AndroidRemote.vue b/src/views/RemoteEmulator/AndroidRemote.vue index e4e89d10..2c2db040 100644 --- a/src/views/RemoteEmulator/AndroidRemote.vue +++ b/src/views/RemoteEmulator/AndroidRemote.vue @@ -556,6 +556,34 @@ const stopLogcat = () => { }) ); }; +const saveLogcat = () => { + if (logcatOutPut && Array.isArray(logcatOutPut.value)) { + + const logContent = logcatOutPut.value.join('\n'); + + const blob = new Blob([logContent], { type: 'text/plain;charset=utf-8' }); + + const url = URL.createObjectURL(blob); + + const now = new Date(); + const formattedDate = now.toISOString().replace(/:/g, '-').split('.')[0]; + const modelName = device.value['model']; + const fileName = `${modelName}_${formattedDate}.log`; + + const a = document.createElement('a'); + a.href = url; + + a.download = fileName; + document.body.appendChild(a); + a.click(); + + document.body.removeChild(a); + URL.revokeObjectURL(url); + } else { + console.error("logcatOutPut or logcatOutPut.value not expect"); + } +}; + const sendCmd = () => { if (cmdInput.value.length > 0 && cmdIsDone.value === true) { cmdIsDone.value = false; @@ -3168,19 +3196,26 @@ const checkAlive = () => { style="margin-left: 5px" type="primary" @click="sendLogcat" - >Search + >Start Stop Save + + Clear