mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-09-26 20:11:11 +08:00
chore: 新增mix相关组件
This commit is contained in:
@@ -68,7 +68,7 @@ func main() {
|
||||
|
||||
## 相关项目
|
||||
- [QuarkSmart](https://github.com/quarkcms/quark-smart) 单体应用
|
||||
- [QuarkMicro](https://github.com/quarkcms/quark-micro) 微服务应用(开发中)
|
||||
- [QuarkMicro](https://github.com/quarkcms/quark-go) 微服务应用(开发中)
|
||||
|
||||
## 演示站点
|
||||
香港站点,页面加载可能比较缓慢
|
||||
|
0
pkg/app/handler/mix/pages/.keep
Normal file
0
pkg/app/handler/mix/pages/.keep
Normal file
4
pkg/app/handler/mix/providers.go
Normal file
4
pkg/app/handler/mix/providers.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package mix
|
||||
|
||||
// 注册服务
|
||||
var Providers = []interface{}{}
|
0
pkg/app/handler/mix/uploads/.keep
Normal file
0
pkg/app/handler/mix/uploads/.keep
Normal file
181
pkg/builder/template/mixtemplate.go
Normal file
181
pkg/builder/template/mixtemplate.go
Normal file
@@ -0,0 +1,181 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"github.com/quarkcms/quark-go/pkg/app/model"
|
||||
"github.com/quarkcms/quark-go/pkg/builder"
|
||||
"github.com/quarkcms/quark-go/pkg/component/admin/footer"
|
||||
"github.com/quarkcms/quark-go/pkg/component/admin/layout"
|
||||
"github.com/quarkcms/quark-go/pkg/component/admin/page"
|
||||
"github.com/quarkcms/quark-go/pkg/component/admin/pagecontainer"
|
||||
"github.com/quarkcms/quark-go/pkg/msg"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 模板
|
||||
type MixTemplate struct {
|
||||
DB *gorm.DB // DB对象
|
||||
Model interface{} // DB模型结构体
|
||||
RouteMapping []*builder.RouteMapping // 路由映射
|
||||
}
|
||||
|
||||
// 获取路由
|
||||
func (p *MixTemplate) GetRouteMapping() []*builder.RouteMapping {
|
||||
return p.RouteMapping
|
||||
}
|
||||
|
||||
// 是否存在路由
|
||||
func (p *MixTemplate) hasRouteMapping(method string, path string, handlerName string) bool {
|
||||
has := false
|
||||
for _, v := range p.RouteMapping {
|
||||
if v.Method == method && v.Path == path && v.HandlerName == handlerName {
|
||||
has = true
|
||||
}
|
||||
}
|
||||
|
||||
return has
|
||||
}
|
||||
|
||||
// 注册路由
|
||||
func (p *MixTemplate) AddRouteMapping(method string, path string, handlerName string) *MixTemplate {
|
||||
if !p.hasRouteMapping(method, path, handlerName) {
|
||||
getRoute := &builder.RouteMapping{
|
||||
Method: method,
|
||||
Path: path,
|
||||
HandlerName: handlerName,
|
||||
}
|
||||
|
||||
p.RouteMapping = append(p.RouteMapping, getRoute)
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// ANY is a shortcut for router.Handle(http.MethodGet, path, handle)
|
||||
func (p *MixTemplate) Any(path string, handlerName string) {
|
||||
p.AddRouteMapping("Any", path, handlerName)
|
||||
}
|
||||
|
||||
// GET is a shortcut for router.Handle(http.MethodGet, path, handle)
|
||||
func (p *MixTemplate) GET(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodGet, path, handlerName)
|
||||
}
|
||||
|
||||
// HEAD is a shortcut for router.Handle(http.MethodHead, path, handle)
|
||||
func (p *MixTemplate) HEAD(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodHead, path, handlerName)
|
||||
}
|
||||
|
||||
// OPTIONS is a shortcut for router.Handle(http.MethodOptions, path, handle)
|
||||
func (p *MixTemplate) OPTIONS(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodOptions, path, handlerName)
|
||||
}
|
||||
|
||||
// POST is a shortcut for router.Handle(http.MethodPost, path, handle)
|
||||
func (p *MixTemplate) POST(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodPost, path, handlerName)
|
||||
}
|
||||
|
||||
// PUT is a shortcut for router.Handle(http.MethodPut, path, handle)
|
||||
func (p *MixTemplate) PUT(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodPut, path, handlerName)
|
||||
}
|
||||
|
||||
// PATCH is a shortcut for router.Handle(http.MethodPatch, path, handle)
|
||||
func (p *MixTemplate) PATCH(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodPatch, path, handlerName)
|
||||
}
|
||||
|
||||
// DELETE is a shortcut for router.Handle(http.MethodDelete, path, handle)
|
||||
func (p *MixTemplate) DELETE(path string, handlerName string) {
|
||||
p.AddRouteMapping(http.MethodDelete, path, handlerName)
|
||||
}
|
||||
|
||||
// 页面组件渲染
|
||||
func (p *MixTemplate) PageComponentRender(ctx *builder.Context, body interface{}) interface{} {
|
||||
|
||||
// Layout组件
|
||||
layoutComponent := ctx.Template.(interface {
|
||||
LayoutComponentRender(ctx *builder.Context, body interface{}) interface{}
|
||||
}).LayoutComponentRender(ctx, body)
|
||||
|
||||
return (&page.Component{}).
|
||||
Init().
|
||||
SetStyle(map[string]interface{}{
|
||||
"height": "100vh",
|
||||
}).
|
||||
SetBody(layoutComponent).
|
||||
JsonSerialize()
|
||||
}
|
||||
|
||||
// 页面布局组件渲染
|
||||
func (p *MixTemplate) LayoutComponentRender(ctx *builder.Context, body interface{}) interface{} {
|
||||
admin := &model.Admin{}
|
||||
config := ctx.Engine.GetConfig()
|
||||
|
||||
// 获取登录管理员信息
|
||||
adminInfo, err := admin.GetAuthUser(config.AppKey, ctx.Token())
|
||||
if err != nil {
|
||||
return msg.Error(err.Error(), "")
|
||||
}
|
||||
|
||||
// 获取管理员菜单
|
||||
getMenus, err := admin.GetMenuListById(adminInfo.Id)
|
||||
if err != nil {
|
||||
return msg.Error(err.Error(), "")
|
||||
}
|
||||
|
||||
adminLayout := ctx.Engine.GetAdminLayout()
|
||||
|
||||
// 页脚
|
||||
footer := (&footer.Component{}).
|
||||
Init().
|
||||
SetCopyright(adminLayout.Copyright).
|
||||
SetLinks(adminLayout.Links)
|
||||
|
||||
// 页面容器组件渲染
|
||||
pageContainerComponent := ctx.Template.(interface {
|
||||
PageContainerComponentRender(ctx *builder.Context, body interface{}) interface{}
|
||||
}).PageContainerComponentRender(ctx, body)
|
||||
|
||||
return (&layout.Component{}).
|
||||
Init().
|
||||
SetTitle(adminLayout.Title).
|
||||
SetLogo(adminLayout.Logo).
|
||||
SetActions(adminLayout.Actions).
|
||||
SetLayout(adminLayout.Layout).
|
||||
SetSplitMenus(adminLayout.SplitMenus).
|
||||
SetContentWidth(adminLayout.ContentWidth).
|
||||
SetPrimaryColor(adminLayout.PrimaryColor).
|
||||
SetFixSiderbar(adminLayout.FixSiderbar).
|
||||
SetFixedHeader(adminLayout.FixedHeader).
|
||||
SetIconfontUrl(adminLayout.IconfontUrl).
|
||||
SetLocale(adminLayout.Locale).
|
||||
SetSiderWidth(adminLayout.SiderWidth).
|
||||
SetMenu(getMenus).
|
||||
SetBody(pageContainerComponent).
|
||||
SetFooter(footer)
|
||||
}
|
||||
|
||||
// 页面容器组件渲染
|
||||
func (p *MixTemplate) PageContainerComponentRender(ctx *builder.Context, body interface{}) interface{} {
|
||||
value := reflect.ValueOf(ctx.Template).Elem()
|
||||
title := value.FieldByName("Title").String()
|
||||
subTitle := value.FieldByName("SubTitle").String()
|
||||
|
||||
// 设置头部
|
||||
header := (&pagecontainer.PageHeader{}).
|
||||
Init().
|
||||
SetTitle(title).
|
||||
SetSubTitle(subTitle)
|
||||
|
||||
return (&pagecontainer.Component{}).Init().SetHeader(header).SetBody(body)
|
||||
}
|
||||
|
||||
// 默认组件渲染
|
||||
func (p *MixTemplate) Render(ctx *builder.Context) interface{} {
|
||||
|
||||
return msg.Error("请实现组件渲染方法", "")
|
||||
}
|
308
pkg/component/mix/action/action.go
Normal file
308
pkg/component/mix/action/action.go
Normal file
@@ -0,0 +1,308 @@
|
||||
package action
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Label string `json:"label"`
|
||||
Size string `json:"size"`
|
||||
Type string `json:"type"`
|
||||
Plain bool `json:"plain"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Loading bool `json:"loading"`
|
||||
FormType string `json:"formType"`
|
||||
OpenType string `json:"openType"`
|
||||
HoverClass string `json:"hoverClass"`
|
||||
HoverStartTime int `json:"hoverStartTime"`
|
||||
HoverStayTime int `json:"hoverStayTime"`
|
||||
AppParameter string `json:"appParameter"`
|
||||
HoverStopPropagation bool `json:"hoverStopPropagation"`
|
||||
Lang string `json:"lang"`
|
||||
SessionFrom string `json:"sessionFrom"`
|
||||
SendMessageTitle string `json:"sendMessageTitle"`
|
||||
SendMessagePath string `json:"sendMessagePath"`
|
||||
SendMessageImg string `json:"sendMessageImg"`
|
||||
ShowMessageCard bool `json:"showMessageCard"`
|
||||
GroupId string `json:"groupId"`
|
||||
GuildId string `json:"guildId"`
|
||||
PublicId string `json:"publicId"`
|
||||
Popup interface{} `json:"popup"`
|
||||
Drawer interface{} `json:"drawer"`
|
||||
ConfirmTitle string `json:"confirmTitle"`
|
||||
ConfirmText string `json:"confirmText"`
|
||||
ConfirmType string `json:"confirmType"`
|
||||
Api string `json:"api"`
|
||||
ApiType string `json:"apiType"`
|
||||
Reload string `json:"reload"`
|
||||
WithLoading bool `json:"withLoading"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "action"
|
||||
p.Size = "default"
|
||||
p.Type = "default"
|
||||
p.ApiType = "GET"
|
||||
|
||||
p.SetKey("action", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style map[string]interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置按钮文字
|
||||
func (p *Component) SetLabel(label string) *Component {
|
||||
p.Label = label
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 按钮的大小
|
||||
func (p *Component) SetSize(size string) *Component {
|
||||
p.Size = size
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 按钮的样式类型 primary | default | warn
|
||||
func (p *Component) SetType(actionType string) *Component {
|
||||
p.Type = actionType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 按钮是否镂空,背景色透明
|
||||
func (p *Component) SetPlain(plain bool) *Component {
|
||||
p.Plain = plain
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *Component) SetDisabled(disabled bool) *Component {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 名称前是否带 loading 图标
|
||||
func (p *Component) SetLoading(loading bool) *Component {
|
||||
p.Loading = loading
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件
|
||||
func (p *Component) SetFormType(formType string) *Component {
|
||||
p.FormType = formType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 开放能力
|
||||
// feedback 打开“意见反馈”页面,用户可提交反馈内容并上传日志 App、微信小程序、QQ小程序
|
||||
// share 触发用户转发 微信小程序、百度小程序、支付宝小程序、字节跳动小程序、飞书小程序、QQ小程序、快手小程序、京东小程序、360小程序
|
||||
// getUserInfo 获取用户信息,可以从@getuserinfo回调中获取到用户信息 微信小程序、百度小程序、QQ小程序、快手小程序、京东小程序、360小程序
|
||||
// contact 打开客服会话,如果用户在会话中点击消息卡片后返回应用,可以从 @contact 回调中获得具体信息 微信小程序、百度小程序、快手小程序
|
||||
// getPhoneNumber 获取用户手机号,可以从@getphonenumber回调中获取到用户信息 微信小程序、百度小程序、字节跳动小程序、支付宝小程序、快手小程序、京东小程序。App平台另见一键登陆(opens new window)
|
||||
// launchApp 小程序中打开APP,可以通过app-parameter属性设定向APP传的参数 微信小程序 (opens new window)、QQ小程序 (opens new window)、快手小程序、京东小程序
|
||||
// openSetting 打开授权设置页 微信小程序、QQ小程序、百度小程序、快手小程序、京东小程序、360小程序
|
||||
// chooseAvatar 获取用户头像,可以从@chooseavatar回调中获取到头像信息 微信小程序2.21.2版本+
|
||||
// uploadDouyinVideo 发布抖音视频 字节小程序2.65.0版本+
|
||||
// getAuthorize 支持小程序授权 支付宝小程序
|
||||
// lifestyle 关注生活号 支付宝小程序
|
||||
// contactShare 分享到通讯录好友 支付宝小程序基础库1.11.0版本+
|
||||
// openGroupProfile 呼起QQ群资料卡页面,可以通过group-id属性设定需要打开的群资料卡的群号,同时manifest.json中必须配置groupIdList QQ小程序基础库1.4.7版本+
|
||||
// openGuildProfile 呼起频道页面,可以通过guild-id属性设定需要打开的频道ID QQ小程序基础库1.46.8版本+
|
||||
// openPublicProfile 打开公众号资料卡,可以通过public-id属性设定需要打开的公众号资料卡的号码,同时manifest.json中必须配置publicIdList QQ小程序基础库1.12.0版本+
|
||||
// shareMessageToFriend 在自定义开放数据域组件中,向指定好友发起分享据 QQ小程序基础库1.17.0版本+
|
||||
// addFriend 添加好友, 对方需要通过该小程序进行授权,允许被加好友后才能调用成功用户授权 QQ小程序
|
||||
// addColorSign 添加彩签,点击后添加状态有用户提示,无回调 QQ小程序基础库1.10.0版本+
|
||||
// addGroupApp 添加群应用(只有管理员或群主有权操作),添加后给button绑定@addgroupapp事件接收回调数据 QQ小程序基础库1.16.0版本+
|
||||
// addToFavorites 收藏当前页面,点击按钮后会触发Page.onAddToFavorites方法 QQ小程序基础库1.19.0版本+
|
||||
// chooseAddress 选择用户收货地址,可以从@chooseaddress回调中获取到用户选择的地址信息 百度小程序3.160.3版本+
|
||||
// chooseInvoiceTitle 选择用户发票抬头,可以从@chooseinvoicetitle回调中获取到用户选择发票抬头信息 百度小程序3.160.3版本+
|
||||
// login 登录,可以从@login回调中确认是否登录成功 百度小程序3.230.1版本+
|
||||
// subscribe 订阅类模板消息,需要用户授权才可发送 百度小程序
|
||||
// favorite 触发用户收藏 快手小程序
|
||||
// watchLater 触发用户稍后再看 快手小程序
|
||||
// openProfile 触发打开用户主页 快手小程序
|
||||
// ajax
|
||||
// submit
|
||||
// popup
|
||||
// drawer
|
||||
// link
|
||||
func (p *Component) SetOpenType(openType string) *Component {
|
||||
p.OpenType = openType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
//指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果
|
||||
func (p *Component) SetHoverClass(hoverClass string) *Component {
|
||||
p.HoverClass = hoverClass
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 按住后多久出现点击态,单位毫秒
|
||||
func (p *Component) SetHoverStartTime(hoverStartTime int) *Component {
|
||||
p.HoverStartTime = hoverStartTime
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 手指松开后点击态保留时间,单位毫秒
|
||||
func (p *Component) SetHoverStayTime(hoverStayTime int) *Component {
|
||||
p.HoverStayTime = hoverStayTime
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序、QQ小程序:打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效
|
||||
func (p *Component) SetAppParameter(appParameter string) *Component {
|
||||
p.AppParameter = appParameter
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:指定是否阻止本节点的祖先节点出现点击态
|
||||
func (p *Component) SetHoverStopPropagation(hoverStopPropagation bool) *Component {
|
||||
p.HoverStopPropagation = hoverStopPropagation
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。
|
||||
func (p *Component) SetLang(lang string) *Component {
|
||||
p.Lang = lang
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:会话来源,open-type="contact"时有效
|
||||
func (p *Component) SetSessionFrom(sessionFrom string) *Component {
|
||||
p.SessionFrom = sessionFrom
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:会话内消息卡片标题,open-type="contact"时有效
|
||||
func (p *Component) SetSendMessageTitle(sendMessageTitle string) *Component {
|
||||
p.SendMessageTitle = sendMessageTitle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:会话内消息卡片点击跳转小程序路径,open-type="contact"时有效
|
||||
func (p *Component) SetSendMessagePath(sendMessagePath string) *Component {
|
||||
p.SendMessagePath = sendMessagePath
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:会话内消息卡片图片,open-type="contact"时有效
|
||||
func (p *Component) SetSendMessageImg(sendMessageImg string) *Component {
|
||||
p.SendMessageImg = sendMessageImg
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 微信小程序:是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效
|
||||
func (p *Component) SetShowMessageCard(showMessageCard bool) *Component {
|
||||
p.ShowMessageCard = showMessageCard
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// QQ小程序:打开群资料卡时,传递的群号
|
||||
func (p *Component) SetGroupId(groupId string) *Component {
|
||||
p.GroupId = groupId
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// QQ小程序:打开频道页面时,传递的频道号
|
||||
func (p *Component) SetGuildId(guildId string) *Component {
|
||||
p.GuildId = guildId
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// QQ小程序:打开公众号资料卡时,传递的号码
|
||||
func (p *Component) SetPublicId(publicId string) *Component {
|
||||
p.PublicId = publicId
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 弹出层
|
||||
func (p *Component) SetPopup(callback interface{}) *Component {
|
||||
popup := (&Popup{}).Init()
|
||||
getCallback := callback.(func(popup *Popup) interface{})
|
||||
|
||||
p.Popup = getCallback(popup)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 抽屉
|
||||
func (p *Component) SetDrawer(callback interface{}) *Component {
|
||||
drawer := (&Drawer{}).Init()
|
||||
getCallback := callback.(func(drawer *Drawer) interface{})
|
||||
|
||||
p.Drawer = getCallback(drawer)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置行为前的确认操作
|
||||
func (p *Component) SetWithConfirm(title string, text string, confirmType string) *Component {
|
||||
p.ConfirmTitle = title
|
||||
p.ConfirmText = text
|
||||
p.ConfirmType = confirmType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 执行行为的接口链接
|
||||
func (p *Component) SetApi(api string) *Component {
|
||||
p.Api = api
|
||||
p.OpenType = "ajax"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 执行行为的方法,GET/POST
|
||||
func (p *Component) SetApiType(apiType string) *Component {
|
||||
p.ApiType = apiType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 执行成功后刷新的组件
|
||||
func (p *Component) SetReload(reload string) *Component {
|
||||
p.Reload = reload
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否具有loading
|
||||
func (p *Component) SetWithLoading(loading bool) *Component {
|
||||
p.WithLoading = loading
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "action"
|
||||
|
||||
return p
|
||||
}
|
66
pkg/component/mix/action/drawer.go
Normal file
66
pkg/component/mix/action/drawer.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package action
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Drawer struct {
|
||||
component.Element
|
||||
Mask bool `json:"mask"`
|
||||
MaskClick bool `json:"maskClick"`
|
||||
Mode string `json:"mode"`
|
||||
Width int `json:"width"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Drawer) Init() *Drawer {
|
||||
p.Component = "drawer"
|
||||
p.SetKey("drawer", component.DEFAULT_CRYPT)
|
||||
p.Mask = true
|
||||
p.MaskClick = true
|
||||
p.Mode = "left"
|
||||
p.Width = 220
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Drawer) SetStyle(style map[string]interface{}) *Drawer {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示遮罩
|
||||
func (p *Drawer) SetMask(mask bool) *Drawer {
|
||||
p.Mask = mask
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 点击遮罩是否可以关闭抽屉
|
||||
func (p *Drawer) SetMaskClick(maskClick bool) *Drawer {
|
||||
p.MaskClick = maskClick
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Drawer滑出位置,可选值:left(从左侧滑出), right(从右侧滑出)
|
||||
func (p *Drawer) SetMode(mode string) *Drawer {
|
||||
p.Mode = mode
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Drawer 宽度,仅vue页面设置生效
|
||||
func (p *Drawer) SetWidth(width int) *Drawer {
|
||||
p.Width = width
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 容器控件里面的内容
|
||||
func (p *Drawer) SetBody(body interface{}) *Drawer {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
184
pkg/component/mix/action/popup.go
Normal file
184
pkg/component/mix/action/popup.go
Normal file
@@ -0,0 +1,184 @@
|
||||
package action
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Popup struct {
|
||||
component.Element
|
||||
Animation bool `json:"animation"`
|
||||
Type string `json:"type"`
|
||||
IsMaskClick bool `json:"isMaskClick"`
|
||||
MaskBackgroundColor string `json:"maskBackgroundColor"`
|
||||
BackgroundColor string `json:"backgroundColor"`
|
||||
SafeArea bool `json:"safeArea"`
|
||||
MessageType string `json:"messageType"`
|
||||
MessageDuration int `json:"messageDuration"`
|
||||
DialogType string `json:"dialogType"`
|
||||
DialogMode string `json:"dialogMode"`
|
||||
DialogTitle string `json:"dialogTitle"`
|
||||
DialogConfirmText string `json:"dialogConfirmText"`
|
||||
DialogCancelText string `json:"dialogCancelText"`
|
||||
DialogValue interface{} `json:"dialogValue"`
|
||||
DialogPlaceholder string `json:"dialogPlaceholder"`
|
||||
DialogBeforeClose bool `json:"dialogBeforeClose"`
|
||||
ShareTitle string `json:"shareTitle"`
|
||||
ShareBeforeClose bool `json:"ShareBeforeClose"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Popup) Init() *Popup {
|
||||
p.Component = "popup"
|
||||
p.SetKey("popup", component.DEFAULT_CRYPT)
|
||||
p.Animation = true
|
||||
p.Type = "center"
|
||||
p.IsMaskClick = true
|
||||
p.MaskBackgroundColor = "rgba(0,0,0,0.4)"
|
||||
p.BackgroundColor = "#fff"
|
||||
p.SafeArea = true
|
||||
p.MessageType = "success"
|
||||
p.MessageDuration = 3000
|
||||
p.DialogType = "success"
|
||||
p.DialogMode = "base"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Popup) SetStyle(style map[string]interface{}) *Popup {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否开启动画
|
||||
func (p *Popup) SetAnimation(animation bool) *Popup {
|
||||
p.Animation = animation
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 弹出方式,top:顶部弹出,center:居中弹出,bottom:底部弹出,left:左侧弹出,right:右侧弹出,message:消息提示,dialog:对话框,share:底部弹出分享示例
|
||||
func (p *Popup) SetType(popupType string) *Popup {
|
||||
p.Type = popupType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 容器控件里面的内容
|
||||
func (p *Popup) SetBody(body interface{}) *Popup {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 蒙版点击是否关闭弹窗
|
||||
func (p *Popup) SetIsMaskClick(isMaskClick bool) *Popup {
|
||||
p.IsMaskClick = isMaskClick
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 蒙版颜色,建议使用 rgba 颜色值,rgba(0,0,0,0.4)
|
||||
func (p *Popup) SetMaskBackgroundColor(maskBackgroundColor string) *Popup {
|
||||
p.MaskBackgroundColor = maskBackgroundColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 主窗口背景色
|
||||
func (p *Popup) SetBackgroundColor(backgroundColor string) *Popup {
|
||||
p.BackgroundColor = backgroundColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否适配底部安全区
|
||||
func (p *Popup) SetSafeArea(safeArea bool) *Popup {
|
||||
p.SafeArea = safeArea
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 消息提示主题,success成功,warn警告,error失败,info消息
|
||||
func (p *Popup) SetMessageType(messageType string) *Popup {
|
||||
p.MessageType = messageType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 消息显示时间,超过显示时间组件自动关闭,设置为0 将不会关闭,需手动调用 close 方法关闭
|
||||
func (p *Popup) SetMessageDuration(messageDuration int) *Popup {
|
||||
p.MessageDuration = messageDuration
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 对话框标题主题,可选值: success/warn/info/error
|
||||
func (p *Popup) SetDialogType(dialogType string) *Popup {
|
||||
p.DialogType = dialogType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 对话框模式,可选值:base(提示对话框)/input(可输入对话框)
|
||||
func (p *Popup) SetDialogMode(dialogMode string) *Popup {
|
||||
p.DialogMode = dialogMode
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 对话框标题
|
||||
func (p *Popup) SetDialogTitle(dialogTitle string) *Popup {
|
||||
p.DialogTitle = dialogTitle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 定义确定按钮文本
|
||||
func (p *Popup) SetDialogConfirmText(dialogConfirmText string) *Popup {
|
||||
p.DialogConfirmText = dialogConfirmText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 定义取消按钮文本
|
||||
func (p *Popup) SetDialogCancelText(dialogCancelText string) *Popup {
|
||||
p.DialogCancelText = dialogCancelText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框默认值,input模式下生效
|
||||
func (p *Popup) SetDialogValue(dialogValue interface{}) *Popup {
|
||||
p.DialogValue = dialogValue
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框提示文字,input模式下生效
|
||||
func (p *Popup) SetDialogPlaceholder(dialogPlaceholder string) *Popup {
|
||||
p.DialogPlaceholder = dialogPlaceholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否拦截按钮事件,如为true,则不会关闭对话框,关闭需要手动执行 uni-popup 的 close 方法
|
||||
func (p *Popup) SetDialogBeforeClose(dialogBeforeClose bool) *Popup {
|
||||
p.DialogBeforeClose = dialogBeforeClose
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 分享弹窗标题
|
||||
func (p *Popup) SetShareTitle(shareTitle string) *Popup {
|
||||
p.ShareTitle = shareTitle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否拦截按钮事件,如为true,则不会关闭对话框,关闭需要手动执行 uni-popup 的 close 方法
|
||||
func (p *Popup) SetShareBeforeClose(shareBeforeClose bool) *Popup {
|
||||
p.ShareBeforeClose = shareBeforeClose
|
||||
|
||||
return p
|
||||
}
|
130
pkg/component/mix/card/card.go
Normal file
130
pkg/component/mix/card/card.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package card
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
SubTitle string `json:"subTitle"`
|
||||
Extra string `json:"extra"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Cover string `json:"cover"`
|
||||
IsFull bool `json:"isFull"`
|
||||
IsShadow bool `json:"isShadow"`
|
||||
Shadow string `json:"shadow"`
|
||||
Border bool `json:"border"`
|
||||
Margin string `json:"margin"`
|
||||
Spacing string `json:"spacing"`
|
||||
Padding string `json:"padding"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "card"
|
||||
p.SetKey("card", component.DEFAULT_CRYPT)
|
||||
p.Shadow = "0px 0px 3px 1px rgba(0, 0, 0, 0.08)"
|
||||
p.Border = true
|
||||
p.Margin = "10px"
|
||||
p.Spacing = "10px"
|
||||
p.Padding = "10px"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *Component) SetTitle(title string) *Component {
|
||||
p.Title = title
|
||||
return p
|
||||
}
|
||||
|
||||
// 子标题
|
||||
func (p *Component) SetSubTitle(subTitle string) *Component {
|
||||
p.SubTitle = subTitle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 额外信息
|
||||
func (p *Component) SetExtra(extra string) *Component {
|
||||
p.Extra = extra
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 略缩图
|
||||
func (p *Component) SetThumbnail(thumbnail string) *Component {
|
||||
p.Thumbnail = thumbnail
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 封面图
|
||||
func (p *Component) SetCover(cover string) *Component {
|
||||
p.Cover = cover
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片内容是否通栏,为true时将去除padding值
|
||||
func (p *Component) SetIsFull(isFull bool) *Component {
|
||||
p.IsFull = isFull
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片阴影,需符合 css 值,0px 0px 3px 1px rgba(0, 0, 0, 0.08)
|
||||
func (p *Component) SetShadow(shadow string) *Component {
|
||||
p.Shadow = shadow
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片边框
|
||||
func (p *Component) SetBorder(border bool) *Component {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片外边距
|
||||
func (p *Component) SetMargin(margin string) *Component {
|
||||
p.Margin = margin
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片内边距
|
||||
func (p *Component) SetSpacing(spacing string) *Component {
|
||||
p.Spacing = spacing
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片内容内边距
|
||||
func (p *Component) SetPadding(padding string) *Component {
|
||||
p.Padding = padding
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "card"
|
||||
|
||||
return p
|
||||
}
|
45
pkg/component/mix/collapse/collapse.go
Normal file
45
pkg/component/mix/collapse/collapse.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package collapse
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Accordion bool `json:"accordion"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "collapse"
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示边框
|
||||
func (p *Component) SetAccordion(accordion bool) *Component {
|
||||
p.Accordion = accordion
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "collapse"
|
||||
|
||||
return p
|
||||
}
|
101
pkg/component/mix/collapse/item.go
Normal file
101
pkg/component/mix/collapse/item.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package collapse
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type CollapseItem struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
Thumb string `json:"thumb"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Open bool `json:"open"`
|
||||
ShowAnimation bool `json:"showAnimation"`
|
||||
Border bool `json:"border"`
|
||||
TitleBorder string `json:"titleBorder"`
|
||||
ShowArrow bool `json:"showArrow"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *CollapseItem) Init() *CollapseItem {
|
||||
p.Component = "collapseItem"
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *CollapseItem) SetStyle(style interface{}) *CollapseItem {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题文字
|
||||
func (p *CollapseItem) SetTitle(title string) *CollapseItem {
|
||||
p.Title = title
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题左侧缩略图
|
||||
func (p *CollapseItem) SetThumb(thumb string) *CollapseItem {
|
||||
p.Thumb = thumb
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *CollapseItem) SetDisabled(disabled bool) *CollapseItem {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否展开面板
|
||||
func (p *CollapseItem) SetOpen(open bool) *CollapseItem {
|
||||
p.Open = open
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 开启动画
|
||||
func (p *CollapseItem) SetShowAnimation(showAnimation bool) *CollapseItem {
|
||||
p.ShowAnimation = showAnimation
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 折叠面板内容分隔线
|
||||
func (p *CollapseItem) SetBorder(border bool) *CollapseItem {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 折叠面板标题分隔线可选值见下方 TitleBorder Params
|
||||
func (p *CollapseItem) SetTitleBorder(titleBorder string) *CollapseItem {
|
||||
p.TitleBorder = titleBorder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示右侧箭头
|
||||
func (p *CollapseItem) SetShowArrow(showArrow bool) *CollapseItem {
|
||||
p.ShowArrow = showArrow
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *CollapseItem) SetBody(body interface{}) *CollapseItem {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *CollapseItem) JsonSerialize() *CollapseItem {
|
||||
p.Component = "collapseItem"
|
||||
|
||||
return p
|
||||
}
|
37
pkg/component/mix/component/element.go
Normal file
37
pkg/component/mix/component/element.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/go-basic/uuid"
|
||||
)
|
||||
|
||||
type Element struct {
|
||||
Key string `json:"key"`
|
||||
ComponentKey string `json:"componentKey"`
|
||||
Component string `json:"component"`
|
||||
Style interface{} `json:"style"`
|
||||
}
|
||||
|
||||
const DEFAULT_KEY = ""
|
||||
const DEFAULT_CRYPT = true
|
||||
|
||||
// 设置Key
|
||||
func (p *Element) SetKey(key string, crypt bool) *Element {
|
||||
|
||||
if key == "" {
|
||||
key = uuid.New()
|
||||
}
|
||||
|
||||
if crypt {
|
||||
h := md5.New()
|
||||
h.Write([]byte(key))
|
||||
key = hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
p.Key = key
|
||||
p.ComponentKey = key
|
||||
|
||||
return p
|
||||
}
|
130
pkg/component/mix/form/field.go
Normal file
130
pkg/component/mix/form/field.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package form
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
"github.com/quarkcms/quark-go/pkg/component/mix/form/fields"
|
||||
)
|
||||
|
||||
type Field struct {
|
||||
component.Element
|
||||
Api string `json:"api"`
|
||||
Model interface{} `json:"model"`
|
||||
Rules interface{} `json:"rules"`
|
||||
ValidateTrigger string `json:"validateTrigger"`
|
||||
LabelPosition string `json:"labelPosition"`
|
||||
LabelWidth int `json:"labelWidth"`
|
||||
LabelAlign string `json:"labelAlign"`
|
||||
ErrShowType string `json:"errShowType"`
|
||||
Border bool `json:"border"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 增强输入框
|
||||
func (p *Field) EasyInput(params ...interface{}) *fields.EasyInput {
|
||||
field := (&fields.EasyInput{}).Init()
|
||||
|
||||
placeholder := reflect.
|
||||
ValueOf(field).
|
||||
Elem().
|
||||
FieldByName("Placeholder").String()
|
||||
|
||||
if placeholder == "" {
|
||||
field.SetPlaceholder("请输入" + params[1].(string))
|
||||
}
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 数据选择器
|
||||
func (p *Field) DataCheckbox(params ...interface{}) *fields.DataCheckbox {
|
||||
field := (&fields.DataCheckbox{}).Init()
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 级联选择器
|
||||
func (p *Field) DataPicker(params ...interface{}) *fields.DataPicker {
|
||||
field := (&fields.DataPicker{}).Init().SetPopupTitle("请选择" + params[1].(string))
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 级联选择器
|
||||
func (p *Field) DatetimePicker(params ...interface{}) *fields.DatetimePicker {
|
||||
field := (&fields.DatetimePicker{}).Init().SetPlaceholder("请选择" + params[1].(string))
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 输入框
|
||||
func (p *Field) Input(params ...interface{}) *fields.Input {
|
||||
field := (&fields.Input{}).Init()
|
||||
|
||||
placeholder := reflect.
|
||||
ValueOf(field).
|
||||
Elem().
|
||||
FieldByName("Placeholder").String()
|
||||
|
||||
if placeholder == "" {
|
||||
field.SetPlaceholder("请输入" + params[1].(string))
|
||||
}
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 多选框
|
||||
func (p *Field) Checkbox(params ...interface{}) *fields.Checkbox {
|
||||
field := (&fields.Checkbox{}).Init()
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 单选框
|
||||
func (p *Field) Radio(params ...interface{}) *fields.Radio {
|
||||
field := (&fields.Radio{}).Init()
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 开关选择器
|
||||
func (p *Field) Switch(params ...interface{}) *fields.Switch {
|
||||
field := (&fields.Switch{}).Init()
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 滑动选择器
|
||||
func (p *Field) Slider(params ...interface{}) *fields.Slider {
|
||||
field := (&fields.Slider{}).Init()
|
||||
|
||||
field.SetName(params[0].(string)).SetLabel(params[1].(string))
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 从底部弹起的滚动选择器
|
||||
func (p *Field) Picker(name string, label string, pickerRange []interface{}) *fields.Picker {
|
||||
field := (&fields.Picker{}).Init().SetRange(pickerRange)
|
||||
|
||||
field.SetName(name).SetLabel(label)
|
||||
|
||||
return field
|
||||
}
|
78
pkg/component/mix/form/fields/checkbox.go
Normal file
78
pkg/component/mix/form/fields/checkbox.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Checkbox struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Checked bool `json:"checked"`
|
||||
Color string `json:"color"`
|
||||
Options interface{} `json:"options"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Checkbox) Init() *Checkbox {
|
||||
p.Component = "checkboxField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 默认值
|
||||
func (p *Checkbox) SetValue(value []interface{}) *Checkbox {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 本地渲染数据
|
||||
func (p *Checkbox) SetDisabled(disabled bool) *Checkbox {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 本地渲染数据
|
||||
func (p *Checkbox) SetChecked(checked bool) *Checkbox {
|
||||
p.Checked = checked
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// list 列表模式下 icon 显示的位置
|
||||
func (p *Checkbox) SetColor(color string) *Checkbox {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置单选属性,[]map[string]interface{}{{"text": "Title1","value": "value1"},{"text": "Title2","value": "value2"}}
|
||||
// 或者 map[interface{}]interface{}{"value1":"Title1","value2":"Title2"}
|
||||
func (p *Checkbox) SetOptions(options interface{}) *Checkbox {
|
||||
var data []map[string]interface{}
|
||||
|
||||
if mapOptions, ok := options.(map[interface{}]interface{}); ok {
|
||||
for k, v := range mapOptions {
|
||||
option := map[string]interface{}{
|
||||
"text": v,
|
||||
"value": k,
|
||||
}
|
||||
|
||||
data = append(data, option)
|
||||
}
|
||||
} else if sliceOptions, ok := options.([]map[string]interface{}); ok {
|
||||
data = sliceOptions
|
||||
}
|
||||
|
||||
p.Options = data
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Checkbox) JsonSerialize() *Checkbox {
|
||||
p.Component = "checkboxField"
|
||||
|
||||
return p
|
||||
}
|
127
pkg/component/mix/form/fields/datacheckbox.go
Normal file
127
pkg/component/mix/form/fields/datacheckbox.go
Normal file
@@ -0,0 +1,127 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type DataCheckbox struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Localdata interface{} `json:"localdata"`
|
||||
Mode string `json:"mode"`
|
||||
Multiple bool `json:"multiple"`
|
||||
Min interface{} `json:"min"`
|
||||
Max interface{} `json:"max"`
|
||||
Wrap bool `json:"wrap"`
|
||||
Icon string `json:"icon"`
|
||||
SelectedColor string `json:"selectedColor"`
|
||||
SelectedTextColor string `json:"selectedTextColor"`
|
||||
EmptyText string `json:"emptyText"`
|
||||
Map interface{} `json:"map"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *DataCheckbox) Init() *DataCheckbox {
|
||||
p.Component = "dataCheckboxField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Mode = "default"
|
||||
p.Icon = "left"
|
||||
p.SelectedColor = "#007aff"
|
||||
p.SelectedTextColor = "#333"
|
||||
p.EmptyText = "暂无数据"
|
||||
p.Map = map[string]string{
|
||||
"text": "text",
|
||||
"value": "value",
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 默认值,multiple=true时为 Array类型,否则为 String或Number类型
|
||||
func (p *DataCheckbox) SetValue(value interface{}) *DataCheckbox {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 本地渲染数据
|
||||
func (p *DataCheckbox) SetLocaldata(localdata interface{}) *DataCheckbox {
|
||||
p.Localdata = localdata
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 显示模式
|
||||
func (p *DataCheckbox) SetMode(mode string) *DataCheckbox {
|
||||
p.Mode = mode
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否多选
|
||||
func (p *DataCheckbox) SetMultiple(multiple bool) *DataCheckbox {
|
||||
p.Multiple = multiple
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最小选择个数 ,multiple为true时生效
|
||||
func (p *DataCheckbox) SetMin(min interface{}) *DataCheckbox {
|
||||
p.Min = min
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最大选择个数 ,multiple为true时生效
|
||||
func (p *DataCheckbox) SetMax(max interface{}) *DataCheckbox {
|
||||
p.Max = max
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否换行显示
|
||||
func (p *DataCheckbox) SetWrap(wrap bool) *DataCheckbox {
|
||||
p.Wrap = wrap
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// list 列表模式下 icon 显示的位置
|
||||
func (p *DataCheckbox) SetIcon(icon string) *DataCheckbox {
|
||||
p.Icon = icon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 选中颜色
|
||||
func (p *DataCheckbox) SetSelectedColor(selectedColor string) *DataCheckbox {
|
||||
p.SelectedColor = selectedColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 选中文本颜色,如不填写则自动显示
|
||||
func (p *DataCheckbox) SetSelectedTextColor(selectedTextColor string) *DataCheckbox {
|
||||
p.SelectedTextColor = selectedTextColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 没有数据时显示的文字 ,本地数据无效
|
||||
func (p *DataCheckbox) SetEmptyText(emptyText string) *DataCheckbox {
|
||||
p.EmptyText = emptyText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 字段映射,将text/value映射到数据中的其他字段
|
||||
func (p *DataCheckbox) SetMap(dataCheckboxMap interface{}) *DataCheckbox {
|
||||
p.Map = dataCheckboxMap
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *DataCheckbox) JsonSerialize() *DataCheckbox {
|
||||
p.Component = "dataCheckboxField"
|
||||
|
||||
return p
|
||||
}
|
92
pkg/component/mix/form/fields/datapicker.go
Normal file
92
pkg/component/mix/form/fields/datapicker.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type DataPicker struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Localdata interface{} `json:"localdata"`
|
||||
Preload bool `json:"preload"`
|
||||
Readonly bool `json:"readonly"`
|
||||
ClearIcon bool `json:"clearIcon"`
|
||||
Ellipsis bool `json:"ellipsis"`
|
||||
PopupTitle string `json:"popupTitle"`
|
||||
Map interface{} `json:"map"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *DataPicker) Init() *DataPicker {
|
||||
p.Component = "dataPickerField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.ClearIcon = true
|
||||
p.Ellipsis = true
|
||||
p.Map = map[string]string{
|
||||
"text": "text",
|
||||
"value": "value",
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 绑定数据
|
||||
func (p *DataPicker) SetValue(value interface{}) *DataPicker {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 数据
|
||||
func (p *DataPicker) SetLocaldata(localdata interface{}) *DataPicker {
|
||||
p.Localdata = localdata
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 预加载数据
|
||||
func (p *DataPicker) SetPreload(preload bool) *DataPicker {
|
||||
p.Preload = preload
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *DataPicker) SetReadonly(readonly bool) *DataPicker {
|
||||
p.Readonly = readonly
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示清除按钮
|
||||
func (p *DataPicker) SetClearIcon(clearIcon bool) *DataPicker {
|
||||
p.ClearIcon = clearIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否隐藏 tab 标签过长的文本
|
||||
func (p *DataPicker) SetEllipsis(ellipsis bool) *DataPicker {
|
||||
p.Ellipsis = ellipsis
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 弹出层标题
|
||||
func (p *DataPicker) SetPopupTitle(popupTitle string) *DataPicker {
|
||||
p.PopupTitle = popupTitle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 字段映射,将text/value映射到数据中的其他字段
|
||||
func (p *DataPicker) SetMap(dataCheckboxMap interface{}) *DataPicker {
|
||||
p.Map = dataCheckboxMap
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *DataPicker) JsonSerialize() *DataPicker {
|
||||
p.Component = "dataPickerField"
|
||||
|
||||
return p
|
||||
}
|
72
pkg/component/mix/form/fields/dataselect.go
Normal file
72
pkg/component/mix/form/fields/dataselect.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type DataSelect struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Localdata interface{} `json:"localdata"`
|
||||
Clear bool `json:"clear"`
|
||||
Label string `json:"label"`
|
||||
Placeholder string `json:"placeholder"`
|
||||
EmptyText string `json:"emptyText"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *DataSelect) Init() *DataSelect {
|
||||
p.Component = "dataSelectField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Placeholder = "请选择"
|
||||
p.EmptyText = "暂无数据 "
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 已选择数据的 value 值
|
||||
func (p *DataSelect) SetValue(value interface{}) *DataSelect {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 本地渲染数据
|
||||
func (p *DataSelect) SetLocaldata(localdata interface{}) *DataSelect {
|
||||
p.Localdata = localdata
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否可以清空已选项
|
||||
func (p *DataSelect) SetClear(clear bool) *DataSelect {
|
||||
p.Clear = clear
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 左侧标题
|
||||
func (p *DataSelect) SetLabel(label string) *DataSelect {
|
||||
p.Label = label
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框的提示文字
|
||||
func (p *DataSelect) SetPlaceholder(placeholder string) *DataSelect {
|
||||
p.Placeholder = placeholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 没有数据时显示的文字 ,本地数据无效
|
||||
func (p *DataSelect) SetEmptyText(emptyText string) *DataSelect {
|
||||
p.EmptyText = emptyText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *DataSelect) JsonSerialize() *DataSelect {
|
||||
p.Component = "dataSelectField"
|
||||
|
||||
return p
|
||||
}
|
134
pkg/component/mix/form/fields/datetimepicker.go
Normal file
134
pkg/component/mix/form/fields/datetimepicker.go
Normal file
@@ -0,0 +1,134 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type DatetimePicker struct {
|
||||
Item
|
||||
Type interface{} `json:"type"`
|
||||
Value interface{} `json:"value"`
|
||||
Start interface{} `json:"start"`
|
||||
End interface{} `json:"end"`
|
||||
ReturnType string `json:"returnType"`
|
||||
Border bool `json:"border"`
|
||||
RangeSeparator string `json:"rangeSeparator"`
|
||||
Placeholder string `json:"placeholder"`
|
||||
StartPlaceholder string `json:"startPlaceholder"`
|
||||
EndPlaceholder string `json:"endPlaceholder"`
|
||||
Disabled bool `json:"disabled"`
|
||||
ClearIcon bool `json:"clearIcon"`
|
||||
HideSecond bool `json:"hideSecond"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *DatetimePicker) Init() *DatetimePicker {
|
||||
p.Component = "datetimePickerField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Type = "datetime"
|
||||
p.ReturnType = "string"
|
||||
p.Border = true
|
||||
p.RangeSeparator = "-"
|
||||
p.Placeholder = "-"
|
||||
p.StartPlaceholder = "-"
|
||||
p.EndPlaceholder = "-"
|
||||
p.ClearIcon = true
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 已选择数据的 value 值
|
||||
func (p *DatetimePicker) SetValue(value interface{}) *DatetimePicker {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 选择器类型
|
||||
func (p *DatetimePicker) SetType(pickerType interface{}) *DatetimePicker {
|
||||
p.Type = pickerType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最小值,可以使用日期的字符串(String)、时间戳(Number)
|
||||
func (p *DatetimePicker) SetStart(start bool) *DatetimePicker {
|
||||
p.Start = start
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最大值,可以使用日期的字符串(String)、时间戳(Number)
|
||||
func (p *DatetimePicker) SetEnd(end string) *DatetimePicker {
|
||||
p.End = end
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 返回值格式
|
||||
func (p *DatetimePicker) SetReturnType(returnType string) *DatetimePicker {
|
||||
p.ReturnType = returnType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否有边框
|
||||
func (p *DatetimePicker) SetBorder(border bool) *DatetimePicker {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 选择范围时的分隔符
|
||||
func (p *DatetimePicker) SetRangeSeparator(rangeSeparator string) *DatetimePicker {
|
||||
p.RangeSeparator = rangeSeparator
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 非范围选择时的占位内容
|
||||
func (p *DatetimePicker) SetPlaceholder(placeholder string) *DatetimePicker {
|
||||
p.Placeholder = placeholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 范围选择时开始日期的占位内容
|
||||
func (p *DatetimePicker) SetStartPlaceholder(startPlaceholder string) *DatetimePicker {
|
||||
p.StartPlaceholder = startPlaceholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 范围选择时结束日期的占位内容
|
||||
func (p *DatetimePicker) SetEndPlaceholder(endPlaceholder string) *DatetimePicker {
|
||||
p.EndPlaceholder = endPlaceholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否不可选择
|
||||
func (p *DatetimePicker) SetDisabled(disabled bool) *DatetimePicker {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示清除按钮
|
||||
func (p *DatetimePicker) SetClearIcon(clearIcon bool) *DatetimePicker {
|
||||
p.ClearIcon = clearIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示秒,只显示时分
|
||||
func (p *DatetimePicker) SetHideSecond(hideSecond bool) *DatetimePicker {
|
||||
p.HideSecond = hideSecond
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *DatetimePicker) JsonSerialize() *DatetimePicker {
|
||||
p.Component = "datetimePickerField"
|
||||
|
||||
return p
|
||||
}
|
341
pkg/component/mix/form/fields/easyinput.go
Normal file
341
pkg/component/mix/form/fields/easyinput.go
Normal file
@@ -0,0 +1,341 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type EasyInput struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Type string `json:"type"`
|
||||
Password bool `json:"password"`
|
||||
Placeholder string `json:"placeholder"`
|
||||
PlaceholderStyle string `json:"placeholderStyle"`
|
||||
PlaceholderClass string `json:"placeholderClass"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Maxlength int `json:"maxlength"`
|
||||
CursorSpacing int `json:"cursorSpacing"`
|
||||
Focus bool `json:"focus"`
|
||||
ConfirmType string `json:"confirmType"`
|
||||
ConfirmHold bool `json:"confirmHold"`
|
||||
Cursor int `json:"cursor"`
|
||||
SelectionStart int `json:"selectionStart"`
|
||||
SelectionEnd int `json:"selectionEnd"`
|
||||
AdjustPosition bool `json:"adjustPosition"`
|
||||
AutoBlur bool `json:"autoBlur"`
|
||||
IgnoreCompositionEvent bool `json:"ignoreCompositionEvent"`
|
||||
AlwaysEmbed bool `json:"alwaysEmbed"`
|
||||
HoldKeyboard bool `json:"holdKeyboard"`
|
||||
SafePasswordCertPath string `json:"safePasswordCertPath"`
|
||||
SafePasswordLength int `json:"safePasswordLength"`
|
||||
SafePasswordTimeStamp int `json:"safePasswordTimeStamp"`
|
||||
SafePasswordNonce string `json:"safePasswordNonce"`
|
||||
SafePasswordSalt string `json:"safePasswordSalt"`
|
||||
SafePasswordCustomHash string `json:"safePasswordCustomHash"`
|
||||
RandomNumber bool `json:"randomNumber"`
|
||||
Controlled bool `json:"controlled"`
|
||||
AlwaysSystem bool `json:"alwaysSystem"`
|
||||
Clearable bool `json:"clearable"`
|
||||
AutoHeight bool `json:"autoHeight"`
|
||||
ClearSize int `json:"clearSize"`
|
||||
PrefixIcon string `json:"prefixIcon"`
|
||||
SuffixIcon string `json:"suffixIcon"`
|
||||
Trim interface{} `json:"trim"`
|
||||
InputBorder bool `json:"inputBorder"`
|
||||
Styles interface{} `json:"styles"`
|
||||
PasswordIcon bool `json:"passwordIcon"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *EasyInput) Init() *EasyInput {
|
||||
p.Component = "easyInputField"
|
||||
p.Type = "text"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.PlaceholderClass = "input-placeholder"
|
||||
p.Maxlength = 140
|
||||
p.ConfirmType = "done"
|
||||
p.SelectionStart = -1
|
||||
p.SelectionEnd = -1
|
||||
p.AdjustPosition = true
|
||||
p.IgnoreCompositionEvent = true
|
||||
p.InputBorder = true
|
||||
p.PasswordIcon = true
|
||||
p.Styles = map[string]string{
|
||||
"color": "#333",
|
||||
"disableColor": "#eee",
|
||||
"borderColor": "#e5e5e5",
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框的初始内容
|
||||
func (p *EasyInput) SetValue(value interface{}) *EasyInput {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// input 的类型
|
||||
func (p *EasyInput) SetType(textType string) *EasyInput {
|
||||
p.Type = textType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否是密码类型
|
||||
func (p *EasyInput) SetPassword(password bool) *EasyInput {
|
||||
p.Password = password
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框为空时占位符
|
||||
func (p *EasyInput) SetPlaceholder(placeholder string) *EasyInput {
|
||||
p.Placeholder = placeholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定 placeholder 的样式
|
||||
func (p *EasyInput) SetPlaceholderStyle(placeholderStyle string) *EasyInput {
|
||||
p.PlaceholderStyle = placeholderStyle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定 placeholder 的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
|
||||
func (p *EasyInput) SetPlaceholderClass(placeholderClass string) *EasyInput {
|
||||
p.PlaceholderClass = placeholderClass
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *EasyInput) SetDisabled(disabled bool) *EasyInput {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最大输入长度,设置为 -1 的时候不限制最大长度
|
||||
func (p *EasyInput) SetMaxlength(maxlength int) *EasyInput {
|
||||
p.Maxlength = maxlength
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定光标与键盘的距离,单位 px 。取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离
|
||||
func (p *EasyInput) SetCursorSpacing(cursorSpacing int) *EasyInput {
|
||||
p.CursorSpacing = cursorSpacing
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 获取焦点
|
||||
func (p *EasyInput) SetFocus(focus bool) *EasyInput {
|
||||
p.Focus = focus
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置键盘右下角按钮的文字,仅在 type="text" 时生效。
|
||||
func (p *EasyInput) SetConfirmType(confirmType string) *EasyInput {
|
||||
p.ConfirmType = confirmType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 点击键盘右下角按钮时是否保持键盘不收起
|
||||
func (p *EasyInput) SetConfirmHold(confirmHold bool) *EasyInput {
|
||||
p.ConfirmHold = confirmHold
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定focus时的光标位置
|
||||
func (p *EasyInput) SetCursor(cursor int) *EasyInput {
|
||||
p.Cursor = cursor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 光标起始位置,自动聚集时有效,需与selection-end搭配使用
|
||||
func (p *EasyInput) SetSelectionStart(selectionStart int) *EasyInput {
|
||||
p.SelectionStart = selectionStart
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 光标结束位置,自动聚集时有效,需与selection-start搭配使用
|
||||
func (p *EasyInput) SetSelectionEnd(selectionEnd int) *EasyInput {
|
||||
p.SelectionEnd = selectionEnd
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 键盘弹起时,是否自动上推页面
|
||||
func (p *EasyInput) SetAdjustPosition(adjustPosition bool) *EasyInput {
|
||||
p.AdjustPosition = adjustPosition
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 键盘收起时,是否自动失去焦点
|
||||
func (p *EasyInput) SetAutoBlur(autoBlur bool) *EasyInput {
|
||||
p.AutoBlur = autoBlur
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否忽略组件内对文本合成系统事件的处理。为 false 时将触发 compositionstart、compositionend、compositionupdate 事件,且在文本合成期间会触发 input 事件
|
||||
func (p *EasyInput) SetIgnoreCompositionEvent(ignoreCompositionEvent bool) *EasyInput {
|
||||
p.IgnoreCompositionEvent = ignoreCompositionEvent
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效)
|
||||
func (p *EasyInput) SetAlwaysEmbed(alwaysEmbed bool) *EasyInput {
|
||||
p.AlwaysEmbed = alwaysEmbed
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// focus时,点击页面的时候不收起键盘
|
||||
func (p *EasyInput) SetHoldKeyboard(holdKeyboard bool) *EasyInput {
|
||||
p.HoldKeyboard = holdKeyboard
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘加密公钥的路径,只支持包内路径
|
||||
func (p *EasyInput) SetSafePasswordCertPath(safePasswordCertPath string) *EasyInput {
|
||||
p.SafePasswordCertPath = safePasswordCertPath
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘输入密码长度
|
||||
func (p *EasyInput) SetSafePasswordLength(safePasswordLength int) *EasyInput {
|
||||
p.SafePasswordLength = safePasswordLength
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘加密时间戳
|
||||
func (p *EasyInput) SetSafePasswordTimeStamp(safePasswordTimeStamp int) *EasyInput {
|
||||
p.SafePasswordTimeStamp = safePasswordTimeStamp
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘加密盐值
|
||||
func (p *EasyInput) SetSafePasswordNonce(safePasswordNonce string) *EasyInput {
|
||||
p.SafePasswordNonce = safePasswordNonce
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘计算 hash 盐值,若指定custom-hash 则无效
|
||||
func (p *EasyInput) SetSafePasswordSalt(safePasswordSalt string) *EasyInput {
|
||||
p.SafePasswordSalt = safePasswordSalt
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘计算 hash 的算法表达式,如 md5(sha1('foo' + sha256(sm3(password + 'bar'))))
|
||||
func (p *EasyInput) SetSafePasswordCustomHash(safePasswordCustomHash string) *EasyInput {
|
||||
p.SafePasswordCustomHash = safePasswordCustomHash
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 type 为 number, digit, idcard 数字键盘是否随机排列
|
||||
func (p *EasyInput) SetRandomNumber(randomNumber bool) *EasyInput {
|
||||
p.RandomNumber = randomNumber
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否为受控组件。为 true 时,value 内容会完全受 setData 控制
|
||||
func (p *EasyInput) SetControlled(controlled bool) *EasyInput {
|
||||
p.Controlled = controlled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否强制使用系统键盘和 Web-view 创建的 input 元素。为 true 时,confirm-type、confirm-hold 可能失效
|
||||
func (p *EasyInput) SetAlwaysSystem(alwaysSystem bool) *EasyInput {
|
||||
p.AlwaysSystem = alwaysSystem
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示右侧清空内容的图标控件(输入框有内容且不禁用时显示),点击可清空输入框内容
|
||||
func (p *EasyInput) SetClearable(clearable bool) *EasyInput {
|
||||
p.Clearable = clearable
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否自动增高输入区域,type为textarea时有效
|
||||
func (p *EasyInput) SetAutoHeight(autoHeight bool) *EasyInput {
|
||||
p.AutoHeight = autoHeight
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 清除图标的大小,单位px
|
||||
func (p *EasyInput) SetClearSize(clearSize int) *EasyInput {
|
||||
p.ClearSize = clearSize
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框头部图标
|
||||
func (p *EasyInput) SetPrefixIcon(prefixIcon string) *EasyInput {
|
||||
p.PrefixIcon = prefixIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框尾部图标
|
||||
func (p *EasyInput) SetSuffixIcon(suffixIcon string) *EasyInput {
|
||||
p.SuffixIcon = suffixIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否自动去除空格,传入类型为 Boolean 时,自动去除前后空格
|
||||
func (p *EasyInput) SetTrim(trim interface{}) *EasyInput {
|
||||
p.Trim = trim
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示input输入框的边框
|
||||
func (p *EasyInput) SetInputBorder(inputBorder bool) *EasyInput {
|
||||
p.InputBorder = inputBorder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 样式自定义
|
||||
func (p *EasyInput) SetStyles(styles interface{}) *EasyInput {
|
||||
p.Styles = styles
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// type=password 时,是否显示小眼睛图标
|
||||
func (p *EasyInput) SetPasswordIcon(passwordIcon bool) *EasyInput {
|
||||
p.PasswordIcon = passwordIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *EasyInput) JsonSerialize() *EasyInput {
|
||||
p.Component = "easyInputField"
|
||||
|
||||
return p
|
||||
}
|
254
pkg/component/mix/form/fields/input.go
Normal file
254
pkg/component/mix/form/fields/input.go
Normal file
@@ -0,0 +1,254 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Input struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Type string `json:"type"`
|
||||
Password bool `json:"password"`
|
||||
Placeholder string `json:"placeholder"`
|
||||
PlaceholderStyle string `json:"placeholderStyle"`
|
||||
PlaceholderClass string `json:"placeholderClass"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Maxlength int `json:"maxlength"`
|
||||
CursorSpacing int `json:"cursorSpacing"`
|
||||
Focus bool `json:"focus"`
|
||||
ConfirmType string `json:"confirmType"`
|
||||
ConfirmHold bool `json:"confirmHold"`
|
||||
Cursor int `json:"cursor"`
|
||||
SelectionStart int `json:"selectionStart"`
|
||||
SelectionEnd int `json:"selectionEnd"`
|
||||
AdjustPosition bool `json:"adjustPosition"`
|
||||
AutoBlur bool `json:"autoBlur"`
|
||||
IgnoreCompositionEvent bool `json:"ignoreCompositionEvent"`
|
||||
AlwaysEmbed bool `json:"alwaysEmbed"`
|
||||
HoldKeyboard bool `json:"holdKeyboard"`
|
||||
SafePasswordCertPath string `json:"safePasswordCertPath"`
|
||||
SafePasswordLength int `json:"safePasswordLength"`
|
||||
SafePasswordTimeStamp int `json:"safePasswordTimeStamp"`
|
||||
SafePasswordNonce string `json:"safePasswordNonce"`
|
||||
SafePasswordSalt string `json:"safePasswordSalt"`
|
||||
SafePasswordCustomHash string `json:"safePasswordCustomHash"`
|
||||
RandomNumber bool `json:"randomNumber"`
|
||||
Controlled bool `json:"controlled"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Input) Init() *Input {
|
||||
p.Component = "inputField"
|
||||
p.Type = "text"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.PlaceholderClass = "input-placeholder"
|
||||
p.Maxlength = 140
|
||||
p.ConfirmType = "done"
|
||||
p.SelectionStart = -1
|
||||
p.SelectionEnd = -1
|
||||
p.AdjustPosition = true
|
||||
p.IgnoreCompositionEvent = true
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框的初始内容
|
||||
func (p *Input) SetValue(value interface{}) *Input {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// input 的类型
|
||||
func (p *Input) SetType(textType string) *Input {
|
||||
p.Type = textType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否是密码类型
|
||||
func (p *Input) SetPassword(password bool) *Input {
|
||||
p.Password = password
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框为空时占位符
|
||||
func (p *Input) SetPlaceholder(placeholder string) *Input {
|
||||
p.Placeholder = placeholder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定 placeholder 的样式
|
||||
func (p *Input) SetPlaceholderStyle(placeholderStyle string) *Input {
|
||||
p.PlaceholderStyle = placeholderStyle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定 placeholder 的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
|
||||
func (p *Input) SetPlaceholderClass(placeholderClass string) *Input {
|
||||
p.PlaceholderClass = placeholderClass
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *Input) SetDisabled(disabled bool) *Input {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最大输入长度,设置为 -1 的时候不限制最大长度
|
||||
func (p *Input) SetMaxlength(maxlength int) *Input {
|
||||
p.Maxlength = maxlength
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定光标与键盘的距离,单位 px 。取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离
|
||||
func (p *Input) SetCursorSpacing(cursorSpacing int) *Input {
|
||||
p.CursorSpacing = cursorSpacing
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 获取焦点
|
||||
func (p *Input) SetFocus(focus bool) *Input {
|
||||
p.Focus = focus
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置键盘右下角按钮的文字,仅在 type="text" 时生效。
|
||||
func (p *Input) SetConfirmType(confirmType string) *Input {
|
||||
p.ConfirmType = confirmType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 点击键盘右下角按钮时是否保持键盘不收起
|
||||
func (p *Input) SetConfirmHold(confirmHold bool) *Input {
|
||||
p.ConfirmHold = confirmHold
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定focus时的光标位置
|
||||
func (p *Input) SetCursor(cursor int) *Input {
|
||||
p.Cursor = cursor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 光标起始位置,自动聚集时有效,需与selection-end搭配使用
|
||||
func (p *Input) SetSelectionStart(selectionStart int) *Input {
|
||||
p.SelectionStart = selectionStart
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 光标结束位置,自动聚集时有效,需与selection-start搭配使用
|
||||
func (p *Input) SetSelectionEnd(selectionEnd int) *Input {
|
||||
p.SelectionEnd = selectionEnd
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 键盘弹起时,是否自动上推页面
|
||||
func (p *Input) SetAdjustPosition(adjustPosition bool) *Input {
|
||||
p.AdjustPosition = adjustPosition
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 键盘收起时,是否自动失去焦点
|
||||
func (p *Input) SetAutoBlur(autoBlur bool) *Input {
|
||||
p.AutoBlur = autoBlur
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否忽略组件内对文本合成系统事件的处理。为 false 时将触发 compositionstart、compositionend、compositionupdate 事件,且在文本合成期间会触发 input 事件
|
||||
func (p *Input) SetIgnoreCompositionEvent(ignoreCompositionEvent bool) *Input {
|
||||
p.IgnoreCompositionEvent = ignoreCompositionEvent
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效)
|
||||
func (p *Input) SetAlwaysEmbed(alwaysEmbed bool) *Input {
|
||||
p.AlwaysEmbed = alwaysEmbed
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// focus时,点击页面的时候不收起键盘
|
||||
func (p *Input) SetHoldKeyboard(holdKeyboard bool) *Input {
|
||||
p.HoldKeyboard = holdKeyboard
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘加密公钥的路径,只支持包内路径
|
||||
func (p *Input) SetSafePasswordCertPath(safePasswordCertPath string) *Input {
|
||||
p.SafePasswordCertPath = safePasswordCertPath
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘输入密码长度
|
||||
func (p *Input) SetSafePasswordLength(safePasswordLength int) *Input {
|
||||
p.SafePasswordLength = safePasswordLength
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘加密时间戳
|
||||
func (p *Input) SetSafePasswordTimeStamp(safePasswordTimeStamp int) *Input {
|
||||
p.SafePasswordTimeStamp = safePasswordTimeStamp
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘加密盐值
|
||||
func (p *Input) SetSafePasswordNonce(safePasswordNonce string) *Input {
|
||||
p.SafePasswordNonce = safePasswordNonce
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘计算 hash 盐值,若指定custom-hash 则无效
|
||||
func (p *Input) SetSafePasswordSalt(safePasswordSalt string) *Input {
|
||||
p.SafePasswordSalt = safePasswordSalt
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 安全键盘计算 hash 的算法表达式,如 md5(sha1('foo' + sha256(sm3(password + 'bar'))))
|
||||
func (p *Input) SetSafePasswordCustomHash(safePasswordCustomHash string) *Input {
|
||||
p.SafePasswordCustomHash = safePasswordCustomHash
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 type 为 number, digit, idcard 数字键盘是否随机排列
|
||||
func (p *Input) SetRandomNumber(randomNumber bool) *Input {
|
||||
p.RandomNumber = randomNumber
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否为受控组件。为 true 时,value 内容会完全受 setData 控制
|
||||
func (p *Input) SetControlled(controlled bool) *Input {
|
||||
p.Controlled = controlled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Input) JsonSerialize() *Input {
|
||||
p.Component = "inputField"
|
||||
|
||||
return p
|
||||
}
|
130
pkg/component/mix/form/fields/item.go
Normal file
130
pkg/component/mix/form/fields/item.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Item struct {
|
||||
component.Element
|
||||
Name interface{} `json:"name"`
|
||||
Rules interface{} `json:"rules"`
|
||||
Required bool `json:"required"`
|
||||
Label string `json:"label"`
|
||||
LabelWidth int `json:"labelWidth"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
LabelAlign string `json:"labelAlign"`
|
||||
LabelPosition string `json:"labelPosition"`
|
||||
ValidateTrigger string `json:"validateTrigger"`
|
||||
LeftIcon string `json:"leftIcon"`
|
||||
IconColor string `json:"iconColor"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Item) Init() *Item {
|
||||
p.Component = "formItem"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.LabelWidth = 70
|
||||
p.LabelAlign = "left"
|
||||
p.LabelPosition = "left"
|
||||
p.ValidateTrigger = "submit"
|
||||
p.IconColor = "#606266"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Item) SetStyle(style interface{}) *Item {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单域的属性名,在使用校验规则时必填
|
||||
func (p *Item) SetName(name interface{}) *Item {
|
||||
p.Name = name
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单校验规则
|
||||
func (p *Item) SetRules(rules interface{}) *Item {
|
||||
p.Rules = rules
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label 右边显示红色"*"号,样式显示不会对校验规则产生效果
|
||||
func (p *Item) SetRequired(required bool) *Item {
|
||||
p.Required = required
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框左边的文字提示
|
||||
func (p *Item) SetLabel(label string) *Item {
|
||||
p.Label = label
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label的宽度,单位px
|
||||
func (p *Item) SetLabelWidth(labelWidth int) *Item {
|
||||
p.LabelWidth = labelWidth
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 显示的错误提示内容,如果为空字符串或者false,则不显示错误信息
|
||||
func (p *Item) SetErrorMessage(errorMessage string) *Item {
|
||||
p.ErrorMessage = errorMessage
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label的文字对齐方式
|
||||
func (p *Item) SetLabelAlign(labelAlign string) *Item {
|
||||
p.LabelAlign = labelAlign
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label的文字的位置
|
||||
func (p *Item) SetLabelPosition(labelPosition string) *Item {
|
||||
p.LabelPosition = labelPosition
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单校验时机
|
||||
func (p *Item) SetValidateTrigger(validateTrigger string) *Item {
|
||||
p.ValidateTrigger = validateTrigger
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label左边的图标,限uni-ui的图标名称
|
||||
func (p *Item) SetLeftIcon(leftIcon string) *Item {
|
||||
p.LeftIcon = leftIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 左边通过icon配置的图标的颜色
|
||||
func (p *Item) SetIconColor(iconColor string) *Item {
|
||||
p.IconColor = iconColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Item) SetBody(body interface{}) *Item {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Item) JsonSerialize() *Item {
|
||||
p.Component = "formItem"
|
||||
|
||||
return p
|
||||
}
|
105
pkg/component/mix/form/fields/picker.go
Normal file
105
pkg/component/mix/form/fields/picker.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Picker struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Start string `json:"start"`
|
||||
End string `json:"end"`
|
||||
Fields string `json:"fields"`
|
||||
CustomItem string `json:"customItem"`
|
||||
Mode string `json:"mode"`
|
||||
Range []interface{} `json:"range"`
|
||||
RangeKey string `json:"RangeKey"`
|
||||
SelectorType string `json:"SelectorType"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Picker) Init() *Picker {
|
||||
p.Component = "pickerField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Mode = "selector"
|
||||
p.Value = 0
|
||||
p.SelectorType = "auto"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// value 的值表示选择了 range 中的第几个(下标从 0 开始)
|
||||
func (p *Picker) SetValue(value int) *Picker {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 选择器模式:selector,multiSelector,time,date,region
|
||||
func (p *Picker) SetMode(mode string) *Picker {
|
||||
p.Mode = mode
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// mode为 selector 或 multiSelector 时,range 有效
|
||||
func (p *Picker) SetRange(pickerRange []interface{}) *Picker {
|
||||
p.Range = pickerRange
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表示有效时间范围的开始
|
||||
func (p *Picker) SetStart(start string) *Picker {
|
||||
p.Start = start
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表示有效时间范围的结束
|
||||
func (p *Picker) SetEnd(end string) *Picker {
|
||||
p.End = end
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 有效值 year、month、day,表示选择器的粒度,默认为 day,App 端未配置此项时使用系统 UI
|
||||
func (p *Picker) SetFields(fields string) *Picker {
|
||||
p.Fields = fields
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 有效值 year、month、day,表示选择器的粒度,默认为 day,App 端未配置此项时使用系统 UI
|
||||
func (p *Picker) SetCustomItem(customItem string) *Picker {
|
||||
p.CustomItem = customItem
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 range 是一个 Array<Object> 时,通过 range-key 来指定 Object 中 key 的值作为选择器显示内容
|
||||
func (p *Picker) SetRangeKey(rangeKey string) *Picker {
|
||||
p.RangeKey = rangeKey
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 大屏时UI类型,支持 picker、select、auto,默认在 iPad 以 picker 样式展示而在 PC 以 select 样式展示
|
||||
func (p *Picker) SetSelectorType(selectorType string) *Picker {
|
||||
p.SelectorType = selectorType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *Picker) SetDisabled(disabled bool) *Picker {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Picker) JsonSerialize() *Picker {
|
||||
p.Component = "pickerField"
|
||||
|
||||
return p
|
||||
}
|
79
pkg/component/mix/form/fields/radio.go
Normal file
79
pkg/component/mix/form/fields/radio.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Radio struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Checked bool `json:"checked"`
|
||||
Color string `json:"color"`
|
||||
Options interface{} `json:"options"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Radio) Init() *Radio {
|
||||
p.Component = "radioField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Color = "rgb(0, 122, 255)"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 默认值
|
||||
func (p *Radio) SetValue(value interface{}) *Radio {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 本地渲染数据
|
||||
func (p *Radio) SetDisabled(disabled bool) *Radio {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 本地渲染数据
|
||||
func (p *Radio) SetChecked(checked bool) *Radio {
|
||||
p.Checked = checked
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// list 列表模式下 icon 显示的位置
|
||||
func (p *Radio) SetColor(color string) *Radio {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置单选属性,[]map[string]interface{}{{"text": "Title1","value": "value1"},{"text": "Title2","value": "value2"}}
|
||||
// 或者 map[interface{}]interface{}{"value1":"Title1","value2":"Title2"}
|
||||
func (p *Radio) SetOptions(options interface{}) *Radio {
|
||||
var data []map[string]interface{}
|
||||
|
||||
if mapOptions, ok := options.(map[interface{}]interface{}); ok {
|
||||
for k, v := range mapOptions {
|
||||
option := map[string]interface{}{
|
||||
"text": v,
|
||||
"value": k,
|
||||
}
|
||||
|
||||
data = append(data, option)
|
||||
}
|
||||
} else if sliceOptions, ok := options.([]map[string]interface{}); ok {
|
||||
data = sliceOptions
|
||||
}
|
||||
|
||||
p.Options = data
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Radio) JsonSerialize() *Radio {
|
||||
p.Component = "radioField"
|
||||
|
||||
return p
|
||||
}
|
109
pkg/component/mix/form/fields/slider.go
Normal file
109
pkg/component/mix/form/fields/slider.go
Normal file
@@ -0,0 +1,109 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Slider struct {
|
||||
Item
|
||||
Value int `json:"value"`
|
||||
Min int `json:"min"`
|
||||
Max int `json:"max"`
|
||||
Step int `json:"step"`
|
||||
Disabled bool `json:"disabled"`
|
||||
ActiveColor string `json:"activeColor"`
|
||||
BackgroundColor string `json:"backgroundColor"`
|
||||
BlockSize int `json:"blockSize"`
|
||||
BlockColor string `json:"blockColor"`
|
||||
ShowValue bool `json:"showValue"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Slider) Init() *Slider {
|
||||
p.Component = "sliderField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Min = 0
|
||||
p.Max = 100
|
||||
p.Step = 1
|
||||
p.Value = 0
|
||||
p.BackgroundColor = "#e9e9e9"
|
||||
p.BlockSize = 28
|
||||
p.BlockColor = "#ffffff"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 默认值
|
||||
func (p *Slider) SetValue(value int) *Slider {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最小值
|
||||
func (p *Slider) SetMin(min int) *Slider {
|
||||
p.Min = min
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 最大值
|
||||
func (p *Slider) SetMax(max int) *Slider {
|
||||
p.Max = max
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 步长,取值必须大于 0,并且可被(max - min)整除
|
||||
func (p *Slider) SetStep(step int) *Slider {
|
||||
p.Step = step
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *Slider) SetDisabled(disabled bool) *Slider {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 滑块左侧已选择部分的线条颜色
|
||||
func (p *Slider) SetActiveColor(activeColor string) *Slider {
|
||||
p.ActiveColor = activeColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 滑块右侧背景条的颜色
|
||||
func (p *Slider) SetBackgroundColor(backgroundColor string) *Slider {
|
||||
p.BackgroundColor = backgroundColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 滑块的大小,取值范围为 12 - 28
|
||||
func (p *Slider) SetBlockSize(blockSize int) *Slider {
|
||||
p.BlockSize = blockSize
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 滑块的颜色
|
||||
func (p *Slider) SetBlockColor(blockColor string) *Slider {
|
||||
p.BlockColor = blockColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示当前 value
|
||||
func (p *Slider) SetShowValue(showValue bool) *Slider {
|
||||
p.ShowValue = showValue
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Slider) JsonSerialize() *Slider {
|
||||
p.Component = "sliderField"
|
||||
|
||||
return p
|
||||
}
|
63
pkg/component/mix/form/fields/switch.go
Normal file
63
pkg/component/mix/form/fields/switch.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package fields
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Switch struct {
|
||||
Item
|
||||
Value interface{} `json:"value"`
|
||||
Checked bool `json:"checked"`
|
||||
Disabled bool `json:"disabled"`
|
||||
Type string `json:"type"`
|
||||
Color string `json:"color"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Switch) Init() *Switch {
|
||||
p.Component = "switchField"
|
||||
p.SetKey("formItem", component.DEFAULT_CRYPT)
|
||||
p.Type = "switch"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 默认值
|
||||
func (p *Switch) SetValue(value interface{}) *Switch {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否选中
|
||||
func (p *Switch) SetChecked(checked bool) *Switch {
|
||||
p.Checked = checked
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *Switch) SetDisabled(disabled bool) *Switch {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 样式,有效值:switch, checkbox
|
||||
func (p *Switch) SetType(switchType string) *Switch {
|
||||
p.Type = switchType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// switch 的颜色,同 css 的 color
|
||||
func (p *Switch) SetColor(color string) *Switch {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Switch) JsonSerialize() *Switch {
|
||||
p.Component = "switchField"
|
||||
|
||||
return p
|
||||
}
|
132
pkg/component/mix/form/form.go
Normal file
132
pkg/component/mix/form/form.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package form
|
||||
|
||||
import (
|
||||
"github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
)
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Api string `json:"api"`
|
||||
ApiType string `json:"apiType"`
|
||||
Model interface{} `json:"model"`
|
||||
Rules interface{} `json:"rules"`
|
||||
ValidateTrigger string `json:"validateTrigger"`
|
||||
LabelPosition string `json:"labelPosition"`
|
||||
LabelWidth int `json:"labelWidth"`
|
||||
LabelAlign string `json:"labelAlign"`
|
||||
ErrShowType string `json:"errShowType"`
|
||||
Border bool `json:"border"`
|
||||
Actions []interface{} `json:"actions"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "form"
|
||||
p.SetKey("form", component.DEFAULT_CRYPT)
|
||||
p.ApiType = "POST"
|
||||
p.ValidateTrigger = "submit"
|
||||
p.LabelPosition = "left"
|
||||
p.LabelWidth = 70
|
||||
p.LabelAlign = "left"
|
||||
p.ErrShowType = "undertext"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单接口
|
||||
func (p *Component) SetApi(api string) *Component {
|
||||
p.Api = api
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单接口提交方式
|
||||
func (p *Component) SetApiType(apiType string) *Component {
|
||||
p.ApiType = apiType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
func (p *Component) SetModel(model interface{}) *Component {
|
||||
p.Model = model
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单校验规则
|
||||
func (p *Component) SetRules(rules interface{}) *Component {
|
||||
p.Rules = rules
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单校验时机,blur仅在 uni-easyinput 中生效
|
||||
func (p *Component) SetValidateTrigger(validateTrigger string) *Component {
|
||||
p.ValidateTrigger = validateTrigger
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label 位置
|
||||
func (p *Component) SetLabelPosition(labelPosition string) *Component {
|
||||
p.LabelPosition = labelPosition
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label 宽度,单位 px
|
||||
func (p *Component) SetLabelWidth(labelWidth int) *Component {
|
||||
p.LabelWidth = labelWidth
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// label 居中方式
|
||||
func (p *Component) SetLabelAlign(labelAlign string) *Component {
|
||||
p.LabelAlign = labelAlign
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 表单错误信息提示方式
|
||||
func (p *Component) SetErrShowType(errShowType string) *Component {
|
||||
p.ErrShowType = errShowType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示分格线
|
||||
func (p *Component) SeBorder(border bool) *Component {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置表单行为
|
||||
func (p *Component) SetActions(actions []interface{}) *Component {
|
||||
p.Actions = actions
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "form"
|
||||
|
||||
return p
|
||||
}
|
77
pkg/component/mix/grid/grid.go
Normal file
77
pkg/component/mix/grid/grid.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package grid
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Column int `json:"column"`
|
||||
BorderColor string `json:"borderColor"`
|
||||
ShowBorder bool `json:"showBorder"`
|
||||
Square bool `json:"square"`
|
||||
Highlight bool `json:"highlight"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "grid"
|
||||
p.SetKey("grid", component.DEFAULT_CRYPT)
|
||||
p.Column = 3
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 每列显示个数
|
||||
func (p *Component) SetColumn(column int) *Component {
|
||||
p.Column = column
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 边框颜色
|
||||
func (p *Component) SetBorderColor(borderColor string) *Component {
|
||||
p.BorderColor = borderColor
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示边框
|
||||
func (p *Component) SetShowBorder(showBorder bool) *Component {
|
||||
p.ShowBorder = showBorder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否方形显示
|
||||
func (p *Component) SetSquare(square bool) *Component {
|
||||
p.Square = square
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 点击背景是否高亮
|
||||
func (p *Component) SetHighlight(highlight bool) *Component {
|
||||
p.Highlight = highlight
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "grid"
|
||||
|
||||
return p
|
||||
}
|
45
pkg/component/mix/grid/item.go
Normal file
45
pkg/component/mix/grid/item.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package grid
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type GridItem struct {
|
||||
component.Element
|
||||
Index int `json:"index"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *GridItem) Init() *GridItem {
|
||||
p.Component = "gridItem"
|
||||
p.SetKey("gridItem", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *GridItem) SetStyle(style interface{}) *GridItem {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 每列显示个数
|
||||
func (p *GridItem) SetIndex(index int) *GridItem {
|
||||
p.Index = index
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *GridItem) SetBody(body interface{}) *GridItem {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *GridItem) JsonSerialize() *GridItem {
|
||||
p.Component = "gridItem"
|
||||
|
||||
return p
|
||||
}
|
60
pkg/component/mix/group/group.go
Normal file
60
pkg/component/mix/group/group.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package group
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
Top int `json:"top"`
|
||||
Mode string `json:"mode"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "group"
|
||||
p.SetKey("group", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 主标题
|
||||
func (p *Component) SetTitle(title string) *Component {
|
||||
p.Title = title
|
||||
return p
|
||||
}
|
||||
|
||||
// 分组间隔
|
||||
func (p *Component) SetTop(top int) *Component {
|
||||
p.Top = top
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 模式 ,card 为卡片模式
|
||||
func (p *Component) SetMode(mode string) *Component {
|
||||
p.Mode = mode
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "group"
|
||||
|
||||
return p
|
||||
}
|
61
pkg/component/mix/icon/icon.go
Normal file
61
pkg/component/mix/icon/icon.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package icon
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Size int `json:"size"`
|
||||
Type string `json:"type"`
|
||||
Color string `json:"color"`
|
||||
CustomPrefix string `json:"customPrefix"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "icon"
|
||||
p.SetKey("icon", component.DEFAULT_CRYPT)
|
||||
p.Size = 24
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *Component) SetSize(size int) *Component {
|
||||
p.Size = size
|
||||
return p
|
||||
}
|
||||
|
||||
// 子标题
|
||||
func (p *Component) SetType(fontType string) *Component {
|
||||
p.Type = fontType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 额外信息
|
||||
func (p *Component) SetColor(color string) *Component {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 略缩图
|
||||
func (p *Component) SetCustomPrefix(customPrefix string) *Component {
|
||||
p.CustomPrefix = customPrefix
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "icon"
|
||||
|
||||
return p
|
||||
}
|
101
pkg/component/mix/image/image.go
Normal file
101
pkg/component/mix/image/image.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package image
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Src string `json:"src"`
|
||||
Mode string `json:"mode"`
|
||||
LazyLoad bool `json:"lazyLoad"`
|
||||
FadeShow bool `json:"fadeShow"`
|
||||
Webp bool `json:"webp"`
|
||||
ShowMenuByLongpress bool `json:"showMenuByLongpress"`
|
||||
Draggable bool `json:"draggable"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "image"
|
||||
p.SetKey("image", component.DEFAULT_CRYPT)
|
||||
p.Mode = "scaleToFill"
|
||||
p.FadeShow = true
|
||||
p.Draggable = true
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 图片资源地址
|
||||
func (p *Component) SetSrc(src string) *Component {
|
||||
p.Src = src
|
||||
return p
|
||||
}
|
||||
|
||||
// 图片裁剪、缩放的模式
|
||||
// scaleToFill:缩放,不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素
|
||||
// aspectFit:缩放,保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。
|
||||
// aspectFill:缩放,保持纵横比缩放图片,只保证图片的短边能完全显示出来。也就是说,图片通常只在水平或垂直方向是完整的,另一个方向将会发生截取。
|
||||
// widthFix:缩放,宽度不变,高度自动变化,保持原图宽高比不变
|
||||
// heightFix:缩放,高度不变,宽度自动变化,保持原图宽高比不变 App 和 H5 平台 HBuilderX 2.9.3+ 支持、微信小程序需要基础库 2.10.3
|
||||
// top:裁剪,不缩放图片,只显示图片的顶部区域
|
||||
// bottom:裁剪,不缩放图片,只显示图片的底部区域
|
||||
// center:裁剪,不缩放图片,只显示图片的中间区域
|
||||
// left:裁剪,不缩放图片,只显示图片的左边区域
|
||||
// right:裁剪,不缩放图片,只显示图片的右边区域
|
||||
// top left:裁剪,不缩放图片,只显示图片的左上边区域
|
||||
// top right:裁剪,不缩放图片,只显示图片的右上边区域
|
||||
// bottom left:裁剪,不缩放图片,只显示图片的左下边区域
|
||||
// bottom right:裁剪,不缩放图片,只显示图片的右下边区域
|
||||
func (p *Component) SetMode(mode string) *Component {
|
||||
p.Mode = mode
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 图片懒加载。只针对page与scroll-view下的image有效
|
||||
func (p *Component) SetLazyLoad(lazyLoad bool) *Component {
|
||||
p.LazyLoad = lazyLoad
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 图片显示动画效果
|
||||
func (p *Component) SetFadeShow(fadeShow bool) *Component {
|
||||
p.FadeShow = fadeShow
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 在系统不支持webp的情况下是否单独启用webp。默认false,只支持网络资源。webp支持详见下面说明
|
||||
func (p *Component) SetWebp(webp bool) *Component {
|
||||
p.Webp = webp
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 开启长按图片显示识别小程序码菜单
|
||||
func (p *Component) SetShowMenuByLongpress(showMenuByLongpress bool) *Component {
|
||||
p.ShowMenuByLongpress = showMenuByLongpress
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否能拖动图片
|
||||
func (p *Component) SetDraggable(draggable bool) *Component {
|
||||
p.Draggable = draggable
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "image"
|
||||
|
||||
return p
|
||||
}
|
113
pkg/component/mix/layout/col.go
Normal file
113
pkg/component/mix/layout/col.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package layout
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Col struct {
|
||||
component.Element
|
||||
Span int `json:"span"`
|
||||
Offset int `json:"offset"`
|
||||
Push int `json:"push"`
|
||||
Pull int `json:"pull"`
|
||||
Xs interface{} `json:"xs"`
|
||||
Sm interface{} `json:"sm"`
|
||||
Md interface{} `json:"md"`
|
||||
Lg interface{} `json:"lg"`
|
||||
Xl interface{} `json:"xl"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Col) Init() *Col {
|
||||
p.Component = "col"
|
||||
p.Offset = 0
|
||||
p.Pull = 0
|
||||
p.Push = 0
|
||||
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Col) SetStyle(style interface{}) *Col {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 栅格左侧的间隔格数,间隔内不可以有栅格
|
||||
func (p *Col) SetOffset(offset int) *Col {
|
||||
p.Offset = offset
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 栅格向左移动格数
|
||||
func (p *Col) SetPull(pull int) *Col {
|
||||
p.Pull = pull
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 栅格向右移动格数
|
||||
func (p *Col) SetPush(push int) *Col {
|
||||
p.Push = push
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 栅格占位格数,为 0 时相当于 display: none
|
||||
func (p *Col) SetSpan(span int) *Col {
|
||||
p.Span = span
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 屏幕 < 576px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
||||
func (p *Col) SetXs(xs interface{}) *Col {
|
||||
p.Xs = xs
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 屏幕 ≥ 576px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
||||
func (p *Col) SetSm(sm interface{}) *Col {
|
||||
p.Sm = sm
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 屏幕 ≥ 768px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
||||
func (p *Col) SetMd(md interface{}) *Col {
|
||||
p.Md = md
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 屏幕 ≥ 992px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
||||
func (p *Col) SetLg(lg interface{}) *Col {
|
||||
p.Lg = lg
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 屏幕 ≥ 1200px 响应式栅格,可为栅格数或一个包含其他属性的对象
|
||||
func (p *Col) SetXl(xl interface{}) *Col {
|
||||
p.Xl = xl
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡牌内容
|
||||
func (p *Col) SetBody(body interface{}) *Col {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Col) JsonSerialize() *Col {
|
||||
p.Component = "col"
|
||||
|
||||
return p
|
||||
}
|
54
pkg/component/mix/layout/row.go
Normal file
54
pkg/component/mix/layout/row.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package layout
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Row struct {
|
||||
component.Element
|
||||
Gutter interface{} `json:"gutter"`
|
||||
Col *Col `json:"col"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Row) Init() *Row {
|
||||
p.Component = "row"
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Row) SetStyle(style interface{}) *Row {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 栅格间隔,可以写成像素值或支持响应式的对象写法来设置水平间隔 { xs: 8, sm: 16, md: 24}。
|
||||
// 或者使用数组形式同时设置 [水平间距, 垂直间距]
|
||||
func (p *Row) SetGutter(gutter interface{}) *Row {
|
||||
p.Gutter = gutter
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置列
|
||||
func (p *Row) SetCol(col *Col) *Row {
|
||||
p.Col = col
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Row) SetBody(body interface{}) *Row {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Row) JsonSerialize() *Row {
|
||||
p.Component = "row"
|
||||
|
||||
return p
|
||||
}
|
96
pkg/component/mix/link/link.go
Normal file
96
pkg/component/mix/link/link.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package link
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Href string `json:"href"`
|
||||
Text string `json:"text"`
|
||||
Download string `json:"download"`
|
||||
ShowUnderLine bool `json:"showUnderLine"`
|
||||
CopyTips string `json:"copyTips"`
|
||||
Color string `json:"color"`
|
||||
FontSize string `json:"fontSize"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "link"
|
||||
p.SetShowUnderLine(true)
|
||||
p.SetCopyTips("已自动复制网址,请在手机浏览器里粘贴该网址")
|
||||
p.SetColor("#999999")
|
||||
p.SetFontSize("14")
|
||||
p.SetKey("link", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style map[string]interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 应用内的跳转链接,值为相对路径或绝对路径,如:"../first/first","/pages/first/first",注意不能加 .vue 后缀
|
||||
func (p *Component) SetHref(href string) *Component {
|
||||
p.Href = href
|
||||
return p
|
||||
}
|
||||
|
||||
// 跳转方式
|
||||
func (p *Component) SetText(text string) *Component {
|
||||
p.Text = text
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 'navigateBack' 时有效,表示回退的层数
|
||||
func (p *Component) SetDownload(download string) *Component {
|
||||
p.Download = download
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 navigate、navigateBack 时有效,窗口的显示/关闭动画效果,详见:窗口动画
|
||||
func (p *Component) SetShowUnderLine(showUnderLine bool) *Component {
|
||||
p.ShowUnderLine = showUnderLine
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 navigate、navigateBack 时有效,窗口显示/关闭动画的持续时间。
|
||||
func (p *Component) SetCopyTips(copyTips string) *Component {
|
||||
p.CopyTips = copyTips
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定点击时的样式类,当hover-class="none"时,没有点击态效果
|
||||
func (p *Component) SetColor(color string) *Component {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定是否阻止本节点的祖先节点出现点击态
|
||||
func (p *Component) SetFontSize(fontSize string) *Component {
|
||||
p.FontSize = fontSize
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "link"
|
||||
|
||||
return p
|
||||
}
|
191
pkg/component/mix/list/item.go
Normal file
191
pkg/component/mix/list/item.go
Normal file
@@ -0,0 +1,191 @@
|
||||
package list
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type ListItem struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
Note string `json:"note"`
|
||||
Ellipsis int `json:"ellipsis"`
|
||||
Thumb string `json:"thumb"`
|
||||
ThumbSize string `json:"thumbSize"`
|
||||
ShowBadge bool `json:"showBadge"`
|
||||
BadgeText string `json:"badgeText"`
|
||||
BadgeType string `json:"badgeType"`
|
||||
BadgeStyle interface{} `json:"badgeStyle"`
|
||||
RightText string `json:"rightText"`
|
||||
Disabled bool `json:"disabled"`
|
||||
ShowArrow bool `json:"showArrow"`
|
||||
Link string `json:"link"`
|
||||
To string `json:"to"`
|
||||
Clickable bool `json:"clickable"`
|
||||
ShowSwitch bool `json:"showSwitch"`
|
||||
SwitchChecked bool `json:"switchChecked"`
|
||||
ShowExtraIcon bool `json:"showExtraIcon"`
|
||||
ExtraIcon interface{} `json:"extraIcon"`
|
||||
Direction string `json:"direction"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *ListItem) Init() *ListItem {
|
||||
p.Component = "listItem"
|
||||
p.Ellipsis = 0
|
||||
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *ListItem) SetStyle(style interface{}) *ListItem {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *ListItem) SetTitle(title string) *ListItem {
|
||||
p.Title = title
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 描述
|
||||
func (p *ListItem) SetNote(note string) *ListItem {
|
||||
p.Note = note
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// title 是否溢出隐藏,可选值,0:默认; 1:显示一行; 2:显示两行;
|
||||
func (p *ListItem) SetEllipsis(ellipsis int) *ListItem {
|
||||
p.Ellipsis = ellipsis
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 左侧缩略图,若thumb有值,则不会显示扩展图标
|
||||
func (p *ListItem) SetThumb(thumb string) *ListItem {
|
||||
p.Thumb = thumb
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 略缩图尺寸,可选值,lg:大图; medium:一般; sm:小图;
|
||||
func (p *ListItem) SetThumbSize(thumbSize string) *ListItem {
|
||||
p.ThumbSize = thumbSize
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示数字角标
|
||||
func (p *ListItem) SetShowBadge(showBadge bool) *ListItem {
|
||||
p.ShowBadge = showBadge
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 数字角标内容
|
||||
func (p *ListItem) SetBadgeText(badgeText string) *ListItem {
|
||||
p.BadgeText = badgeText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 数字角标类型,参考uni-icons
|
||||
func (p *ListItem) SetBadgeType(badgeType string) *ListItem {
|
||||
p.BadgeType = badgeType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 数字角标样式,使用uni-badge的custom-style参数
|
||||
func (p *ListItem) SetBadgeStyle(badgeStyle interface{}) *ListItem {
|
||||
p.BadgeStyle = badgeStyle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 右侧文字内容
|
||||
func (p *ListItem) SetRightText(rightText string) *ListItem {
|
||||
p.RightText = rightText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用
|
||||
func (p *ListItem) SetDisabled(disabled bool) *ListItem {
|
||||
p.Disabled = disabled
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示箭头图标
|
||||
func (p *ListItem) SetShowArrow(showArrow bool) *ListItem {
|
||||
p.ShowArrow = showArrow
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 新页面跳转方式,可选值见下表
|
||||
func (p *ListItem) SetLink(link string) *ListItem {
|
||||
p.Link = link
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 新页面跳转地址,如填写此属性,click 会返回页面是否跳转成功
|
||||
func (p *ListItem) SetTo(to string) *ListItem {
|
||||
p.To = to
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否开启点击反馈
|
||||
func (p *ListItem) SetClickable(clickable bool) *ListItem {
|
||||
p.Clickable = clickable
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示Switch
|
||||
func (p *ListItem) SetShowSwitch(showSwitch bool) *ListItem {
|
||||
p.ShowSwitch = showSwitch
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Switch是否被选中
|
||||
func (p *ListItem) SetSwitchChecked(switchChecked bool) *ListItem {
|
||||
p.SwitchChecked = switchChecked
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 左侧是否显示扩展图标
|
||||
func (p *ListItem) SetShowExtraIcon(showExtraIcon bool) *ListItem {
|
||||
p.ShowExtraIcon = showExtraIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 扩展图标参数,格式为 {color: '#4cd964',size: '22',type: 'spinner'},参考 uni-icons
|
||||
func (p *ListItem) SetExtraIcon(extraIcon interface{}) *ListItem {
|
||||
p.ExtraIcon = extraIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 排版方向,可选值,row:水平排列; column:垂直排列; 3个插槽是水平排还是垂直排,也受此属性控制
|
||||
func (p *ListItem) SetDirection(direction string) *ListItem {
|
||||
p.Direction = direction
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *ListItem) JsonSerialize() *ListItem {
|
||||
p.Component = "listItem"
|
||||
|
||||
return p
|
||||
}
|
45
pkg/component/mix/list/list.go
Normal file
45
pkg/component/mix/list/list.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package list
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Border bool `json:"border"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "list"
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示边框
|
||||
func (p *Component) SetBorder(border bool) *Component {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "list"
|
||||
|
||||
return p
|
||||
}
|
156
pkg/component/mix/navbar/navbar.go
Normal file
156
pkg/component/mix/navbar/navbar.go
Normal file
@@ -0,0 +1,156 @@
|
||||
package navbar
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
LeftText string `json:"leftText"`
|
||||
RightText string `json:"rightText"`
|
||||
LeftIcon string `json:"leftIcon"`
|
||||
RightIcon string `json:"rightIcon"`
|
||||
Color string `json:"color"`
|
||||
BackgroundColor string `json:"backgroundColor"`
|
||||
Fixed bool `json:"fixed"`
|
||||
StatusBar bool `json:"statusBar"`
|
||||
Shadow bool `json:"shadow"`
|
||||
Border bool `json:"border"`
|
||||
Height interface{} `json:"height"`
|
||||
Dark bool `json:"dark"`
|
||||
LeftWidth interface{} `json:"leftWidth"`
|
||||
RightWidth interface{} `json:"rightWidth"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "navbar"
|
||||
p.SetKey("navbar", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *Component) SetTitle(title string) *Component {
|
||||
p.Title = title
|
||||
return p
|
||||
}
|
||||
|
||||
// 左侧按钮文本
|
||||
func (p *Component) SetLeftText(leftText string) *Component {
|
||||
p.LeftText = leftText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 右侧按钮文本
|
||||
func (p *Component) SetRightText(rightText string) *Component {
|
||||
p.RightText = rightText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 左侧按钮图标(图标类型参考 Icon 图标 (opens new window)type 属性)
|
||||
func (p *Component) SetLeftIcon(leftIcon string) *Component {
|
||||
p.LeftIcon = leftIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 右侧按钮图标(图标类型参考 Icon 图标 (opens new window)type 属性)
|
||||
func (p *Component) SetRightIcon(rightIcon string) *Component {
|
||||
p.RightIcon = rightIcon
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 图标和文字颜色
|
||||
func (p *Component) SetColor(color string) *Component {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏背景颜色
|
||||
func (p *Component) SetBackgroundColor(backgroundColor string) *Component {
|
||||
p.BackgroundColor = backgroundColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否固定顶部
|
||||
func (p *Component) SetFixed(fixed bool) *Component {
|
||||
p.Fixed = fixed
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否包含状态栏
|
||||
func (p *Component) SetStatusBar(statusBar bool) *Component {
|
||||
p.StatusBar = statusBar
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏下是否有阴影
|
||||
func (p *Component) SetShadow(shadow bool) *Component {
|
||||
p.Shadow = shadow
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏下是否有边框
|
||||
func (p *Component) SetBorder(border bool) *Component {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏高度
|
||||
func (p *Component) SetHeight(height interface{}) *Component {
|
||||
p.Height = height
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏开启暗黑模式
|
||||
func (p *Component) SetDark(dark bool) *Component {
|
||||
p.Dark = dark
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏左侧插槽宽度
|
||||
func (p *Component) SetLeftWidth(leftWidth interface{}) *Component {
|
||||
p.LeftWidth = leftWidth
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏右侧插槽宽度
|
||||
func (p *Component) SetRightWidth(rightWidth interface{}) *Component {
|
||||
p.RightWidth = rightWidth
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "navbar"
|
||||
|
||||
return p
|
||||
}
|
123
pkg/component/mix/navigator/navigator.go
Normal file
123
pkg/component/mix/navigator/navigator.go
Normal file
@@ -0,0 +1,123 @@
|
||||
package navigator
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Url string `json:"url"`
|
||||
OpenType string `json:"openType"`
|
||||
Delta int `json:"delta"`
|
||||
AnimationType string `json:"animationType"`
|
||||
AnimationDuration int `json:"animationDuration"`
|
||||
HoverClass string `json:"hoverClass"`
|
||||
HoverStopPropagation string `json:"hoverStopPropagation"`
|
||||
HoverStartTime int `json:"hoverStartTime"`
|
||||
HoverStayTime int `json:"hoverStayTime"`
|
||||
Target string `json:"target"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "navigator"
|
||||
p.OpenType = "navigate"
|
||||
p.AnimationType = "pop-in"
|
||||
p.AnimationDuration = 300
|
||||
p.HoverClass = "navigator-hover"
|
||||
p.HoverStartTime = 50
|
||||
p.HoverStayTime = 600
|
||||
p.Target = "self"
|
||||
p.SetKey("navigator", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style map[string]interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 应用内的跳转链接,值为相对路径或绝对路径,如:"../first/first","/pages/first/first",注意不能加 .vue 后缀
|
||||
func (p *Component) SetUrl(url string) *Component {
|
||||
p.Url = url
|
||||
return p
|
||||
}
|
||||
|
||||
// 跳转方式
|
||||
func (p *Component) SetOpenType(openType string) *Component {
|
||||
p.OpenType = openType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 'navigateBack' 时有效,表示回退的层数
|
||||
func (p *Component) SetDelta(delta int) *Component {
|
||||
p.Delta = delta
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 navigate、navigateBack 时有效,窗口的显示/关闭动画效果,详见:窗口动画
|
||||
func (p *Component) SetAnimationType(animationType string) *Component {
|
||||
p.AnimationType = animationType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 navigate、navigateBack 时有效,窗口显示/关闭动画的持续时间。
|
||||
func (p *Component) SetAnimationDuration(animationDuration int) *Component {
|
||||
p.AnimationDuration = animationDuration
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定点击时的样式类,当hover-class="none"时,没有点击态效果
|
||||
func (p *Component) SetHoverClass(hoverClass string) *Component {
|
||||
p.HoverClass = hoverClass
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定是否阻止本节点的祖先节点出现点击态
|
||||
func (p *Component) SetHoverStopPropagation(hoverStopPropagation string) *Component {
|
||||
p.HoverStopPropagation = hoverStopPropagation
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否固定顶部
|
||||
func (p *Component) SetHoverStartTime(hoverStartTime int) *Component {
|
||||
p.HoverStartTime = hoverStartTime
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否包含状态栏
|
||||
func (p *Component) SetHoverStayTime(hoverStayTime int) *Component {
|
||||
p.HoverStayTime = hoverStayTime
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 导航栏下是否有阴影
|
||||
func (p *Component) SetTarget(target string) *Component {
|
||||
p.Target = target
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "navigator"
|
||||
|
||||
return p
|
||||
}
|
57
pkg/component/mix/page/page.go
Normal file
57
pkg/component/mix/page/page.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package page
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
NavBar interface{} `json:"navBar"`
|
||||
Content interface{} `json:"content"`
|
||||
TabBar interface{} `json:"tabBar"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "page"
|
||||
p.SetKey("page", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *Component) SetTitle(title string) *Component {
|
||||
p.Title = title
|
||||
return p
|
||||
}
|
||||
|
||||
// 头部导航
|
||||
func (p *Component) SetNavBar(navBar interface{}) *Component {
|
||||
p.NavBar = navBar
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetContent(content interface{}) *Component {
|
||||
p.Content = content
|
||||
return p
|
||||
}
|
||||
|
||||
// 底部导航
|
||||
func (p *Component) SetTabBar(tabBar interface{}) *Component {
|
||||
p.TabBar = tabBar
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "page"
|
||||
|
||||
return p
|
||||
}
|
107
pkg/component/mix/searchbar/searchbar.go
Normal file
107
pkg/component/mix/searchbar/searchbar.go
Normal file
@@ -0,0 +1,107 @@
|
||||
package searchbar
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Value interface{} `json:"value"`
|
||||
Placeholder string `json:"placeholdeV"`
|
||||
Radius int `json:"radius"`
|
||||
ClearButton string `json:"clearButton"`
|
||||
CancelButton string `json:"cancelButton"`
|
||||
CancelText string `json:"cancelText"`
|
||||
BgColor string `json:"bgColor"`
|
||||
Maxlength int `json:"maxlength"`
|
||||
Focus bool `json:"focus"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "searchbar"
|
||||
p.Placeholder = "搜索"
|
||||
p.Radius = 100
|
||||
p.ClearButton = "auto"
|
||||
p.CancelButton = "auto"
|
||||
p.CancelText = "取消"
|
||||
p.BgColor = "#FFFFFF"
|
||||
p.Maxlength = 100
|
||||
p.SetKey("searchbar", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 搜索栏绑定值
|
||||
func (p *Component) SetValue(value interface{}) *Component {
|
||||
p.Value = value
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 搜索栏Placeholder
|
||||
func (p *Component) SetPlaceholder(placeholder string) *Component {
|
||||
p.Placeholder = placeholder
|
||||
return p
|
||||
}
|
||||
|
||||
// 搜索栏圆角,单位px
|
||||
func (p *Component) SetRadius(radius int) *Component {
|
||||
p.Radius = radius
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示清除按钮,可选值always-一直显示、auto-输入框不为空时显示、none-一直不显示
|
||||
func (p *Component) SetClearButton(clearButton string) *Component {
|
||||
p.ClearButton = clearButton
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示取消按钮,可选值always-一直显示、auto-输入框不为空时显示、none-一直不显示
|
||||
func (p *Component) SetCancelButton(cancelButton string) *Component {
|
||||
p.CancelButton = cancelButton
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 取消按钮的文字
|
||||
func (p *Component) SetCancelText(cancelText string) *Component {
|
||||
p.CancelText = cancelText
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入框背景颜色
|
||||
func (p *Component) SetBgColor(bgColor string) *Component {
|
||||
p.BgColor = bgColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 输入最大长度
|
||||
func (p *Component) SetMaxlength(maxlength int) *Component {
|
||||
p.Maxlength = maxlength
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否包含状态栏
|
||||
func (p *Component) SetFocus(focus bool) *Component {
|
||||
p.Focus = focus
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "searchbar"
|
||||
|
||||
return p
|
||||
}
|
104
pkg/component/mix/section/section.go
Normal file
104
pkg/component/mix/section/section.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package section
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
TitleFontSize string `json:"titleFontSize"`
|
||||
TitleColor string `json:"titleColor"`
|
||||
SubTitle string `json:"subTitle"`
|
||||
SubTitleFontSize string `json:"subTitleFontSize"`
|
||||
SubTitleColor string `json:"subTitleColor"`
|
||||
Padding interface{} `json:"padding"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "section"
|
||||
p.SetKey("section", component.DEFAULT_CRYPT)
|
||||
p.TitleFontSize = "14px"
|
||||
p.TitleColor = "#333"
|
||||
p.SubTitleFontSize = "12px"
|
||||
p.SubTitleColor = "#999"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 装饰类型,可选值:line(竖线)、circle(圆形)、square(方形)
|
||||
func (p *Component) SetType(sectionType string) *Component {
|
||||
p.Type = sectionType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *Component) SetTitle(title string) *Component {
|
||||
p.Title = title
|
||||
return p
|
||||
}
|
||||
|
||||
// 主标题字体大小
|
||||
func (p *Component) SetTitleFontSize(titleFontSize string) *Component {
|
||||
p.TitleFontSize = titleFontSize
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 主标题字体颜色
|
||||
func (p *Component) SetTitleColor(titleColor string) *Component {
|
||||
p.TitleColor = titleColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 副标题
|
||||
func (p *Component) SetSubTitle(subTitle string) *Component {
|
||||
p.SubTitle = subTitle
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 副标题字体大小
|
||||
func (p *Component) SetSubTitleFontSize(subTitleFontSize string) *Component {
|
||||
p.SubTitleFontSize = subTitleFontSize
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 副标题字体颜色
|
||||
func (p *Component) SetSubTitleColor(subTitleColor string) *Component {
|
||||
p.SubTitleColor = subTitleColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 卡片边框
|
||||
func (p *Component) SetPadding(padding string) *Component {
|
||||
p.Padding = padding
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "section"
|
||||
|
||||
return p
|
||||
}
|
71
pkg/component/mix/segmentedcontrol/segmentedcontrol.go
Normal file
71
pkg/component/mix/segmentedcontrol/segmentedcontrol.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package segmentedcontrol
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Current int `json:"current"`
|
||||
StyleType string `json:"styleType"`
|
||||
ActiveColor string `json:"activeColor"`
|
||||
Titles interface{} `json:"titles"`
|
||||
Items interface{} `json:"items"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "segmentedControl"
|
||||
p.Current = 0
|
||||
p.StyleType = "button"
|
||||
p.ActiveColor = "#007aff"
|
||||
p.SetKey("segmentedControl", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style map[string]interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当前选中的tab索引值,从0计数
|
||||
func (p *Component) SetCurrent(current int) *Component {
|
||||
p.Current = current
|
||||
return p
|
||||
}
|
||||
|
||||
// 跳转方式
|
||||
func (p *Component) SetStyleType(styleType string) *Component {
|
||||
p.StyleType = styleType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 'navigateBack' 时有效,表示回退的层数
|
||||
func (p *Component) SetActiveColor(activeColor string) *Component {
|
||||
p.ActiveColor = activeColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 navigate、navigateBack 时有效,窗口的显示/关闭动画效果,详见:窗口动画
|
||||
func (p *Component) SetTitles(titles interface{}) *Component {
|
||||
p.Titles = titles
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当 open-type 为 navigate、navigateBack 时有效,窗口显示/关闭动画的持续时间。
|
||||
func (p *Component) SetItems(items interface{}) *Component {
|
||||
p.Items = items
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "segmentedControl"
|
||||
|
||||
return p
|
||||
}
|
76
pkg/component/mix/swiper/dot.go
Normal file
76
pkg/component/mix/swiper/dot.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package swiper
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type SwiperDot struct {
|
||||
component.Element
|
||||
Current int `json:"current"`
|
||||
Mode string `json:"mode"`
|
||||
Field string `json:"field"`
|
||||
Items interface{} `json:"items"`
|
||||
DotsStyles interface{} `json:"dotsStyles"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *SwiperDot) Init() *SwiperDot {
|
||||
p.Component = "swiperDot"
|
||||
p.SetKey("swiperDot", component.DEFAULT_CRYPT)
|
||||
p.DotsStyles = nil
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *SwiperDot) SetStyle(style interface{}) *SwiperDot {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当前指示点索引,必须是通过 swiper 的 change 事件获取到的 e.detail.current
|
||||
func (p *SwiperDot) SetCurrent(current int) *SwiperDot {
|
||||
p.Current = current
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指示点的类型,可选值:default 、round 、nav 、 indexes
|
||||
func (p *SwiperDot) SetMode(mode string) *SwiperDot {
|
||||
p.Mode = mode
|
||||
return p
|
||||
}
|
||||
|
||||
// mode 为 nav 时,显示的内容字段(mode = nav 时必填)
|
||||
func (p *SwiperDot) SetField(field string) *SwiperDot {
|
||||
p.Field = field
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 轮播图的数据,通过数组长度决定指示点个数
|
||||
func (p *SwiperDot) SetItems(items interface{}) *SwiperDot {
|
||||
p.Items = items
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 轮播图的数据,通过数组长度决定指示点个数
|
||||
func (p *SwiperDot) SetBody(body interface{}) *SwiperDot {
|
||||
p.Items = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指示点样式
|
||||
func (p *SwiperDot) SetDotsStyles(dotsStyles interface{}) *SwiperDot {
|
||||
p.DotsStyles = dotsStyles
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *SwiperDot) JsonSerialize() *SwiperDot {
|
||||
p.Component = "swiperDot"
|
||||
|
||||
return p
|
||||
}
|
78
pkg/component/mix/swiper/dotstyle.go
Normal file
78
pkg/component/mix/swiper/dotstyle.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package swiper
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type DotStyle struct {
|
||||
component.Element
|
||||
Width int `json:"width"`
|
||||
Bottom int `json:"bottom"`
|
||||
Color string `json:"color"`
|
||||
BackgroundColor string `json:"backgroundColor"`
|
||||
Border string `json:"border"`
|
||||
SelectedBackgroundColor string `json:"selectedBackgroundColor"`
|
||||
SelectedBorder string `json:"selectedBorder"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *DotStyle) Init() *DotStyle {
|
||||
p.Component = "dotStyle"
|
||||
p.SetKey("dotStyle", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指示点宽度 在 mode = nav、mode = indexes 时不生效
|
||||
func (p *DotStyle) SetWidth(width int) *DotStyle {
|
||||
p.Width = width
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指示点距 swiper 底部的高度
|
||||
func (p *DotStyle) SetBottom(bottom int) *DotStyle {
|
||||
p.Bottom = bottom
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指示点前景色,只在 mode = nav ,mode = indexes 时生效
|
||||
func (p *DotStyle) SetColor(color string) *DotStyle {
|
||||
p.Color = color
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 未选择指示点背景色
|
||||
func (p *DotStyle) SetBackgroundColor(backgroundColor string) *DotStyle {
|
||||
p.BackgroundColor = backgroundColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 未选择指示点边框样式
|
||||
func (p *DotStyle) SetBorder(border string) *DotStyle {
|
||||
p.Border = border
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 已选择指示点背景色,在 mode = nav 时不生效
|
||||
func (p *DotStyle) SetSelectedBackgroundColor(selectedBackgroundColor string) *DotStyle {
|
||||
p.SelectedBackgroundColor = selectedBackgroundColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 已选择指示点边框样式,在 mode = nav 时不生效
|
||||
func (p *DotStyle) SetSelectedBorder(selectedBorder string) *DotStyle {
|
||||
p.SelectedBorder = selectedBorder
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *DotStyle) JsonSerialize() *DotStyle {
|
||||
p.Component = "dotStyle"
|
||||
|
||||
return p
|
||||
}
|
45
pkg/component/mix/swiper/item.go
Normal file
45
pkg/component/mix/swiper/item.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package swiper
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type SwiperItem struct {
|
||||
component.Element
|
||||
Title string `json:"title"`
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *SwiperItem) Init() *SwiperItem {
|
||||
p.Component = "swiperItem"
|
||||
p.SetKey("swiperItem", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *SwiperItem) SetStyle(style interface{}) *SwiperItem {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 标题
|
||||
func (p *SwiperItem) SetTitle(title string) *SwiperItem {
|
||||
p.Title = title
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 内容
|
||||
func (p *SwiperItem) SetBody(body interface{}) *SwiperItem {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *SwiperItem) JsonSerialize() *SwiperItem {
|
||||
p.Component = "swiperItem"
|
||||
|
||||
return p
|
||||
}
|
226
pkg/component/mix/swiper/swiper.go
Normal file
226
pkg/component/mix/swiper/swiper.go
Normal file
@@ -0,0 +1,226 @@
|
||||
package swiper
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
IndicatorDots bool `json:"indicatorDots"`
|
||||
IndicatorColor string `json:"indicatorColor"`
|
||||
IndicatorActiveColor string `json:"indicatorActiveColor"`
|
||||
ActiveClass string `json:"activeClass"`
|
||||
ChangingClass string `json:"changingClass"`
|
||||
Autoplay bool `json:"autoplay"`
|
||||
Current int `json:"current"`
|
||||
CurrentItemId string `json:"currentItemId"`
|
||||
Interval int `json:"interval"`
|
||||
Duration int `json:"duration"`
|
||||
Circular bool `json:"circular"`
|
||||
Vertical bool `json:"vertical"`
|
||||
PreviousMargin string `json:"previousMargin"`
|
||||
NextMargin string `json:"nextMargin"`
|
||||
Acceleration bool `json:"acceleration"`
|
||||
DisableProgrammaticAnimation bool `json:"disableProgrammaticAnimation"`
|
||||
DisplayMultipleItems int `json:"displayMultipleItems"`
|
||||
SkipHiddenItemLayout bool `json:"skipHiddenItemLayout"`
|
||||
DisableTouch bool `json:"disableTouch"`
|
||||
Touchable bool `json:"touchable"`
|
||||
EasingFunction string `json:"easingFunction"`
|
||||
Items interface{} `json:"items"`
|
||||
ItemStyle interface{} `json:"itemStyle"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "swiper"
|
||||
p.SetKey("swiper", component.DEFAULT_CRYPT)
|
||||
p.IndicatorColor = "rgba(0, 0, 0, .3)"
|
||||
p.IndicatorActiveColor = "#000000"
|
||||
p.Interval = 5000
|
||||
p.Duration = 500
|
||||
p.DisplayMultipleItems = 1
|
||||
p.Touchable = true
|
||||
p.EasingFunction = "default"
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set ItemStyle.
|
||||
func (p *Component) SetItemStyle(style interface{}) *Component {
|
||||
p.ItemStyle = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示面板指示点
|
||||
func (p *Component) SetIndicatorDots(indicatorDots bool) *Component {
|
||||
p.IndicatorDots = indicatorDots
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指示点颜色
|
||||
func (p *Component) SetIndicatorColor(indicatorColor string) *Component {
|
||||
p.IndicatorColor = indicatorColor
|
||||
return p
|
||||
}
|
||||
|
||||
// 当前选中的指示点颜色
|
||||
func (p *Component) SetIndicatorActiveColor(indicatorActiveColor string) *Component {
|
||||
p.IndicatorActiveColor = indicatorActiveColor
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// swiper-item 可见时的 class
|
||||
func (p *Component) SetActiveClass(activeClass string) *Component {
|
||||
p.ActiveClass = activeClass
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// acceleration 设置为 true 时且处于滑动过程中,中间若干屏处于可见时的class
|
||||
func (p *Component) SetChangingClass(changingClass string) *Component {
|
||||
p.ChangingClass = changingClass
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否自动切换
|
||||
func (p *Component) SetAutoplay(autoplay bool) *Component {
|
||||
p.Autoplay = autoplay
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当前所在滑块的 index
|
||||
func (p *Component) SetCurrent(current int) *Component {
|
||||
p.Current = current
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当前所在滑块的 item-id ,不能与 current 被同时指定
|
||||
func (p *Component) SetCurrentItemId(currentItemId string) *Component {
|
||||
p.CurrentItemId = currentItemId
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 自动切换时间间隔
|
||||
func (p *Component) SetInterval(interval int) *Component {
|
||||
p.Interval = interval
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 滑动动画时长
|
||||
func (p *Component) SetDuration(duration int) *Component {
|
||||
p.Duration = duration
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否采用衔接滑动,即播放到末尾后重新回到开头
|
||||
func (p *Component) SetCircular(circular bool) *Component {
|
||||
p.Circular = circular
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 滑动方向是否为纵向
|
||||
func (p *Component) SetVertical(vertical bool) *Component {
|
||||
p.Vertical = vertical
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值
|
||||
func (p *Component) SetPreviousMargin(previousMargin string) *Component {
|
||||
p.PreviousMargin = previousMargin
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值
|
||||
func (p *Component) SetNextMargin(nextMargin string) *Component {
|
||||
p.NextMargin = nextMargin
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当开启时,会根据滑动速度,连续滑动多屏
|
||||
func (p *Component) SetAcceleration(acceleration bool) *Component {
|
||||
p.Acceleration = acceleration
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁用代码变动触发 swiper 切换时使用动画。
|
||||
func (p *Component) SetDisableProgrammaticAnimation(disableProgrammaticAnimation bool) *Component {
|
||||
p.DisableProgrammaticAnimation = disableProgrammaticAnimation
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 同时显示的滑块数量
|
||||
func (p *Component) SetDisplayMultipleItems(displayMultipleItems int) *Component {
|
||||
p.DisplayMultipleItems = displayMultipleItems
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息
|
||||
func (p *Component) SetSkipHiddenItemLayout(skipHiddenItemLayout bool) *Component {
|
||||
p.SkipHiddenItemLayout = skipHiddenItemLayout
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否禁止用户 touch 操作
|
||||
func (p *Component) SetDisableTouch(disableTouch bool) *Component {
|
||||
p.DisableTouch = disableTouch
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否监听用户的触摸事件,只在初始化时有效,不能动态变更
|
||||
func (p *Component) SetTouchable(touchable bool) *Component {
|
||||
p.Touchable = touchable
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定 swiper 切换缓动动画类型,有效值:default、linear、easeInCubic、easeOutCubic、easeInOutCubic
|
||||
func (p *Component) SetEasingFunction(easingFunction string) *Component {
|
||||
p.EasingFunction = easingFunction
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 轮播图的数据,通过数组长度决定指示点个数
|
||||
func (p *Component) SetItems(items interface{}) *Component {
|
||||
p.Items = items
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 轮播图的数据,通过数组长度决定指示点个数
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Items = body
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "swiper"
|
||||
|
||||
return p
|
||||
}
|
324
pkg/component/mix/video/video.go
Normal file
324
pkg/component/mix/video/video.go
Normal file
@@ -0,0 +1,324 @@
|
||||
package video
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Src string `json:"src"`
|
||||
Autoplay bool `json:"autoplay"`
|
||||
Loop bool `json:"loop"`
|
||||
Muted bool `json:"muted"`
|
||||
InitialTime int `json:"initialTime"`
|
||||
Duration int `json:"duration"`
|
||||
Controls bool `json:"controls"`
|
||||
DanmuList interface{} `json:"danmuList"`
|
||||
DanmuBtn bool `json:"danmuBtn"`
|
||||
EnableDanmu bool `json:"enableDanmu"`
|
||||
PageGesture bool `json:"pageGesture "`
|
||||
Direction int `json:"direction"`
|
||||
ShowProgress bool `json:"showProgress"`
|
||||
ShowFullscreenBtn bool `json:"showFullscreenBtn"`
|
||||
ShowPlayBtn bool `json:"showPlayBtn"`
|
||||
ShowCenterPlayBtn bool `json:"showCenterPlayBtn"`
|
||||
ShowLoading bool `json:"showLoading"`
|
||||
EnableProgressGesture bool `json:"enableProgressGesture"`
|
||||
ObjectFit string `json:"objectFit"`
|
||||
Poster string `json:"poster"`
|
||||
ShowMuteBtn bool `json:"showMuteBtn"`
|
||||
Title string `json:"title"`
|
||||
PlayBtnPosition string `json:"playBtnPosition"`
|
||||
MobilenetHintType int `json:"mobilenetHintType"`
|
||||
EnablePlayGesture bool `json:"enablePlayGesture"`
|
||||
AutoPauseIfNavigate bool `json:"autoPauseIfNavigate"`
|
||||
AutoPauseIfOpenNative bool `json:"autoPauseIfOpenNative"`
|
||||
VslideGesture bool `json:"vslideGesture"`
|
||||
VslideGestureInFullscreen bool `json:"vslideGestureInFullscreen"`
|
||||
AdUnitId string `json:"adUnitId"`
|
||||
PosterForCrawler string `json:"posterForCrawler"`
|
||||
Codec string `json:"codec"`
|
||||
HttpCache bool `json:"httpCache"`
|
||||
PlayStrategy int `json:"playStrategy"`
|
||||
Header interface{} `json:"header"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "video"
|
||||
p.Controls = true
|
||||
p.ShowProgress = true
|
||||
p.ShowFullscreenBtn = true
|
||||
p.ShowPlayBtn = true
|
||||
p.ShowCenterPlayBtn = true
|
||||
p.ShowLoading = true
|
||||
p.EnableProgressGesture = true
|
||||
p.ObjectFit = "contain"
|
||||
p.PlayBtnPosition = "bottom"
|
||||
p.MobilenetHintType = 1
|
||||
p.AutoPauseIfNavigate = true
|
||||
p.AutoPauseIfOpenNative = true
|
||||
p.VslideGestureInFullscreen = true
|
||||
p.Codec = "hardware"
|
||||
p.HttpCache = true
|
||||
p.PlayStrategy = 0
|
||||
p.SetKey("video", component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 要播放视频的资源地址
|
||||
func (p *Component) SetSrc(src string) *Component {
|
||||
p.Src = src
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否自动播放
|
||||
func (p *Component) SetAutoplay(autoplay bool) *Component {
|
||||
p.Autoplay = autoplay
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否循环播放
|
||||
func (p *Component) SetLoop(loop bool) *Component {
|
||||
p.Loop = loop
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否静音播放
|
||||
func (p *Component) SetMuted(muted bool) *Component {
|
||||
p.Muted = muted
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定视频初始播放位置,单位为秒(s)。
|
||||
func (p *Component) SetInitialTime(initialTime int) *Component {
|
||||
p.InitialTime = initialTime
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 指定视频时长,单位为秒(s)。
|
||||
func (p *Component) SetDuration(duration int) *Component {
|
||||
p.Duration = duration
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示默认播放控件(播放/暂停按钮、播放进度、时间)
|
||||
func (p *Component) SetControls(controls bool) *Component {
|
||||
p.Controls = controls
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 弹幕列表
|
||||
func (p *Component) SetDanmuList(danmuList interface{}) *Component {
|
||||
p.DanmuList = danmuList
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示弹幕按钮,只在初始化时有效,不能动态变更
|
||||
func (p *Component) SetDanmuBtn(danmuBtn bool) *Component {
|
||||
p.DanmuBtn = danmuBtn
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否展示弹幕,只在初始化时有效,不能动态变更
|
||||
func (p *Component) SetEnableDanmu(enableDanmu bool) *Component {
|
||||
p.EnableDanmu = enableDanmu
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 在非全屏模式下,是否开启亮度与音量调节手势
|
||||
func (p *Component) SetPageGesture(pageGesture bool) *Component {
|
||||
p.PageGesture = pageGesture
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置全屏时视频的方向,不指定则根据宽高比自动判断。有效值为 0(正常竖向), 90(屏幕逆时针90度), -90(屏幕顺时针90度)
|
||||
func (p *Component) SetDirection(direction int) *Component {
|
||||
p.Direction = direction
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 若不设置,宽度大于240时才会显示
|
||||
func (p *Component) SetShowProgress(showProgress bool) *Component {
|
||||
p.ShowFullscreenBtn = showProgress
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示全屏按钮
|
||||
func (p *Component) SetShowFullscreenBtn(showFullscreenBtn bool) *Component {
|
||||
p.ShowFullscreenBtn = showFullscreenBtn
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示视频底部控制栏的播放按钮
|
||||
func (p *Component) SetShowPlayBtn(showPlayBtn bool) *Component {
|
||||
p.ShowPlayBtn = showPlayBtn
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示视频中间的播放按钮
|
||||
func (p *Component) SetShowCenterPlayBtn(showCenterPlayBtn bool) *Component {
|
||||
p.ShowCenterPlayBtn = showCenterPlayBtn
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示loading控件
|
||||
func (p *Component) SetShowLoading(showLoading bool) *Component {
|
||||
p.ShowLoading = showLoading
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否开启控制进度的手势
|
||||
func (p *Component) SetEnableProgressGesture(enableProgressGesture bool) *Component {
|
||||
p.EnableProgressGesture = enableProgressGesture
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当视频大小与 video 容器大小不一致时,视频的表现形式。contain:包含,fill:填充,cover:覆盖
|
||||
func (p *Component) SetObjectFit(objectFit string) *Component {
|
||||
p.ObjectFit = objectFit
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 视频封面的图片网络资源地址,如果 controls 属性值为 false 则设置 poster 无效
|
||||
func (p *Component) SetPoster(poster string) *Component {
|
||||
p.Poster = poster
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否显示静音按钮
|
||||
func (p *Component) SetShowMuteBtn(showMuteBtn bool) *Component {
|
||||
p.ShowMuteBtn = showMuteBtn
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 视频的标题,全屏时在顶部展示
|
||||
func (p *Component) SetTitle(title string) *Component {
|
||||
p.Title = title
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 播放按钮的位置
|
||||
func (p *Component) SetPlayBtnPosition(playBtnPosition string) *Component {
|
||||
p.PlayBtnPosition = playBtnPosition
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 移动网络提醒样式:0是不提醒,1是提醒,默认值为1
|
||||
func (p *Component) SetMobilenetHintType(mobilenetHintType int) *Component {
|
||||
p.MobilenetHintType = mobilenetHintType
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否开启播放手势,即双击切换播放/暂停
|
||||
func (p *Component) SetEnablePlayGesture(enablePlayGesture bool) *Component {
|
||||
p.EnablePlayGesture = enablePlayGesture
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当跳转到其它小程序页面时,是否自动暂停本页面的视频
|
||||
func (p *Component) SetAutoPauseIfNavigate(autoPauseIfNavigate bool) *Component {
|
||||
p.AutoPauseIfNavigate = autoPauseIfNavigate
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 当跳转到其它微信原生页面时,是否自动暂停本页面的视频
|
||||
func (p *Component) SetAutoPauseIfOpenNative(autoPauseIfOpenNative bool) *Component {
|
||||
p.AutoPauseIfOpenNative = autoPauseIfOpenNative
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 在非全屏模式下,是否开启亮度与音量调节手势(同 page-gesture)
|
||||
func (p *Component) SetVslideGesture(vslideGesture bool) *Component {
|
||||
p.VslideGesture = vslideGesture
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 在全屏模式下,是否开启亮度与音量调节手势
|
||||
func (p *Component) SetVslideGestureInFullscreen(vslideGestureInFullscreen bool) *Component {
|
||||
p.VslideGestureInFullscreen = vslideGestureInFullscreen
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 视频前贴广告单元ID,更多详情可参考开放能力视频前贴广告
|
||||
func (p *Component) SetAdUnitId(adUnitId string) *Component {
|
||||
p.AdUnitId = adUnitId
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 用于给搜索等场景作为视频封面展示,建议使用无播放 icon 的视频封面图,只支持网络地址
|
||||
func (p *Component) SetPosterForCrawler(posterForCrawler string) *Component {
|
||||
p.PosterForCrawler = posterForCrawler
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 解码器选择,hardware:硬解码(硬解码可以增加解码算力,提高视频清晰度。少部分老旧硬件可能存在兼容性问题);software:ffmpeg 软解码;
|
||||
func (p *Component) SetCodec(codec string) *Component {
|
||||
p.Codec = codec
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 是否对 http、https 视频源开启本地缓存。缓存策略:开启了此开关的视频源,在视频播放时会在本地保存缓存文件,如果本地缓存池已超过100M,在进行缓存前会清空之前的缓存(不适用于m3u8等流媒体协议)
|
||||
func (p *Component) SetHttpCache(httpCache bool) *Component {
|
||||
p.HttpCache = httpCache
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 播放策略,0:普通模式,适合绝大部分视频播放场景;1:平滑播放模式(降级),增加缓冲区大小,采用open sl解码音频,避免音视频脱轨的问题,可能会降低首屏展现速度、视频帧率,出现开屏音频延迟等。 适用于高码率视频的极端场景;2: M3U8优化模式,增加缓冲区大小,提升视频加载速度和流畅度,可能会降低首屏展现速度。 适用于M3U8在线播放的场景
|
||||
func (p *Component) SetPlayStrategy(playStrategy int) *Component {
|
||||
p.PlayStrategy = playStrategy
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// HTTP 请求 Header
|
||||
func (p *Component) SetHeader(header interface{}) *Component {
|
||||
p.Header = header
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 组件json序列化
|
||||
func (p *Component) JsonSerialize() *Component {
|
||||
p.Component = "video"
|
||||
|
||||
return p
|
||||
}
|
30
pkg/component/mix/view/view.go
Normal file
30
pkg/component/mix/view/view.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package view
|
||||
|
||||
import "github.com/quarkcms/quark-go/pkg/component/mix/component"
|
||||
|
||||
type Component struct {
|
||||
component.Element
|
||||
Body interface{} `json:"body"`
|
||||
}
|
||||
|
||||
// 初始化
|
||||
func (p *Component) Init() *Component {
|
||||
p.Component = "view"
|
||||
p.SetKey(component.DEFAULT_KEY, component.DEFAULT_CRYPT)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// Set style.
|
||||
func (p *Component) SetStyle(style interface{}) *Component {
|
||||
p.Style = style
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// 容器控件里面的内容
|
||||
func (p *Component) SetBody(body interface{}) *Component {
|
||||
p.Body = body
|
||||
|
||||
return p
|
||||
}
|
Reference in New Issue
Block a user