forked from pmh1314520/WebRPA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread-config.ps1
More file actions
35 lines (32 loc) · 1.07 KB
/
read-config.ps1
File metadata and controls
35 lines (32 loc) · 1.07 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
# 读取 WebRPAConfig.json 配置文件
param(
[string]$Key
)
$configPath = Join-Path $PSScriptRoot "WebRPAConfig.json"
try {
if (Test-Path $configPath) {
$config = Get-Content $configPath -Raw -Encoding UTF8 | ConvertFrom-Json
switch ($Key) {
"backend.port" { Write-Output $config.backend.port }
"frontend.port" { Write-Output $config.frontend.port }
"frameworkHub.port" { Write-Output $config.frameworkHub.port }
default { Write-Output "" }
}
} else {
# 配置文件不存在,返回默认值
switch ($Key) {
"backend.port" { Write-Output "8000" }
"frontend.port" { Write-Output "5173" }
"frameworkHub.port" { Write-Output "3000" }
default { Write-Output "" }
}
}
} catch {
# 读取失败,返回默认值
switch ($Key) {
"backend.port" { Write-Output "8000" }
"frontend.port" { Write-Output "5173" }
"frameworkHub.port" { Write-Output "3000" }
default { Write-Output "" }
}
}