go-adminUI组件学习二

更新时间:2023-08-03 13:11:35 阅读: 评论:0

go-adminUI组件学习⼆
以adminlte主题为例,详细分析模板接⼝的实现代码。
type Theme struct{
ThemeName string
components.Ba
common.BaTheme
}
var Adminlte = Theme{
ThemeName:"adminlte",
Ba: components.Ba{
Attribute: types.Attribute{
/
/TemplateList为adminlte包变量,保存各UI组件的模板
TemplateList: TemplateList,
},
},
}
func init(){
adminTemplate.Add("adminlte",&Adminlte)
}
Theme结构实现template接⼝,在导⼊和使⽤adminlite包时,⾃动调⽤init函数,赋值主题名称和模板列表。
Name()string
GetTmplList()map[string]string
GetAstList()[]string
GetAst(string)([]byte,error)
GetTemplate(bool)(*template.Template,string)
package adminlte
var TemplateList =map[string]string{"admin_panel": `{{define "admin_panel"}}
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
{{.NavButtonsHTML}}
<li title="{{lang "Fixed the sidebar"}}">
<a href="javascript:void(0);" class="fixed-btn" data-click="fal">
军礼<i class="fa fa-thumb-tack"></i>
</a>
月子可以吃什么菜
</li>
......
ThemeName 保存主题名称
components.Ba 基本UI组件结构,实现template接⼝内的组件相关⽅法,给各组件默认属性值,在go-admin/template/。
type Ba struct{
Attribute types.Attribute
容易唱的歌}
func(b Ba)Box() types.BoxAttribute {
return&BoxAttribute{
Name:"box",
Header:    template.HTML(""),
Body:      template.HTML(""),
Footer:    template.HTML(""),
处臵
Title:"",
HeadBorder:"",
Attribute:  b.Attribute,
Attribute:  b.Attribute,
}
}
func(b Ba)Col() types.ColAttribute { return&ColAttribute{
Name:"col",
Size:"col-md-2",
Content:"",
Attribute: b.Attribute,
}
}
func(b Ba)Form() types.FormAttribute { return&FormAttribute{
Name:"form",
Content:[]types.FormField{},
Url:"/",
Method:"post",
HiddenFields:make(map[string]string),  Layout:      form.LayoutDefault,
Title:"edit",
Attribute:    b.Attribute,
CdnUrl:      config.GetAstUrl(),
HeadWidth:2,
InputWidth:8,
}
}
func(b Ba)Image() types.ImgAttribute { return&ImgAttribute{
Name:"image",
Width:"50",
Height:"50",
Src:"",
Attribute: b.Attribute,
}
}
虎斑贝func(b Ba)Tabs() types.TabsAttribute { return&TabsAttribute{
Name:"tabs",
Attribute: b.Attribute,
}
}
func(b Ba)Alert() types.AlertAttribute { return&AlertAttribute{
Name:"alert",
内疚什么意思
Attribute: b.Attribute,
摩羯座水逆}
}
func(b Ba)Label() types.LabelAttribute { return&LabelAttribute{
Name:"label",
Type:"",
Content:"",
Attribute: b.Attribute,
}
}
func(b Ba)Link() types.LinkAttribute { return&LinkAttribute{
Name:"link",
Content:"",
Content:"",
Attribute: b.Attribute,
}
}
func(b Ba)Popup() types.PopupAttribute { return&PopupAttribute{
Name:"popup",
Attribute: b.Attribute,
}
}
func(b Ba)Paginator() types.PaginatorAttribute { return&PaginatorAttribute{
Name:"paginator",
Attribute: b.Attribute,
}
}
func(b Ba)Row() types.RowAttribute {
return&RowAttribute{
Name:"row",
Content:"",
Attribute: b.Attribute,
}
}
func(b Ba)Button() types.ButtonAttribute { return&ButtonAttribute{
Name:"button",
Content:"",
Href:"",
Attribute: b.Attribute,
}
}
func(b Ba)Table() types.TableAttribute {
return&TableAttribute{
Name:"table",
Thead:make(types.Thead,0),
InfoList:make([]map[string]types.InfoItem,0),
Type:"normal",
Style:"hover",
Layout:"auto",
Attribute: b.Attribute,
}
}
func(b Ba)DataTable() types.DataTableAttribute { return&DataTableAttribute{
TableAttribute:*(b.Table().
SetType("data-table").(*TableAttribute)),
EditUrl:"",
NewUrl:"",
Style:"hover",
Attribute: b.Attribute,
}
}
func(b Ba)Tree() types.TreeAttribute {
return&TreeAttribute{
Name:"tree",
Tree:[]menu.Item{},
Attribute: b.Attribute,
}
}
common.BaTheme 实现获取版本、要求admin版本等⽅法。
GetAstImportHTML(exceptComponents ...string) template.HTML GetVersion()string
GetRequirements()[]string称赞反义词

本文发布于:2023-08-03 13:11:35,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1106592.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:组件   实现   主题   模板   名称   版本
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图