fix: 优化了部分
This commit is contained in:
parent
6e4f0c282b
commit
ea12081e13
@ -12,18 +12,17 @@ import FileUtils from '../utils/FileUtils';
|
|||||||
|
|
||||||
export default class EntryAbility extends UIAbility {
|
export default class EntryAbility extends UIAbility {
|
||||||
async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
|
||||||
|
console.log("多伦鸿蒙车载程序启动")
|
||||||
try {
|
try {
|
||||||
await DB.init(this.context)
|
await DB.init(this.context)
|
||||||
await InitTable()
|
await InitTable()
|
||||||
let fileUtil = new FileUtils(this.context)
|
let fileUtil = new FileUtils(this.context)
|
||||||
|
// 一些地址配置
|
||||||
const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt');
|
const data = await fileUtil.readFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt');
|
||||||
console.log("读取配置", data)
|
|
||||||
if (data !== '' && data !== undefined) {
|
if (data !== '' && data !== undefined) {
|
||||||
console.log("配置设置")
|
|
||||||
const result: EnvironmentConfigurationType = JSON.parse(data)
|
const result: EnvironmentConfigurationType = JSON.parse(data)
|
||||||
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", result)
|
AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", result)
|
||||||
const host = `http://${result.centerIp}:${result.centerPort}`
|
const host = `http://${result.centerIp}:${result.centerPort}`
|
||||||
console.log("host",host)
|
|
||||||
AppStorage.setOrCreate<string>("host", host)
|
AppStorage.setOrCreate<string>("host", host)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -46,7 +45,6 @@ export default class EntryAbility extends UIAbility {
|
|||||||
let rect = windowClass.getWindowProperties().windowRect
|
let rect = windowClass.getWindowProperties().windowRect
|
||||||
let width = rect.width
|
let width = rect.width
|
||||||
let height = rect.height
|
let height = rect.height
|
||||||
console.log("log", width, height)
|
|
||||||
AppStorage.setOrCreate<CarInfoType>('carInfo', {})
|
AppStorage.setOrCreate<CarInfoType>('carInfo', {})
|
||||||
AppStorage.setOrCreate<ExaminerInfoType>('examinerInfo', {})
|
AppStorage.setOrCreate<ExaminerInfoType>('examinerInfo', {})
|
||||||
AppStorage.setOrCreate<string>('lsh', '0000000000000')
|
AppStorage.setOrCreate<string>('lsh', '0000000000000')
|
||||||
|
|||||||
@ -125,8 +125,8 @@ struct Index {
|
|||||||
exam() {
|
exam() {
|
||||||
this.loadingDialog.open()
|
this.loadingDialog.open()
|
||||||
if (!this.timeInfo) {
|
if (!this.timeInfo) {
|
||||||
AppStorage.setOrCreate('type', 1)
|
// AppStorage.setOrCreate('type', 1)
|
||||||
AppStorage.setOrCreate('title', '时间同步接口连接失败')
|
// AppStorage.setOrCreate('title', '时间同步接口连接失败')
|
||||||
this.errorDialog.open()
|
this.errorDialog.open()
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
message: `时间同步接口连接失败`,
|
message: `时间同步接口连接失败`,
|
||||||
|
|||||||
@ -131,6 +131,7 @@ export default function Request<T extends RequestResult>(options: RequestOption)
|
|||||||
extraData: options.xml ? options.data : JSON.stringify(options.data),
|
extraData: options.xml ? options.data : JSON.stringify(options.data),
|
||||||
readTimeout: options.timeout || 30 * 1000
|
readTimeout: options.timeout || 30 * 1000
|
||||||
}).then(async data => {
|
}).then(async data => {
|
||||||
|
console.log(RequestTag, options.url, "返回的数据", JSON.stringify(data))
|
||||||
let result = options.xml ? xmlToJSON(data.result as string) : data.result
|
let result = options.xml ? xmlToJSON(data.result as string) : data.result
|
||||||
let resObj: object = new Object()
|
let resObj: object = new Object()
|
||||||
if (typeof result === 'string') {
|
if (typeof result === 'string') {
|
||||||
|
|||||||
@ -59,6 +59,7 @@ export default class UdpClient {
|
|||||||
|
|
||||||
|
|
||||||
bindUdp(): Promise<void> | undefined {
|
bindUdp(): Promise<void> | undefined {
|
||||||
|
console.log(UDPTag, "绑定udp",this.localIp,this.localIpPort)
|
||||||
return this.udp?.bind({
|
return this.udp?.bind({
|
||||||
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
address: this.localIp, port: parseInt(this.localIpPort), family: 1
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -113,14 +114,14 @@ export default class UdpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async create(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
async create(udpLocalIp: string, udpLocalIpPort: string, udpOppositeIp: string, udpOppositeIpPort: string) {
|
||||||
console.log(UDPTag,"udp 初始化")
|
console.log(UDPTag, "udp 初始化参数", udpLocalIp, udpLocalIpPort, udpOppositeIp, udpOppositeIpPort)
|
||||||
await this.close()
|
await this.close()
|
||||||
this.localIp = udpLocalIp
|
this.localIp = udpLocalIp
|
||||||
this.oppositeIp = udpOppositeIp
|
this.oppositeIp = udpOppositeIp
|
||||||
this.localIpPort = udpLocalIpPort
|
this.localIpPort = udpLocalIpPort
|
||||||
this.oppositeIpPort = udpOppositeIpPort
|
this.oppositeIpPort = udpOppositeIpPort
|
||||||
this.udp = socket.constructUDPSocketInstance();
|
|
||||||
try {
|
try {
|
||||||
|
this.udp = socket.constructUDPSocketInstance();
|
||||||
this.bindUdp()
|
this.bindUdp()
|
||||||
this.bindEvent()
|
this.bindEvent()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -98,7 +98,7 @@ class ObtainUdpBusiness {
|
|||||||
private initSecondGeneration() {
|
private initSecondGeneration() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// 三代机udp初始化
|
||||||
private initThirdGeneration() {
|
private initThirdGeneration() {
|
||||||
try {
|
try {
|
||||||
let config: EnvironmentConfigurationType =
|
let config: EnvironmentConfigurationType =
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19",
|
"@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3",
|
||||||
"@ohos/crypto-js@2.0.3": "@ohos/crypto-js@2.0.3"
|
"@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19"
|
||||||
},
|
},
|
||||||
"packages": {
|
"packages": {
|
||||||
"@ohos/hypium@1.0.19": {
|
"@ohos/hypium@1.0.19": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user