feat: usb日志、轨迹拷入
This commit is contained in:
		
							parent
							
								
									4c81726cfe
								
							
						
					
					
						commit
						79c8cba21f
					
				| @ -40,6 +40,9 @@ async function compressFileToCache(input: string, output: string, context: commo | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| export class UsbUtils { | export class UsbUtils { | ||||||
|   private context: common.UIAbilityContext |   private context: common.UIAbilityContext | ||||||
| 
 | 
 | ||||||
| @ -64,28 +67,38 @@ export class UsbUtils { | |||||||
|   async copyTrackToUsb() { |   async copyTrackToUsb() { | ||||||
|     let output = "" |     let output = "" | ||||||
|     let temp = "" |     let temp = "" | ||||||
|     return this.getUsbDiskPath().then(path => { |     return this.getUsbDiskPath() | ||||||
|  |       .then(path => { | ||||||
|         output = path |         output = path | ||||||
|         return compressFileToCache('/data/log/duolun/logs', "track", this.context) |         return compressFileToCache('/data/log/duolun/logs', "track", this.context) | ||||||
|     }).then((trackPath) => { |       }) | ||||||
|  |       .then((trackPath) => { | ||||||
|         temp = trackPath |         temp = trackPath | ||||||
|         return fs.copyFile(trackPath, output + '/' + "track.zip") |         return fs.copyFile(trackPath, output + '/' + "track.zip") | ||||||
|     }).then(() => { |       }) | ||||||
|  |       .then(() => { | ||||||
|         return fs.unlink(temp) |         return fs.unlink(temp) | ||||||
|       }) |       }) | ||||||
|  |       .finally(() => { | ||||||
|  |       }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async copyLogToUsb() { |   async copyLogToUsb() { | ||||||
|     let output = "" |     let output = "" | ||||||
|     let temp = "" |     let temp = "" | ||||||
|     return this.getUsbDiskPath().then(path => { |     return this.getUsbDiskPath() | ||||||
|  |       .then(path => { | ||||||
|         output = path |         output = path | ||||||
|         return compressFileToCache('/data/log/hilog', "log", this.context) |         return compressFileToCache('/data/log/hilog', "log", this.context) | ||||||
|     }).then((trackPath) => { |       }) | ||||||
|  |       .then((trackPath) => { | ||||||
|         temp = trackPath |         temp = trackPath | ||||||
|         return fs.copyFile(trackPath, output + '/' + "log.zip") |         return fs.copyFile(trackPath, output + '/' + "log.zip") | ||||||
|     }).then(() => { |       }) | ||||||
|  |       .then(() => { | ||||||
|         return fs.unlink(temp) |         return fs.unlink(temp) | ||||||
|       }) |       }) | ||||||
|  |       .finally(() => { | ||||||
|  |       }) | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @ -20,6 +20,7 @@ import imageBtn from './compontents/imageBtn'; | |||||||
| import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; | import VoiceAnnounce from './judgeSDK/utils/voiceAnnouncements'; | ||||||
| import { updateModelAndCar } from '../common/autoUpdate/index' | import { updateModelAndCar } from '../common/autoUpdate/index' | ||||||
| import { RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket'; | import { RemoteToolWebsocket } from '../common/utils/RemotetoolWebsocket'; | ||||||
|  | import { UsbUtils } from '../common/utils/UsbUtils'; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @Entry | @Entry | ||||||
| @ -61,6 +62,7 @@ struct Index { | |||||||
|   private avPlayer |   private avPlayer | ||||||
|   private context = getContext(this) as common.UIAbilityContext; |   private context = getContext(this) as common.UIAbilityContext; | ||||||
|   private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket() |   private remoteToolWebsocket: RemoteToolWebsocket = new RemoteToolWebsocket() | ||||||
|  |   private usbUtils: UsbUtils = new UsbUtils(this.context) | ||||||
| 
 | 
 | ||||||
|   @Styles |   @Styles | ||||||
|   commStyle(){ |   commStyle(){ | ||||||
| @ -218,6 +220,27 @@ struct Index { | |||||||
|             .fontColor('#CCAE7A') |             .fontColor('#CCAE7A') | ||||||
|             .fontSize(22 * globalThis.ratio) |             .fontSize(22 * globalThis.ratio) | ||||||
|             .margin({ right: 24 }) |             .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%') |         .width('100%') | ||||||
|         .justifyContent(FlexAlign.SpaceBetween) |         .justifyContent(FlexAlign.SpaceBetween) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user