Skip to content

Commit

Permalink
feat: 增加logcat日志下载保存
Browse files Browse the repository at this point in the history
  • Loading branch information
guozehui committed Aug 27, 2024
1 parent 352d6ef commit 0fbfdb2
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/views/RemoteEmulator/AndroidRemote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3168,19 +3196,26 @@ const checkAlive = () => {
style="margin-left: 5px"
type="primary"
@click="sendLogcat"
>Search
>Start
</el-button>
<el-button
size="mini"
style="margin-left: 5px"
type="danger"
type="warning"
@click="stopLogcat"
>Stop
</el-button>
<el-button
size="mini"
style="margin-left: 5px"
type="warning"
type="success"
@click="saveLogcat"
>Save
</el-button>
<el-button
size="mini"
style="margin-left: 5px"
type="danger"
@click="clearLogcat"
>Clear
</el-button>
Expand Down

0 comments on commit 0fbfdb2

Please sign in to comment.