forked from x/icebergs
add some
This commit is contained in:
parent
8f98a1db7a
commit
0efa99e9c6
@ -83,9 +83,10 @@ const (
|
||||
REVERT = "revert"
|
||||
REPEAT = "repeat"
|
||||
|
||||
NEXT = "next"
|
||||
PREV = "prev"
|
||||
PAGE = "page"
|
||||
NEXT = "next"
|
||||
PREV = "prev"
|
||||
PAGE = "page"
|
||||
OFFEND = "offend"
|
||||
)
|
||||
const (
|
||||
CACHE_CLEAR_ON_EXIT = "cache.clear.on.exit"
|
||||
@ -102,7 +103,7 @@ func PrevPageLimit(m *ice.Message, total string, arg ...string) {
|
||||
func PrevPage(m *ice.Message, total string, arg ...string) {
|
||||
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||
offends := kit.Int(offend) - kit.Int(limit)
|
||||
if offends <= -kit.Int(total) || offends >= kit.Int(total) {
|
||||
if total != "0" && (offends <= -kit.Int(total) || offends >= kit.Int(total)) {
|
||||
m.Toast("已经是最前一页啦!")
|
||||
m.ProcessHold()
|
||||
return
|
||||
@ -117,7 +118,7 @@ func PrevPage(m *ice.Message, total string, arg ...string) {
|
||||
func NextPage(m *ice.Message, total string, arg ...string) {
|
||||
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||
offends := kit.Int(offend) + kit.Int(limit)
|
||||
if offends <= -kit.Int(total) || offends >= kit.Int(total) {
|
||||
if total != "0" && (offends <= -kit.Int(total) || offends >= kit.Int(total)) {
|
||||
m.Toast("已经是最后一页啦!")
|
||||
m.ProcessHold()
|
||||
return
|
||||
|
@ -218,6 +218,7 @@ func _spide_head(m *ice.Message, req *http.Request, head map[string]string, valu
|
||||
m.Info("%s %s", req.Method, req.URL)
|
||||
kit.Fetch(value[SPIDE_HEADER], func(key string, value string) {
|
||||
req.Header.Set(key, value)
|
||||
m.Logs(key, value)
|
||||
})
|
||||
kit.Fetch(value[SPIDE_COOKIE], func(key string, value string) {
|
||||
req.AddCookie(&http.Cookie{Name: key, Value: value})
|
||||
@ -312,6 +313,7 @@ const (
|
||||
|
||||
SPIDE_RES = "content_data"
|
||||
|
||||
Authorization = "Authorization"
|
||||
ContentType = "Content-Type"
|
||||
ContentLength = "Content-Length"
|
||||
|
||||
@ -332,7 +334,10 @@ const (
|
||||
RESPONSE = "response"
|
||||
|
||||
CLIENT_NAME = "client.name"
|
||||
CLIENT_URL = "client.url"
|
||||
LOGHEADERS = "logheaders"
|
||||
|
||||
MERGE = "merge"
|
||||
)
|
||||
const SPIDE = "spide"
|
||||
|
||||
@ -351,8 +356,8 @@ func init() {
|
||||
mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS))
|
||||
}},
|
||||
"merge": {Name: "merge name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(kit.MergeURL(m.Cmd(SPIDE, arg[0], ice.OptionFields("")).Append("client.url")+arg[1], arg[2:]))
|
||||
MERGE: {Name: "merge name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(kit.MergeURL2(m.Cmd(SPIDE, arg[0], ice.OptionFields("")).Append(CLIENT_URL), arg[1], arg[2:]))
|
||||
}},
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
|
||||
|
4
meta.go
4
meta.go
@ -33,6 +33,7 @@ func (m *Message) Set(key string, arg ...string) *Message {
|
||||
}
|
||||
delete(m.meta, KEY)
|
||||
delete(m.meta, VALUE)
|
||||
delete(m.meta, MSG_APPEND)
|
||||
return m
|
||||
}
|
||||
if len(arg) > 0 {
|
||||
@ -107,7 +108,8 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
|
||||
head := kit.Simple()
|
||||
if len(arg) > 0 {
|
||||
head = kit.Simple(arg[0])
|
||||
} else { // 键值排序
|
||||
}
|
||||
if len(head) == 0 { // 键值排序
|
||||
head = kit.SortedKey(kit.KeyValue(map[string]interface{}{}, "", value))
|
||||
}
|
||||
|
||||
|
3
misc.go
3
misc.go
@ -77,6 +77,9 @@ func (m *Message) SplitIndex(str string, arg ...string) *Message {
|
||||
func (m *Message) PushDetail(value interface{}, arg ...interface{}) *Message {
|
||||
return m.Push(CACHE_DETAIL, value, arg...)
|
||||
}
|
||||
func (m *Message) PushRecord(value interface{}, arg ...string) *Message {
|
||||
return m.Push("", value, kit.Split(kit.Join(arg)))
|
||||
}
|
||||
|
||||
func (m *Message) OptionCB(key string, cb ...interface{}) interface{} {
|
||||
if len(cb) > 0 {
|
||||
|
13
option.go
13
option.go
@ -25,12 +25,13 @@ func (m *Message) OptionFields(arg ...string) string {
|
||||
}
|
||||
return kit.Join(kit.Simple(m.Optionv(MSG_FIELDS)))
|
||||
}
|
||||
func (m *Message) OptionPage(arg ...string) {
|
||||
func (m *Message) OptionPage(arg ...string) int {
|
||||
m.Option(CACHE_LIMIT, kit.Select("", arg, 0))
|
||||
m.Option(CACHE_OFFEND, kit.Select("", arg, 1))
|
||||
m.Option(CACHE_FILTER, kit.Select("", arg, 2))
|
||||
m.Option("offend", kit.Select("", arg, 1))
|
||||
m.Option("limit", kit.Select("", arg, 0))
|
||||
m.Option("limit", kit.Select(m.Option("limit"), arg, 0))
|
||||
m.Option("offend", kit.Select(m.Option("offend"), arg, 1))
|
||||
return kit.Int(m.Option("offend"))/kit.Int(kit.Select("10", m.Option("limit"))) + 1
|
||||
}
|
||||
func (m *Message) OptionLoad(file string) *Message {
|
||||
if f, e := os.Open(file); e == nil {
|
||||
@ -51,6 +52,12 @@ func (m *Message) OptionSplit(key ...string) (res []string) {
|
||||
}
|
||||
return res
|
||||
}
|
||||
func (m *Message) OptionDefault(key, value string) string {
|
||||
if m.Option(key) == "" {
|
||||
m.Option(key, value)
|
||||
}
|
||||
return m.Option(key)
|
||||
}
|
||||
func (m *Message) OptionSimple(key ...string) (res []string) {
|
||||
for _, k := range kit.Split(kit.Join(key)) {
|
||||
if k == "" || m.Option(k) == "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user