form

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormTypeMessage uint8 = iota
	FormTypeAction
	FormTypeModal
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionForm

type ActionForm struct {
	Title   string
	Content string
	Buttons []ActionFormElement
}

ActionForm ..

func (ActionForm) ID

func (a ActionForm) ID() uint8

func (ActionForm) PackToJSON

func (a ActionForm) PackToJSON() string

type ActionFormElement

type ActionFormElement struct {
	Text string         // 按钮中的文字
	Icon ActionFormIcon // 按钮的图标,可以不使用
}

ActionFormElement ..

type ActionFormIcon

type ActionFormIcon any

type ActionFormIconNone

type ActionFormIconNone struct{}

type ActionFormIconPathImage

type ActionFormIconPathImage struct {
	ImagePath string // e.g. `textures/ui/anvil_icon.png`
}

type ActionFormIconURLImage

type ActionFormIconURLImage struct {
	ImageURL string // e.g. `https://avatars.githubusercontent.com/u/109064184`
}

type MessageForm

type MessageForm struct {
	Title   string `json:"title"`   // 标题
	Content string `json:"content"` // 内容
	Button1 string `json:"button1"` // 可以表示 “确定/取消” 的 “确定” 按钮
	Button2 string `json:"button2"` // 可以表示 “确定/取消” 的 “取消” 按钮
}

MessageForm ..

func (MessageForm) ID

func (m MessageForm) ID() uint8

func (MessageForm) PackToJSON

func (m MessageForm) PackToJSON() string

type MinecraftForm

type MinecraftForm interface {
	ID() uint8
	PackToJSON() string
}

MinecraftForm 是各种表单的类型的总称

type ModalForm

type ModalForm struct {
	Title    string             // 模态表单的标题
	Contents []ModalFormElement // 模态表单的各个内容
}

ModalForm ..

func (ModalForm) ID

func (m ModalForm) ID() uint8

func (ModalForm) PackToJSON

func (m ModalForm) PackToJSON() string

type ModalFormElement

type ModalFormElement any

ModalFormElement 是模态表单中各种元素类别的总称

type ModalFormElementDropdown

type ModalFormElementDropdown struct {
	Text    string   `json:"text"`    // 多选的标题
	Options []string `json:"options"` // 各个选项
	Default uint     `json:"default"` // 默认选项 (即上方 Options 的索引)
}

多选

type ModalFormElementInput

type ModalFormElementInput struct {
	Text        string `json:"text"`        // 输入框的标题
	Default     string `json:"default"`     // 输入框内的默认内容
	PlaceHolder string `json:"placeholder"` // 输入框的提示内容
}

输入框

type ModalFormElementLabel

type ModalFormElementLabel struct {
	Text string `json:"text"` // 对应的文本
}

普通文本

type ModalFormElementSlider

type ModalFormElementSlider struct {
	Text    string `json:"text"`    // 进度条的标题
	Min     int    `json:"min"`     // 进度条的最小值
	Max     int    `json:"max"`     // 进度条的最大值
	Step    int    `json:"step"`    // 用户调整进度条的最小单位 (或步进长度)
	Default int    `json:"default"` // 进度条的默认值
}

可拖拽的进度条

type ModalFormElementStepSlider

type ModalFormElementStepSlider struct {
	Text    string   `json:"text"`    // 滑块的标题
	Steps   []string `json:"steps"`   // 可以滑动选择的各个选项
	Default uint     `json:"default"` // 默认的选项 (即上方 Steps 的索引)
}

滑块

type ModalFormElementToggle

type ModalFormElementToggle struct {
	Text    string `json:"text"`    // 按钮的文字
	Default bool   `json:"default"` // 按钮的默认状态 (开/关)
}

按钮

Jump to

Keyboard shortcuts

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