actionutils

package
v0.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2021 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail

func Fail(action actions.ActionWrapper, err error)

Fail 提示服务器错误信息

func FailPage

func FailPage(action actions.ActionWrapper, err error)

FailPage 提示页面错误信息

func MatchPath

func MatchPath(action *actions.ActionObject, path string) bool

MatchPath 判断动作的文件路径是否相当

func SetSubMenu

func SetSubMenu(action actions.ActionWrapper, menu *MenuGroup)

设置子菜单

func SetTabbar

func SetTabbar(action actions.ActionWrapper, tabbar *Tabbar)

设置子菜单

Types

type ActionInterface added in v0.2.8

type ActionInterface interface {
	RPC() *rpc.RPCClient

	AdminContext() context.Context

	ViewData() maps.Map
}

type CSRF

type CSRF struct {
}

func (*CSRF) BeforeAction

func (this *CSRF) BeforeAction(actionPtr actions.ActionWrapper, paramName string) (goNext bool)
type Menu struct {
	Id               string      `json:"id"`
	Name             string      `json:"name"`
	Items            []*MenuItem `json:"items"`
	IsActive         bool        `json:"isActive"`
	AlwaysActive     bool        `json:"alwaysActive"`
	Index            int         `json:"index"`
	CountNormalItems int         `json:"countNormalItems"`
}

子菜单定义

func NewMenu

func NewMenu() *Menu

获取新对象

func (this *Menu) Add(name string, subName string, url string, isActive bool) *MenuItem

添加菜单项

func (this *Menu) AddSpecial(name string, subName string, url string, isActive bool) *MenuItem

添加特殊菜单项,不计数

type MenuGroup struct {
	Menus      []*Menu `json:"menus"`
	AlwaysMenu *Menu   `json:"alwaysMenu"`
}

菜单分组

func NewMenuGroup

func NewMenuGroup() *MenuGroup

获取新菜单分组对象

func (this *MenuGroup) FindMenu(menuId string, menuName string) *Menu

查找菜单,如果找不到则自动创建

func (this *MenuGroup) Sort()

排序

type MenuItem struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	SubName    string `json:"subName"` // 副标题
	SupName    string `json:"supName"` // 头标
	URL        string `json:"url"`
	IsActive   bool   `json:"isActive"`
	Icon       string `json:"icon"`
	IsSortable bool   `json:"isSortable"`
	SubColor   string `json:"subColor"`
}

菜单项

type Page

type Page struct {
	Offset  int64 // 开始位置
	Size    int64 // 每页显示数量
	Current int64 // 当前页码
	Max     int64 // 最大页码
	Total   int64 // 总数量

	Path  string
	Query url.Values
}

func NewActionPage

func NewActionPage(actionPtr actions.ActionWrapper, total int64, size int64) *Page

func (*Page) AsHTML

func (this *Page) AsHTML() string

func (*Page) IsLastPage

func (this *Page) IsLastPage() bool

判断是否为最后一页

type ParentAction

type ParentAction struct {
	actions.ActionObject
	// contains filtered or unexported fields
}

func FindParentAction

func FindParentAction(actionPtr actions.ActionWrapper) *ParentAction

FindParentAction 查找父级Action

func (*ParentAction) AdminContext

func (this *ParentAction) AdminContext() context.Context

AdminContext 获取Context

func (*ParentAction) AdminId

func (this *ParentAction) AdminId() int64

func (*ParentAction) CreateLog

func (this *ParentAction) CreateLog(level string, description string, args ...interface{})

func (*ParentAction) CreateLogInfo

func (this *ParentAction) CreateLogInfo(description string, args ...interface{})

func (*ParentAction) ErrorPage

func (this *ParentAction) ErrorPage(err error)

func (*ParentAction) ErrorText

func (this *ParentAction) ErrorText(err string)

func (*ParentAction) FirstMenu

func (this *ParentAction) FirstMenu(menuItem string)

func (*ParentAction) Nav

func (this *ParentAction) Nav(mainMenu string, tab string, firstMenu string)

func (*ParentAction) NewPage

func (this *ParentAction) NewPage(total int64, size ...int64) *Page

func (*ParentAction) NotFound

func (this *ParentAction) NotFound(name string, itemId int64)

func (*ParentAction) Parent

func (this *ParentAction) Parent() *ParentAction

Parent 可以调用自身的一个简便方法

func (*ParentAction) RPC

func (this *ParentAction) RPC() *rpc.RPCClient

RPC 获取RPC

func (*ParentAction) SecondMenu

func (this *ParentAction) SecondMenu(menuItem string)

func (*ParentAction) TinyMenu

func (this *ParentAction) TinyMenu(menuItem string)

func (*ParentAction) ViewData added in v0.2.8

func (this *ParentAction) ViewData() maps.Map

ViewData 视图里可以使用的数据

type Tabbar

type Tabbar struct {
	// contains filtered or unexported fields
}

Tabbar定义

func NewTabbar

func NewTabbar() *Tabbar

获取新对象

func (*Tabbar) Add

func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) maps.Map

添加菜单项

func (*Tabbar) Items

func (this *Tabbar) Items() []maps.Map

取得所有的Items

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL