diff --git a/entry/src/main/ets/common/utils/UsbUtils.ets b/entry/src/main/ets/common/utils/UsbUtils.ets index 34971cce..4e6f84fd 100644 --- a/entry/src/main/ets/common/utils/UsbUtils.ets +++ b/entry/src/main/ets/common/utils/UsbUtils.ets @@ -40,6 +40,9 @@ async function compressFileToCache(input: string, output: string, context: commo } } + + + export class UsbUtils { private context: common.UIAbilityContext @@ -64,28 +67,38 @@ export class UsbUtils { async copyTrackToUsb() { let output = "" let temp = "" - return this.getUsbDiskPath().then(path => { - output = path - return compressFileToCache('/data/log/duolun/logs', "track", this.context) - }).then((trackPath) => { - temp = trackPath - return fs.copyFile(trackPath, output + '/' + "track.zip") - }).then(() => { - return fs.unlink(temp) - }) + return this.getUsbDiskPath() + .then(path => { + output = path + return compressFileToCache('/data/log/duolun/logs', "track", this.context) + }) + .then((trackPath) => { + temp = trackPath + return fs.copyFile(trackPath, output + '/' + "track.zip") + }) + .then(() => { + return fs.unlink(temp) + }) + .finally(() => { + }) } async copyLogToUsb() { let output = "" let temp = "" - return this.getUsbDiskPath().then(path => { - output = path - return compressFileToCache('/data/log/hilog', "log", this.context) - }).then((trackPath) => { - temp = trackPath - return fs.copyFile(trackPath, output + '/' + "log.zip") - }).then(() => { - return fs.unlink(temp) - }) + return this.getUsbDiskPath() + .then(path => { + output = path + return compressFileToCache('/data/log/hilog', "log", this.context) + }) + .then((trackPath) => { + temp = trackPath + return fs.copyFile(trackPath, output + '/' + "log.zip") + }) + .then(() => { + return fs.unlink(temp) + }) + .finally(() => { + }) } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index c3161c39..dc85c930 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -20,6 +20,7 @@ import imageBtn from './compontents/imageBtn'; import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; import { updateModelAndCar } from '../common/autoUpdate/index' import { RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket'; +import { UsbUtils } from '../common/utils/UsbUtils'; @Entry @@ -61,6 +62,7 @@ struct Index { private avPlayer private context = getContext(this) as common.UIAbilityContext; private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket() + private usbUtils: UsbUtils = new UsbUtils(this.context) @Styles commStyle(){ @@ -218,6 +220,27 @@ struct Index { .fontColor('#CCAE7A') .fontSize(22 * globalThis.ratio) .margin({ right: 24 }) + .gesture(GestureGroup(GestureMode.Exclusive, TapGesture({ count: 2 }).onAction(() => { + promptAction.showDialog({ + title: " U盘导出工具", + buttons: [ + { + text: '日志', + color: '#000000' + }, + { + text: '轨迹', + color: '#000000' + } + ], + }).then(res => { + if (res.index === 0) { + this.usbUtils.copyLogToUsb() + } else { + this.usbUtils.copyTrackToUsb() + } + }) + }))) } .width('100%') .justifyContent(FlexAlign.SpaceBetween)