fix: 优化 SignDisplayCom 组件中的类型声明和代码格式,提升代码一致性
This commit is contained in:
		
							parent
							
								
									bf7a06333d
								
							
						
					
					
						commit
						ef2e07d1ac
					
				| @ -1,15 +1,15 @@ | |||||||
| import router from '@ohos.router'; | import router from '@ohos.router'; | ||||||
| import FileLog from '../judgeSDK/utils/fileLog'; |  | ||||||
| import RealTime from '../compontents/judge/RealTime'; | import RealTime from '../compontents/judge/RealTime'; | ||||||
| import { GPSData, SignalData } from '../../mock'; | import { GPSData, SignalData } from '../../mock'; | ||||||
| import { SignalDataType } from '../../model'; | import { SignalDataType } from '../../model'; | ||||||
|  | 
 | ||||||
| @Component | @Component | ||||||
| export default struct SignDisplayCom { | export default struct SignDisplayCom { | ||||||
|   @State showBack: boolean = false |   @State showBack: boolean = false | ||||||
|   @Prop showTrajectory:boolean = false |   @Prop showTrajectory: boolean = false | ||||||
|   @State scaleNum: number = 1 |   @State scaleNum: number = 1 | ||||||
|   @State msg: string = '' |   @State msg: string = '' | ||||||
|   @State signArr: Array<any> = [] |   @State signArr: Array<string> = [] | ||||||
|   @State sjxhColum: Array<SignalDataType> = SignalData |   @State sjxhColum: Array<SignalDataType> = SignalData | ||||||
|   @State GPSColum: Array<SignalDataType> = GPSData |   @State GPSColum: Array<SignalDataType> = GPSData | ||||||
|   @State udplocalIp: string = '' |   @State udplocalIp: string = '' | ||||||
| @ -181,7 +181,7 @@ export default struct SignDisplayCom { | |||||||
| 
 | 
 | ||||||
|           Row() { |           Row() { | ||||||
|             Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) { |             Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap }) { | ||||||
|               ForEach(this.sjxhColum, (item) => { |               ForEach(this.sjxhColum, (item: SignalDataType) => { | ||||||
|                 Column() { |                 Column() { | ||||||
|                   Text(`${item.key}:${item.value}`) |                   Text(`${item.key}:${item.value}`) | ||||||
|                     .fontSize(14 * this.ratio) |                     .fontSize(14 * this.ratio) | ||||||
| @ -216,7 +216,10 @@ export default struct SignDisplayCom { | |||||||
|               Text('时分秒:' + this.signArr[94]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) |               Text('时分秒:' + this.signArr[94]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) | ||||||
|               Text('经度:' + this.signArr[95]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) |               Text('经度:' + this.signArr[95]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) | ||||||
|               Text('纬度:' + this.signArr[96]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) |               Text('纬度:' + this.signArr[96]).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) | ||||||
|               Text('速度:' +((Number((this.signArr[97]||0))*1.852).toFixed(2)).toString()).fontColor('#FFB433').fontSize(14 * this.ratio).height(18 * this.ratio) |               Text('速度:' + ((Number((this.signArr[97] || 0)) * 1.852).toFixed(2)).toString()) | ||||||
|  |                 .fontColor('#FFB433') | ||||||
|  |                 .fontSize(14 * this.ratio) | ||||||
|  |                 .height(18 * this.ratio) | ||||||
|             } |             } | ||||||
|             .backgroundColor('#1A1A1A') |             .backgroundColor('#1A1A1A') | ||||||
|             .width(170 * this.ratio) |             .width(170 * this.ratio) | ||||||
| @ -231,9 +234,10 @@ export default struct SignDisplayCom { | |||||||
|         .backgroundImage($r('app.media.km_open')) |         .backgroundImage($r('app.media.km_open')) | ||||||
|         .backgroundImageSize({ width: '100%', height: '100%' }) |         .backgroundImageSize({ width: '100%', height: '100%' }) | ||||||
|         .visibility(this.active == 0 ? Visibility.Visible : Visibility.None) |         .visibility(this.active == 0 ? Visibility.Visible : Visibility.None) | ||||||
|  | 
 | ||||||
|         Column() { |         Column() { | ||||||
|           Column() { |           Column() { | ||||||
|             Text( this.msg || '0') |             Text(this.msg || '0') | ||||||
|               .fontColor('#FFF5E5') |               .fontColor('#FFF5E5') | ||||||
|               .fontSize(14 * this.ratio) |               .fontSize(14 * this.ratio) | ||||||
|               .width('100%') |               .width('100%') | ||||||
| @ -253,6 +257,7 @@ export default struct SignDisplayCom { | |||||||
|         .backgroundImage($r('app.media.km_open')) |         .backgroundImage($r('app.media.km_open')) | ||||||
|         .backgroundImageSize({ width: '100%', height: '100%' }) |         .backgroundImageSize({ width: '100%', height: '100%' }) | ||||||
|         .visibility(this.active == 2 ? Visibility.Visible : Visibility.None) |         .visibility(this.active == 2 ? Visibility.Visible : Visibility.None) | ||||||
|  | 
 | ||||||
|         Row() { |         Row() { | ||||||
|           Flex({ direction: FlexDirection.Column }) { |           Flex({ direction: FlexDirection.Column }) { | ||||||
|             Row() { |             Row() { | ||||||
| @ -271,7 +276,7 @@ export default struct SignDisplayCom { | |||||||
|             }.margin({ top: 10 * this.ratio }) |             }.margin({ top: 10 * this.ratio }) | ||||||
| 
 | 
 | ||||||
|             Flex({ direction: FlexDirection.Column }) { |             Flex({ direction: FlexDirection.Column }) { | ||||||
|               ForEach(this.GPSColum, (item) => { |               ForEach(this.GPSColum, (item: SignalDataType) => { | ||||||
|                 Column() { |                 Column() { | ||||||
|                   Text(`${item.key}:${item.value}`) |                   Text(`${item.key}:${item.value}`) | ||||||
|                     .fontSize(12 * this.ratio) |                     .fontSize(12 * this.ratio) | ||||||
| @ -295,7 +300,7 @@ export default struct SignDisplayCom { | |||||||
|           .width(550 * this.ratio) |           .width(550 * this.ratio) | ||||||
|           .height(380 * this.ratio) |           .height(380 * this.ratio) | ||||||
|           .backgroundColor('#1A1A1A') |           .backgroundColor('#1A1A1A') | ||||||
|           .margin({ top: 6 * this.ratio,}) |           .margin({ top: 6 * this.ratio, }) | ||||||
| 
 | 
 | ||||||
|         } |         } | ||||||
|         .width(936 * this.ratio) |         .width(936 * this.ratio) | ||||||
| @ -322,12 +327,12 @@ export default struct SignDisplayCom { | |||||||
|     // this.udplocalIp=JSON.parse(data)?.udplocalIp||'192.168.7.170' |     // this.udplocalIp=JSON.parse(data)?.udplocalIp||'192.168.7.170' | ||||||
|     this.ratio = this.ratio * (this.scaleNum || 1); |     this.ratio = this.ratio * (this.scaleNum || 1); | ||||||
|     const that = this |     const that = this | ||||||
|     const {showBack,getSignal} = this |     const { showBack, getSignal } = this | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     if (showBack) { |     if (showBack) { | ||||||
|       this.ratio = 1.4 |       this.ratio = 1.4 | ||||||
|       globalThis.udpClient.onMessage_1&&globalThis.udpClient.onMessage_1((msg) => { |       globalThis.udpClient.onMessage_1 && globalThis.udpClient.onMessage_1((msg) => { | ||||||
|         console.log('getUDPonMessage_1bysignDisplay0', msg) |         console.log('getUDPonMessage_1bysignDisplay0', msg) | ||||||
|         if (msg) { |         if (msg) { | ||||||
|           getSignal(msg) |           getSignal(msg) | ||||||
| @ -336,7 +341,7 @@ export default struct SignDisplayCom { | |||||||
|     } else { |     } else { | ||||||
|       clearInterval(this.signalTimer) |       clearInterval(this.signalTimer) | ||||||
|       this.signalTimer = setInterval(() => { |       this.signalTimer = setInterval(() => { | ||||||
|         const msgStr = AppStorage.get('msgStr') |         const msgStr = AppStorage.get<string>('msgStr') | ||||||
|         if (msgStr) { |         if (msgStr) { | ||||||
|           getSignal(msgStr) |           getSignal(msgStr) | ||||||
| 
 | 
 | ||||||
| @ -352,7 +357,7 @@ export default struct SignDisplayCom { | |||||||
|     const that = this |     const that = this | ||||||
|     const showBack = this.showBack; |     const showBack = this.showBack; | ||||||
|     if (showBack) { |     if (showBack) { | ||||||
|       globalThis.udpClient.onMessage_1&&globalThis.udpClient.onMessage_1((msg) => { |       globalThis.udpClient.onMessage_1 && globalThis.udpClient.onMessage_1((msg) => { | ||||||
|         console.log('getUDPonMessage_1bysignDisplay2', msg) |         console.log('getUDPonMessage_1bysignDisplay2', msg) | ||||||
| 
 | 
 | ||||||
|         getSignal(msg) |         getSignal(msg) | ||||||
| @ -361,14 +366,14 @@ export default struct SignDisplayCom { | |||||||
|       clearInterval(this.signalTimer) |       clearInterval(this.signalTimer) | ||||||
|       this.signalTimer = setInterval(() => { |       this.signalTimer = setInterval(() => { | ||||||
|         //TODO 临时方案 |         //TODO 临时方案 | ||||||
|         const msgStr =  AppStorage.get('msgStr') |         const msgStr = AppStorage.get<string>('msgStr') | ||||||
|         getSignal(msgStr) |         getSignal(msgStr) | ||||||
|       }, 200) |       }, 200) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   getSignal = (msg) => { |   getSignal = (msg: string) => { | ||||||
|     const that = this; |     const that = this; | ||||||
|     that.msg = msg |     that.msg = msg | ||||||
|     const strachArr = msg.split(',') |     const strachArr = msg.split(',') | ||||||
| @ -410,12 +415,12 @@ export default struct SignDisplayCom { | |||||||
|       this.GPSColum[t].value = this.signArr[i] |       this.GPSColum[t].value = this.signArr[i] | ||||||
|       t++ |       t++ | ||||||
|     } |     } | ||||||
|     this.GPSColum[14].value = ((Number((this.signArr[97]||0))*1.852).toFixed(2)).toString() |     this.GPSColum[14].value = ((Number((this.signArr[97] || 0)) * 1.852).toFixed(2)).toString() | ||||||
|     const str0=this.signArr[93].substr(0,2) |     const str0 = this.signArr[93].substr(0, 2) | ||||||
|     const str1=this.signArr[93].substr(2,2) |     const str1 = this.signArr[93].substr(2, 2) | ||||||
|     const str2=this.signArr[93].substr(4.2) |     const str2 = this.signArr[93].substr(4.2) | ||||||
|     this.signArr[93]=str2+str1+str0 |     this.signArr[93] = str2 + str1 + str0 | ||||||
|     this.GPSColum[10].value =  this.signArr[93] |     this.GPSColum[10].value = this.signArr[93] | ||||||
| 
 | 
 | ||||||
|     // this.signArr[53]=192.168.7.170' |     // this.signArr[53]=192.168.7.170' | ||||||
|     this.sjxhColum = JSON.parse(JSON.stringify((this.sjxhColum))) |     this.sjxhColum = JSON.parse(JSON.stringify((this.sjxhColum))) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user