mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
add some
This commit is contained in:
parent
8f98a1db7a
commit
0efa99e9c6
@ -86,6 +86,7 @@ const (
|
|||||||
NEXT = "next"
|
NEXT = "next"
|
||||||
PREV = "prev"
|
PREV = "prev"
|
||||||
PAGE = "page"
|
PAGE = "page"
|
||||||
|
OFFEND = "offend"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
CACHE_CLEAR_ON_EXIT = "cache.clear.on.exit"
|
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) {
|
func PrevPage(m *ice.Message, total string, arg ...string) {
|
||||||
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||||
offends := kit.Int(offend) - kit.Int(limit)
|
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.Toast("已经是最前一页啦!")
|
||||||
m.ProcessHold()
|
m.ProcessHold()
|
||||||
return
|
return
|
||||||
@ -117,7 +118,7 @@ func PrevPage(m *ice.Message, total string, arg ...string) {
|
|||||||
func NextPage(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)
|
limit, offend := kit.Select("10", arg, 0), kit.Select("0", arg, 1)
|
||||||
offends := kit.Int(offend) + kit.Int(limit)
|
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.Toast("已经是最后一页啦!")
|
||||||
m.ProcessHold()
|
m.ProcessHold()
|
||||||
return
|
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)
|
m.Info("%s %s", req.Method, req.URL)
|
||||||
kit.Fetch(value[SPIDE_HEADER], func(key string, value string) {
|
kit.Fetch(value[SPIDE_HEADER], func(key string, value string) {
|
||||||
req.Header.Set(key, value)
|
req.Header.Set(key, value)
|
||||||
|
m.Logs(key, value)
|
||||||
})
|
})
|
||||||
kit.Fetch(value[SPIDE_COOKIE], func(key string, value string) {
|
kit.Fetch(value[SPIDE_COOKIE], func(key string, value string) {
|
||||||
req.AddCookie(&http.Cookie{Name: key, Value: value})
|
req.AddCookie(&http.Cookie{Name: key, Value: value})
|
||||||
@ -312,6 +313,7 @@ const (
|
|||||||
|
|
||||||
SPIDE_RES = "content_data"
|
SPIDE_RES = "content_data"
|
||||||
|
|
||||||
|
Authorization = "Authorization"
|
||||||
ContentType = "Content-Type"
|
ContentType = "Content-Type"
|
||||||
ContentLength = "Content-Length"
|
ContentLength = "Content-Length"
|
||||||
|
|
||||||
@ -332,7 +334,10 @@ const (
|
|||||||
RESPONSE = "response"
|
RESPONSE = "response"
|
||||||
|
|
||||||
CLIENT_NAME = "client.name"
|
CLIENT_NAME = "client.name"
|
||||||
|
CLIENT_URL = "client.url"
|
||||||
LOGHEADERS = "logheaders"
|
LOGHEADERS = "logheaders"
|
||||||
|
|
||||||
|
MERGE = "merge"
|
||||||
)
|
)
|
||||||
const SPIDE = "spide"
|
const SPIDE = "spide"
|
||||||
|
|
||||||
@ -351,8 +356,8 @@ func init() {
|
|||||||
mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS))
|
_spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS))
|
||||||
}},
|
}},
|
||||||
"merge": {Name: "merge name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
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:]))
|
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) {
|
}, 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] == "") {
|
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, KEY)
|
||||||
delete(m.meta, VALUE)
|
delete(m.meta, VALUE)
|
||||||
|
delete(m.meta, MSG_APPEND)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
@ -107,7 +108,8 @@ func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Messa
|
|||||||
head := kit.Simple()
|
head := kit.Simple()
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
head = kit.Simple(arg[0])
|
head = kit.Simple(arg[0])
|
||||||
} else { // 键值排序
|
}
|
||||||
|
if len(head) == 0 { // 键值排序
|
||||||
head = kit.SortedKey(kit.KeyValue(map[string]interface{}{}, "", value))
|
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 {
|
func (m *Message) PushDetail(value interface{}, arg ...interface{}) *Message {
|
||||||
return m.Push(CACHE_DETAIL, value, arg...)
|
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{} {
|
func (m *Message) OptionCB(key string, cb ...interface{}) interface{} {
|
||||||
if len(cb) > 0 {
|
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)))
|
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_LIMIT, kit.Select("", arg, 0))
|
||||||
m.Option(CACHE_OFFEND, kit.Select("", arg, 1))
|
m.Option(CACHE_OFFEND, kit.Select("", arg, 1))
|
||||||
m.Option(CACHE_FILTER, kit.Select("", arg, 2))
|
m.Option(CACHE_FILTER, kit.Select("", arg, 2))
|
||||||
m.Option("offend", kit.Select("", arg, 1))
|
m.Option("limit", kit.Select(m.Option("limit"), arg, 0))
|
||||||
m.Option("limit", kit.Select("", 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 {
|
func (m *Message) OptionLoad(file string) *Message {
|
||||||
if f, e := os.Open(file); e == nil {
|
if f, e := os.Open(file); e == nil {
|
||||||
@ -51,6 +52,12 @@ func (m *Message) OptionSplit(key ...string) (res []string) {
|
|||||||
}
|
}
|
||||||
return res
|
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) {
|
func (m *Message) OptionSimple(key ...string) (res []string) {
|
||||||
for _, k := range kit.Split(kit.Join(key)) {
|
for _, k := range kit.Split(kit.Join(key)) {
|
||||||
if k == "" || m.Option(k) == "" {
|
if k == "" || m.Option(k) == "" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user