-
Notifications
You must be signed in to change notification settings - Fork 34
/
helper.go
40 lines (34 loc) · 866 Bytes
/
helper.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
package notices
import (
"github.com/TeaWeb/code/teadb"
"github.com/TeaWeb/code/teaweb/utils"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/logs"
"net/http"
)
type Helper struct {
}
func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) {
action := actionPtr.Object()
action.Data["teaMenu"] = "notices"
if action.Request.Method == http.MethodGet {
if !action.HasPrefix("/notices/badge") {
count, err := teadb.NoticeDAO().CountAllUnreadNotices()
if err != nil {
logs.Error(err)
}
action.Data["countUnread"] = count
}
}
// 操作按钮
menuGroup := utils.NewMenuGroup()
{
menu := menuGroup.FindMenu("operations", "[操作]")
menu.AlwaysActive = true
menuGroup.AlwaysMenu = menu
menu.Index = 10000
menu.Add("通知", "", "/notices", true)
}
menuGroup.Sort()
utils.SetSubMenu(action, menuGroup)
}