/
index.go
52 lines (44 loc) · 1.25 KB
/
index.go
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
package mongo
import (
"github.com/TeaWeb/code/teaconfigs/db"
"github.com/TeaWeb/code/teadb"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/maps"
"runtime"
"strings"
)
type IndexAction actions.Action
// MongoDB连接信息
func (this *IndexAction) Run(params struct{}) {
config := db.SharedMongoConfig()
this.Data["config"] = maps.Map{
"scheme": config.Scheme,
"username": config.Username,
"password": strings.Repeat("*", len(config.Password)),
"host": config.Host,
"port": config.Port,
"authMechanism": config.AuthMechanism,
"authMechanismProperties": config.AuthMechanismPropertiesString(),
"requestURI": config.RequestURI,
}
this.Data["uri"] = config.URIMask()
// 连接状态
err := teadb.SharedDB().Test()
if err != nil {
this.Data["error"] = err.Error()
} else {
this.Data["error"] = ""
}
// 检测是否已安装
mongodbPath := Tea.Root + "/mongodb/bin/mongod"
if files.NewFile(mongodbPath).Exists() {
this.Data["isInstalled"] = true
} else {
this.Data["isInstalled"] = false
}
// 当前系统
this.Data["os"] = runtime.GOOS
this.Show()
}