fix: 一代机
This commit is contained in:
		
							parent
							
								
									95a53a04e0
								
							
						
					
					
						commit
						912f5636db
					
				| @ -1,56 +1,14 @@ | ||||
| import Want from '@ohos.app.ability.Want' | ||||
| import promptAction from '@ohos.promptAction' | ||||
| import fileAccess from '@ohos.file.fileAccess' | ||||
| import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl' | ||||
| import common from '@ohos.app.ability.common' | ||||
| import fs from '@ohos.file.fs' | ||||
| 
 | ||||
| const LOGTAG = 'LOGTAG' | ||||
| 
 | ||||
| export default class FileUtil { | ||||
|   private context: common.UIAbilityContext | ||||
|   private wantInfos: Want[] | ||||
|   private fileAccessHelper: fileAccess.FileAccessHelper | ||||
| 
 | ||||
|   //后续文件路径待替换
 | ||||
|   private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files/duolun' | ||||
| 
 | ||||
|   public destFile: string | ||||
|   public filePathFdObj: Object = {} | ||||
| 
 | ||||
|   constructor(wantInfos) { | ||||
|     const {requestPermission} = this; | ||||
|     this.wantInfos = wantInfos; | ||||
|     requestPermission(); | ||||
|     fs.mkdir(this.absolutePath) | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|    * @desc 校验文件夹,文件夹不存在会创建,支持嵌套 | ||||
|    * | ||||
|    */ | ||||
|   public initFolder = async (folderPath:string) => { | ||||
|     const {absolutePath} = this; | ||||
|     const folderList = folderPath.split('/').filter(folderName => folderName !== ''); | ||||
| 
 | ||||
|     let path = absolutePath | ||||
|     folderList.forEach((folderName=>{ | ||||
|       path += `/${folderName}`; | ||||
|       try { | ||||
|         const isExit = fs.accessSync(path); | ||||
|         if(!isExit){ | ||||
|           fs.mkdirSync(path) | ||||
|         } | ||||
|       } catch (e) { | ||||
|         console.info('初始化文件夹失败',path) | ||||
|         promptAction.showToast({ | ||||
|           message:`初始化文件夹失败`+ folderPath + JSON.stringify(e), | ||||
|           duration:4000, | ||||
|         }) | ||||
|       } | ||||
|     })); | ||||
|     return path; | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
| * @desc 创建并覆盖文件 | ||||
| * | ||||
| @ -105,7 +63,6 @@ export default class FileUtil{ | ||||
|       console.error(LOGTAG, JSON.stringify(e)) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|  * @desc 关闭文件 | ||||
|  * | ||||
| @ -118,7 +75,6 @@ export default class FileUtil{ | ||||
|       console.info(LOGTAG, filePath + '文件关闭成功') | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|   * @desc 读取文件 | ||||
|   * | ||||
| @ -138,7 +94,6 @@ export default class FileUtil{ | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|    *  @desc获取系统目录里的文件列表 | ||||
|    */ | ||||
| @ -146,44 +101,36 @@ export default class FileUtil{ | ||||
|     const {absolutePath,getFilePathList} = this; | ||||
|     return getFilePathList(`${absolutePath}/${folderPath}`, false) | ||||
|   }; | ||||
|   private context: common.UIAbilityContext | ||||
|   private wantInfos: Want[] | ||||
|   private fileAccessHelper: any | ||||
|   //后续文件路径待替换
 | ||||
|   private absolutePath = '/mnt/hmdfs/100/account/device_view/local/files/duolun' | ||||
|   private getFilePathList = async (filePath: string, isSdcard: boolean) => { | ||||
|     let fileName = [], sdCardFileName = []; | ||||
| 
 | ||||
|   // 删除文件夹或者文件
 | ||||
|   /* | ||||
|    * @desc 删除文件夹或者文件 | ||||
|    * @param{{type}} 1:文件夹 2:文件 3:自定义目录下文件 | ||||
|    **/ | ||||
| 
 | ||||
|   public deleteF = async (path:string,type: 1 | 2 | 3) => { | ||||
|     const {getFilePathList,absolutePath} = this | ||||
|     if(type === 1){ | ||||
|       const fileList = await getFilePathList(`${absolutePath}/${path}`,false); | ||||
|       fileList.forEach(filePath =>{ | ||||
|         fs.unlinkSync(`${absolutePath}/${path}/${filePath}`); | ||||
|       }) | ||||
|       fs.rmdirSync(`${absolutePath}/${path}`); | ||||
|       return true | ||||
|     } | ||||
| 
 | ||||
|     if(type === 2){ | ||||
|       fs.unlinkSync(`${absolutePath}/${path}`); | ||||
|       return true | ||||
|     } | ||||
|     if(type === 3){ | ||||
|       fs.unlinkSync(`${path}`); | ||||
|       return true | ||||
|     try { | ||||
|       const filenames = await fs.listFile(filePath); | ||||
|       for (let i = 0; i < filenames.length; i++) { | ||||
|         console.error(LOGTAG, `目录:${filePath}的子文件:${filenames[i]}`); | ||||
|         if (isSdcard) { | ||||
|           sdCardFileName.push(filenames[i]) | ||||
|         } else { | ||||
|           fileName.push(filenames[i]) | ||||
|         } | ||||
|       } | ||||
| 
 | ||||
|   // 获取系统文件绝对路径
 | ||||
|   public getAbsolutePath = () =>{ | ||||
|     const {absolutePath} = this; | ||||
|     return absolutePath | ||||
|       return isSdcard ? sdCardFileName : fileName | ||||
|     } catch (e) { | ||||
|       console.error(LOGTAG, JSON.stringify(e)); | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
|   // 检索文件列表
 | ||||
|   public getSdCardPathList = async () => { | ||||
|     //@ts-ignore
 | ||||
|     this.wantInfos = await fileAccess.getFileAccessAbilityInfo(); | ||||
|     const {wantInfos,context} = this; | ||||
|     //@ts-ignore
 | ||||
|     const fileAccessHelper = fileAccess.createFileAccessHelper(this.context, this.wantInfos); | ||||
|     this.fileAccessHelper = fileAccessHelper; | ||||
| 
 | ||||
| @ -218,34 +165,11 @@ export default class FileUtil{ | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   public getFileContent = (filePath:string) => { | ||||
|     const {absolutePath} = this; | ||||
|     const { READ_WRITE }= fs.OpenMode | ||||
|     const path = `${absolutePath}/${filePath}` | ||||
|     const str = fs.readTextSync(path); | ||||
|     return str | ||||
|   } | ||||
| 
 | ||||
|   private getFilePathList = async (filePath:string,isSdcard:boolean) => { | ||||
|     let fileName = [],sdCardFileName = []; | ||||
| 
 | ||||
|     try { | ||||
|       const filenames = await fs.listFile(filePath); | ||||
|       for (let i = 0; i < filenames.length; i++) { | ||||
|         console.error(LOGTAG,`目录:${filePath}的子文件:${filenames[i]}`); | ||||
|         if(isSdcard){ | ||||
|           sdCardFileName.push(filenames[i]) | ||||
|         }else{ | ||||
|           fileName.push(filenames[i]) | ||||
|         } | ||||
|       } | ||||
|       return isSdcard ? sdCardFileName : fileName | ||||
|     }catch (e){ | ||||
|       console.error(LOGTAG,JSON.stringify(e)); | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   // 删除文件夹或者文件
 | ||||
|   /* | ||||
|    * @desc 删除文件夹或者文件 | ||||
|    * @param{{type}} 1:文件夹 2:文件 3:自定义目录下文件 | ||||
|    **/ | ||||
|   // 文件系统初始化
 | ||||
|   private requestPermission = async () => { | ||||
|     const {context,absolutePath} = this; | ||||
| @ -253,6 +177,7 @@ export default class FileUtil{ | ||||
|       'ohos.permission.READ_MEDIA', | ||||
|       'ohos.permission.WRITE_MEDIA' | ||||
|     ]; | ||||
|     // @ts-ignore
 | ||||
|     this.wantInfos = await fileAccess.getFileAccessAbilityInfo(); | ||||
|     let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() | ||||
|     atManager.requestPermissionsFromUser(context, permissions, async (code, result) => { | ||||
| @ -267,5 +192,72 @@ export default class FileUtil{ | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   constructor(wantInfos) { | ||||
|     const {requestPermission} = this; | ||||
|     this.wantInfos = wantInfos; | ||||
|     requestPermission(); | ||||
|     fs.mkdir(this.absolutePath) | ||||
|   } | ||||
| 
 | ||||
|   /* | ||||
|    * @desc 校验文件夹,文件夹不存在会创建,支持嵌套 | ||||
|    * | ||||
|    */ | ||||
|   public initFolder = async (folderPath: string) => { | ||||
|     const {absolutePath} = this; | ||||
|     const folderList = folderPath.split('/').filter(folderName => folderName !== ''); | ||||
| 
 | ||||
|     let path = absolutePath | ||||
|     folderList.forEach((folderName => { | ||||
|       path += `/${folderName}`; | ||||
|       try { | ||||
|         const isExit = fs.accessSync(path); | ||||
|         if (!isExit) { | ||||
|           fs.mkdirSync(path) | ||||
|         } | ||||
|       } catch (e) { | ||||
|         console.info('初始化文件夹失败', path) | ||||
|         promptAction.showToast({ | ||||
|           message: `初始化文件夹失败` + folderPath + JSON.stringify(e), | ||||
|           duration: 4000, | ||||
|         }) | ||||
|       } | ||||
|     })); | ||||
|     return path; | ||||
|   } | ||||
| 
 | ||||
|   public deleteF = async (path: string, type: 1 | 2 | 3) => { | ||||
|     const {getFilePathList,absolutePath} = this | ||||
|     if (type === 1) { | ||||
|       const fileList = await getFilePathList(`${absolutePath}/${path}`, false); | ||||
|       fileList.forEach(filePath => { | ||||
|         fs.unlinkSync(`${absolutePath}/${path}/${filePath}`); | ||||
|       }) | ||||
|       fs.rmdirSync(`${absolutePath}/${path}`); | ||||
|       return true | ||||
|     } | ||||
| 
 | ||||
|     if (type === 2) { | ||||
|       fs.unlinkSync(`${absolutePath}/${path}`); | ||||
|       return true | ||||
|     } | ||||
|     if (type === 3) { | ||||
|       fs.unlinkSync(`${path}`); | ||||
|       return true | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // 获取系统文件绝对路径
 | ||||
|   public getAbsolutePath = () => { | ||||
|     const {absolutePath} = this; | ||||
|     return absolutePath | ||||
|   } | ||||
| 
 | ||||
|   public getFileContent = (filePath: string) => { | ||||
|     const {absolutePath} = this; | ||||
|     const { READ_WRITE } = fs.OpenMode | ||||
|     const path = `${absolutePath}/${filePath}` | ||||
|     const str = fs.readTextSync(path); | ||||
|     return str | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -164,7 +164,6 @@ class TcpUtils { | ||||
|     if (log) { | ||||
|       console.log(tag, 'send', message) | ||||
|     } | ||||
|     this.fileUtil.addFile(this.path + 'temp.txt', `^#${message}#$`) | ||||
|     this.socket.send({ | ||||
|       data: `^#${message}#$` | ||||
|     }).then(() => { | ||||
|  | ||||
| @ -1,5 +1,7 @@ | ||||
| import socket from '@ohos.net.socket'; | ||||
| import { PLCGPSData } from '../../mock'; | ||||
| import { PLCGPSData } from '../../mock/PLCGPSData'; | ||||
| 
 | ||||
| // import { PLCGPSData } from '../../mock';
 | ||||
| 
 | ||||
| export default class UdpByOne { | ||||
|   //   PLC udp
 | ||||
| @ -12,7 +14,7 @@ export default class UdpByOne { | ||||
|   // PLC oppositeIpPort
 | ||||
|   private PLCOppositeIpPort: string = '30012'; | ||||
|   // PLC消息
 | ||||
|   private PLCMsg: number[]; | ||||
|   private PLCMsg: ArrayBuffer; | ||||
|   //   GPS udp
 | ||||
|   private GPSUDP: any; | ||||
|   // GPS localIp
 | ||||
| @ -21,7 +23,7 @@ export default class UdpByOne { | ||||
|   // GPS oppositeIpPort
 | ||||
|   private GPSOppositeIpPort: string = '30013'; | ||||
|   // GPS消息
 | ||||
|   private GPSMsg: string; | ||||
|   private GPSMsg: any; | ||||
| 
 | ||||
|   constructor() { | ||||
|     //   初始化UDP
 | ||||
| @ -72,16 +74,13 @@ export default class UdpByOne { | ||||
|     this.sendGPSMsg('1111') | ||||
|     this.PLCUDP.on("message", (res, remoteInfo) => { | ||||
|       console.log('heartMsg', 'getPlc') | ||||
| 
 | ||||
|       this.PLCMsg = res.message; | ||||
|       //   组合数据
 | ||||
|       let newMessage = this.handleMsg(res.message) | ||||
|       let newMessage = this.handleMsg() | ||||
|       callback(newMessage) | ||||
|     }) | ||||
|     return | ||||
|     this.GPSUDP.on("message", (res1, remoteInfo) => { | ||||
|       console.log('heartMsg', 'GPSUDP') | ||||
| 
 | ||||
|       let dataView = new DataView(res1.message) | ||||
|       let str = "" | ||||
|       for (let i = 0; i < dataView?.byteLength; ++i) { | ||||
| @ -91,32 +90,25 @@ export default class UdpByOne { | ||||
|         } | ||||
|       } | ||||
|       this.GPSMsg = str; | ||||
|       console.log('heartMsgGPSstr', str) | ||||
|       return this.PLCUDP.on("message", (res2, remoteInfo) => { | ||||
|         this.PLCMsg = res2.message; | ||||
|         //   组合数据
 | ||||
|         // let newMessage = this.handleMsg()
 | ||||
|         // callback(newMessage)
 | ||||
|       }) | ||||
|       let newMessage = this.handleMsg() | ||||
|       callback(newMessage) | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|   // 处理消息
 | ||||
|   public handleMsg(plcMessage) { | ||||
|   public handleMsg() { | ||||
|     let newMessage = PLCGPSData; | ||||
|     console.log('heartMsg000', PLCGPSData) | ||||
|     //   海拔高度
 | ||||
|     // 原始GPS消息字符串
 | ||||
|     // this.GPSMsg = `$GPGGA,021126.00,2955.5885178,N,11953.8931034,E,5,12,0.8,13.191,M,6.838,M,2.000,0000*49$GPRMC,021126.00,A,2955.5885178,N,11953.8931034,E,4.881,318.3,170623,0.0,E,F*37$GPGST,021126.00,3.30,1.77,3.30,0.0000,1.77,1.25,3.30*67$PTNL,AVR,021126.00,+47.3119,Yaw,+0.4832,Tilt,,,0.817,3,1.7,25*09`;
 | ||||
|     if (this.GPSMsg) { | ||||
|       // 使用正则表达式提取$GPGGA消息
 | ||||
|       let GPGGAMsg = this.GPSMsg.match(/\$GPGGA[^$]*/)[0]; | ||||
|     let GPGGAMsgArr = GPGGAMsg.split(",").slice(0, 15); | ||||
|       let GPGGAMsgArr = GPGGAMsg ? GPGGAMsg.split(",").slice(0, 15) : []; | ||||
|       //   使用正则提取$GPRMC消息
 | ||||
|       let GPRMCMsg = this.GPSMsg.match(/\$GPRMC[^$]*/)[0]; | ||||
|     let GPRMCMsgArr = GPRMCMsg.split(",").slice(0, 14); | ||||
|     //   使用正则表达式提取$GPGST消息]
 | ||||
|     let GPGSTMsg = this.GPSMsg.match(/\$GPGST[^$]*/)[0]; | ||||
|     let GPGSTMsgArr = GPGSTMsg.split(",").slice(0, 9); | ||||
|       let GPRMCMsgArr = GPRMCMsg ? GPRMCMsg.split(",").slice(0, 14) : []; | ||||
|       //   使用正则表达式提取$GPGST消息
 | ||||
|       let GPGSTMatch = this.GPSMsg.match(/\$GPGST[^$]*/); | ||||
|       let GPGSTMsgArr = GPGSTMatch ? GPGSTMatch[0].split(",").slice(0, 9) : []; | ||||
|       //   使用正则提取$PTNL消息
 | ||||
|       let PTNLMsg = this.GPSMsg.match(/\$PTNL[^$]*/)[0]; | ||||
|       let PTNLMsgArr = PTNLMsg.split(",").slice(0, 14); | ||||
| @ -151,57 +143,59 @@ export default class UdpByOne { | ||||
|       newMessage[96] = GPGGAMsgArr[2]; | ||||
|       // 速度97
 | ||||
|       newMessage[97] = GPRMCMsgArr[7]; | ||||
|     let dataView = new DataView(plcMessage) | ||||
|     } | ||||
|     if (this.PLCMsg) { | ||||
|       let dataView = new DataView(this.PLCMsg) | ||||
|       let PLCByteArr = [] | ||||
|       for (let i = 0; i < dataView?.byteLength; ++i) { | ||||
|         let c = dataView?.getUint8(i).toString(2).padStart(8, "0") | ||||
|       console.log('heartMsgheartMsg', c) | ||||
|         PLCByteArr.push(c.toString()) | ||||
|       } | ||||
|     // return
 | ||||
|     // let PLCByteArr = this.PLCMsg.map((num) => num.toString(2).padStart(8, "0"));
 | ||||
|       if (PLCByteArr.length < 55) { | ||||
|         return newMessage.join(",") | ||||
|       } | ||||
|       console.log("heartMsgheartMsg1", PLCByteArr.toString()); | ||||
|       // 左方向灯 2
 | ||||
|     newMessage[2] = PLCByteArr[6][2]; | ||||
|     // 右方向灯 3
 | ||||
|     newMessage[3] = PLCByteArr[6][3]; | ||||
|       newMessage[2] = PLCByteArr[6][5]; | ||||
|       // 右方向灯 3 .
 | ||||
|       newMessage[3] = PLCByteArr[6][4]; | ||||
|       // 喇叭 4
 | ||||
|     newMessage[4] = PLCByteArr[8][2]; | ||||
|       newMessage[4] = PLCByteArr[8][4]; | ||||
|       // 点火1 5
 | ||||
|     newMessage[5] = PLCByteArr[8][0]; | ||||
|       newMessage[5] = PLCByteArr[8][7]; | ||||
|       // 点火2 6
 | ||||
|     newMessage[6] = PLCByteArr[8][1]; | ||||
|       newMessage[6] = PLCByteArr[8][6]; | ||||
|       // 近光灯 7
 | ||||
|     newMessage[7] = PLCByteArr[6][0]; | ||||
|       newMessage[7] = PLCByteArr[6][7]; | ||||
|       // 远光灯 8
 | ||||
|     newMessage[8] = PLCByteArr[6][1]; | ||||
|       newMessage[8] = PLCByteArr[6][6]; | ||||
|       // 示廓灯 9
 | ||||
|     newMessage[9] = PLCByteArr[6][5]; | ||||
|       newMessage[9] = PLCByteArr[6][2]; | ||||
|       // 雾灯 10
 | ||||
|       // 雨刮器 11
 | ||||
|     newMessage[11] = PLCByteArr[8][2]; | ||||
|       newMessage[11] = PLCByteArr[8][5]; | ||||
|       // 脚刹 12
 | ||||
|     newMessage[12] = PLCByteArr[7][2]; | ||||
|       newMessage[12] = PLCByteArr[7][5]; | ||||
|       // 手刹 13
 | ||||
|     newMessage[13] = PLCByteArr[7][3]; | ||||
|       newMessage[13] = PLCByteArr[7][4]; | ||||
|       // 主驾驶门 14
 | ||||
|     newMessage[14] = PLCByteArr[7][0]; | ||||
|       newMessage[14] = PLCByteArr[7][7]; | ||||
|       // NC 15
 | ||||
|       // TODO
 | ||||
|       // SA15 16
 | ||||
|       // TODO
 | ||||
|       // 离合 17
 | ||||
|     newMessage[17] = PLCByteArr[7][1]; | ||||
|       newMessage[17] = PLCByteArr[7][6]; | ||||
|       // 副刹车 18
 | ||||
|     newMessage[18] = PLCByteArr[7][4]; | ||||
|       newMessage[18] = PLCByteArr[7][3]; | ||||
|       // 安全带 19
 | ||||
|     newMessage[19] = PLCByteArr[7][7]; | ||||
|       newMessage[19] = PLCByteArr[7][0]; | ||||
|       // 双跳灯 20
 | ||||
|     newMessage[20] = PLCByteArr[6][4]; | ||||
|       newMessage[20] = PLCByteArr[6][3]; | ||||
|       // 其他门 21
 | ||||
|       // TODO
 | ||||
|       // 转速过高 22
 | ||||
|     newMessage[22] = PLCByteArr[9][7]; | ||||
|       newMessage[22] = PLCByteArr[9][0]; | ||||
|       // 车速 23
 | ||||
|       newMessage[23] = PLCByteArr[11]; | ||||
|       // 累计脉冲 24
 | ||||
| @ -261,6 +255,8 @@ export default class UdpByOne { | ||||
|       // GPS错误次数 60
 | ||||
|       // 已工作时长/设定的工作时长 61
 | ||||
|       // 改正数数据长度*数据长度-基准站RTCM改正数类型 62
 | ||||
|     } | ||||
| 
 | ||||
|     console.log('heartMsgend', newMessage.join(",")) | ||||
| 
 | ||||
|     return newMessage.join(",") | ||||
|  | ||||
| @ -303,7 +303,7 @@ export default class UdpClientByCenter { | ||||
|   onMessage_1(callback?) { | ||||
|     this.onMessage_1Callback = callback; | ||||
|     this.UPDOne.receiveMsg(callback); | ||||
|     this.udp && this.udp.on('message', this.message_1Fn); | ||||
|     // this.udp && this.udp.on('message', this.message_1Fn);
 | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -1,11 +1,9 @@ | ||||
| import TopLogo from './compontents/TopLogo' | ||||
| import { registrationDeviceNo } from '../api/checkCar' | ||||
| import { dateFormat } from '../common/utils/tools' | ||||
| import deviceManager from '@ohos.distributedHardware.deviceManager' | ||||
| import { upDateTableByArray } from '../common/service/initable' | ||||
| import promptAction from '@ohos.promptAction' | ||||
| import FileUtil from '../common/utils/File' | ||||
| import common from '@ohos.app.ability.common'; | ||||
| import common from '@ohos.app.ability.common' | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -25,6 +23,7 @@ export default struct Index { | ||||
|     // this.plateNo=globalThis.carInfo.plateNo | ||||
|     console.log('createDeviceManagerstart') | ||||
|     try { | ||||
|       // @ts-ignore | ||||
|       deviceManager.createDeviceManager('com.oh.dts', (error, value) => { | ||||
|         if (error) { | ||||
|           console.error('createDeviceManager failed.'); | ||||
|  | ||||
| @ -1,9 +1,5 @@ | ||||
| 
 | ||||
| import TopLogo from './compontents/TopLogo' | ||||
| import ethernet from '@ohos.net.ethernet'; | ||||
| import prompt from '@ohos.prompt' | ||||
| import { upDateTableByArray} from '../common/service/initable' | ||||
| import { getSyncData} from '../common/service/initable' | ||||
| import TopLogo from './compontents/TopLogo'; | ||||
| import prompt from '@ohos.prompt'; | ||||
| import FileUtil from '../common/utils/File'; | ||||
| import common from '@ohos.app.ability.common'; | ||||
| import { GlobalConfig } from '../config'; | ||||
| @ -12,7 +8,6 @@ import { GlobalConfig } from '../config'; | ||||
| @Entry | ||||
| @Component | ||||
| struct Index { | ||||
| 
 | ||||
|   @State textList1: string[] = ['差分服务器Ip', '响应端口', '中心服务器IP', '响应端口', '子网掩码', '默认网关', 'dns', '后置机IP ', '响应端口', '前置机IP', '本地端口'] | ||||
|   // @State textList2: string[] = [] | ||||
|   @State ratio: number = 1700 / 960 | ||||
| @ -27,12 +22,13 @@ struct Index { | ||||
|   // @State inputTextList2: string[] = [] | ||||
|   // 112.80.35.83 11052 | ||||
|   // @State inputTextList1: string[] = ['192.168.36.2','8084','192.168.36.200','20122','255.255.255.0','192.168.36.1','','','114.114.114.114','192.168.36.139','8000'] | ||||
|   @State @Watch('outClick') outFlag: boolean = false; | ||||
|   scroller: Scroller = new Scroller() | ||||
|   // @State inputTextList2: string[] = ['192.168.36.139','20022'] | ||||
|   private fileUtil: FileUtil | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
|   private vocObj = null; | ||||
| 
 | ||||
|   @State @Watch('outClick') outFlag: boolean = false;  private vocObj = null; | ||||
|   scroller: Scroller = new Scroller() | ||||
|   build() { | ||||
|     Column() { | ||||
|       TopLogo({ outFlag: $outFlag }) | ||||
| @ -61,7 +57,8 @@ struct Index { | ||||
|                       angle: 0, | ||||
|                       colors: [[0x403C36, 0.0], [0x4D473D, 0.34], [0x3D3A34, 1.0]] | ||||
| 
 | ||||
|                     }).onChange((value: string) => { | ||||
|                     }) | ||||
|                     .onChange((value: string) => { | ||||
|                       this.inputTextList1[index] = value | ||||
| 
 | ||||
|                     }) | ||||
| @ -81,13 +78,29 @@ struct Index { | ||||
|         .width('100%') | ||||
|         .height('80%') | ||||
|         .borderRadius('25px') | ||||
| 
 | ||||
|         Column() { | ||||
|           Image($r('app.media.terminal_save')).width('20.5%').height('74%').onClick(async () => { | ||||
|             const fileUtil = new FileUtil(this.context) | ||||
|             const folderPath = await fileUtil.initFolder(`/config`); | ||||
|             const param={udplocalIp:this.inputTextList1[9],udplocalIpPort:this.inputTextList1[10],udpOppositeIp:this.inputTextList1[7],udpOppositeIpPort:this.inputTextList1[8],tcplocalIp:this.inputTextList1[9],tcplocalIpPort:'8088',tcpOppositeIp:this.inputTextList1[0],tcpOppositePort:this.inputTextList1[1],netMask:this.inputTextList1[4],gateway:this.inputTextList1[5],dnsServers:this.inputTextList1[6],centerIp:this.inputTextList1[2],centerPort:this.inputTextList1[3]} | ||||
|             const param = { | ||||
|               udplocalIp: this.inputTextList1[9], | ||||
|               udplocalIpPort: this.inputTextList1[10], | ||||
|               udpOppositeIp: this.inputTextList1[7], | ||||
|               udpOppositeIpPort: this.inputTextList1[8], | ||||
|               tcplocalIp: this.inputTextList1[9], | ||||
|               tcplocalIpPort: '8088', | ||||
|               tcpOppositeIp: this.inputTextList1[0], | ||||
|               tcpOppositePort: this.inputTextList1[1], | ||||
|               netMask: this.inputTextList1[4], | ||||
|               gateway: this.inputTextList1[5], | ||||
|               dnsServers: this.inputTextList1[6], | ||||
|               centerIp: this.inputTextList1[2], | ||||
|               centerPort: this.inputTextList1[3] | ||||
|             } | ||||
|             fileUtil.addFile(`${folderPath}/ipConfig.txt`, JSON.stringify(param), '') | ||||
|             // upDateTableByArray('IpConfigTable',[]) | ||||
|             // @ts-ignore | ||||
|             ethernet.setIfaceConfig("eth0", { | ||||
|               mode: 0, | ||||
|               ipAddr: this.inputTextList1[9], | ||||
| @ -157,7 +170,7 @@ struct Index { | ||||
|       this.inputTextList1[3] = result.centerPort | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     //@ts-ignore | ||||
|     ethernet.getIfaceConfig("eth0", (error, value) => { | ||||
|       if (error) { | ||||
|         // that.errorMsg='error' | ||||
| @ -173,9 +186,11 @@ struct Index { | ||||
|     }) | ||||
| 
 | ||||
|   } | ||||
| 
 | ||||
|   onPageShow() { | ||||
|     console.info('Index onPageShow'); | ||||
|   } | ||||
| 
 | ||||
|   outClick() { | ||||
| 
 | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user