generated from only9464/Acrylic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppManager.go
57 lines (50 loc) · 1.09 KB
/
AppManager.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
53
54
55
56
57
package main
import (
"HEU-Wisedu/apps/FAWKC"
"HEU-Wisedu/apps/Settings"
"HEU-Wisedu/apps/TJKC"
"HEU-Wisedu/apps/XGKC"
"HEU-Wisedu/apps/YXKCYX"
"HEU-Wisedu/apps/login"
"HEU-Wisedu/apps/only9464"
"context"
)
// 创建新的AppManager并注册所有app
func NewAppManager() *AppManager {
return &AppManager{
apps: []AppInterface{
NewApp(),
TJKC.NewApp(),
FAWKC.NewApp(),
XGKC.NewApp(),
YXKCYX.NewApp(),
login.NewApp(),
only9464.NewApp(),
Settings.NewApp(),
// 在这里添加新的app即可(嘻嘻)*****
},
}
}
///所有APP统一管理
// App接口定义所有app必须实现的方法
type AppInterface interface {
Startup(ctx context.Context)
}
// 存储所有app实例
type AppManager struct {
apps []AppInterface
}
// 统一处理Startup
func (am *AppManager) StartupHandler(ctx context.Context) {
for _, app := range am.apps {
app.Startup(ctx)
}
}
// 获取需要绑定的接口列表
func (am *AppManager) GetBindings() []interface{} {
bindings := make([]interface{}, len(am.apps))
for i, app := range am.apps {
bindings[i] = app
}
return bindings
}