EnvironmentCustomDialog.ets
2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { SPHelper } from 'wdKit/Index';
import { HostEnum, HostManager, HttpUrlUtils } from 'wdNetwork/Index';
@CustomDialog
export struct EnvironmentCustomDialog {
@State currentEnvironment: string = HostManager.getHost();
controller: CustomDialogController
cancel: () => void = () => {
}
confirm: () => void = () => {
}
build() {
Column() {
Text("请选择环境")
.fontColor("#222222")
.fontSize(18)
.width("100%")
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.margin({ top: 20 })
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(this.currentEnvironment == HostEnum.HOST_SIT)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HostEnum.HOST_SIT;
}
})
Text('切换到SIT(测试)环境,重启应用生效')
.fontSize(14)
}
.justifyContent(FlexAlign.Start)
.width('90%')
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(this.currentEnvironment == HostEnum.HOST_UAT)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HostEnum.HOST_UAT;
}
})
Text('切换到UAT(预发布)环境,重启应用生效')
.fontSize(14)
}
.width('90%')
.justifyContent(FlexAlign.Start)
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(this.currentEnvironment == HostEnum.HOST_PRODUCT)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HostEnum.HOST_PRODUCT;
}
})
Text('切换到PROD(现网)环境,重启应用生效')
.fontSize(14)
}
.width('90%')
.justifyContent(FlexAlign.Start)
Row() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(this.currentEnvironment == HostEnum.HOST_DEV)
.height(20)
.width(20)
.onChange((isChecked: boolean) => {
if (isChecked) {
this.currentEnvironment = HostEnum.HOST_DEV;
}
})
Text('切换到DEV(开发)环境,重启应用生效')
.fontSize(14)
}
.width('90%')
.justifyContent(FlexAlign.Start)
Button('确认')
.margin({ top: 20 })
.onClick(() => {
// HttpUrlUtils.hostUrl = this.currentEnvironment
SPHelper.default.saveSync('hostUrl', this.currentEnvironment);
this.controller.close()
this.confirm()
})
}.height(261).backgroundColor(Color.White).borderRadius(6).width('74%')
}
}