forked from x/icebergs
opt some
This commit is contained in:
parent
7634b366e5
commit
8073489376
@ -6,9 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func _action_share_create(m *ice.Message, arg ...string) {
|
||||
m.Debug("info %v", arg)
|
||||
if m.Option("index") != "" {
|
||||
m.Debug("info %v", arg)
|
||||
m.Cmdy(ice.WEB_SHARE, ice.TYPE_ACTION, m.Option("name"), m.Option("text"),
|
||||
"tool.0.pod", kit.Select(m.Option("pod"), m.Option("node")),
|
||||
"tool.0.ctx", m.Option("group"),
|
||||
@ -17,7 +15,6 @@ func _action_share_create(m *ice.Message, arg ...string) {
|
||||
"tool.0.value", m.Option("value"),
|
||||
"tool.0.single", "yes",
|
||||
)
|
||||
return
|
||||
} else {
|
||||
m.Option(ice.MSG_RIVER, arg[5])
|
||||
m.Option(ice.MSG_STORM, arg[7])
|
||||
@ -61,6 +58,37 @@ func _action_share_update(m *ice.Message, c *ice.Context, cmd string, arg ...str
|
||||
})
|
||||
})
|
||||
}
|
||||
func _action_order(m *ice.Message, arg ...string) {
|
||||
if arg[2] == "index" {
|
||||
for i, v := range arg[3:] {
|
||||
m.Push("river", arg[0])
|
||||
m.Push("storm", arg[1])
|
||||
m.Push("action", i)
|
||||
|
||||
m.Push("node", "")
|
||||
m.Push("group", "")
|
||||
m.Push("index", v)
|
||||
m.Push("args", "[]")
|
||||
|
||||
msg := m.Cmd(m.Space(m.Option("pod")), ice.CTX_COMMAND, v)
|
||||
m.Push("name", msg.Append("name"))
|
||||
m.Push("help", msg.Append("help"))
|
||||
m.Push("feature", msg.Append("meta"))
|
||||
m.Push("inputs", msg.Append("list"))
|
||||
}
|
||||
}
|
||||
if len(arg) > 3 && arg[3] == "action" && _action_action(m, arg[4], arg[5:]...) {
|
||||
return
|
||||
}
|
||||
|
||||
cmds := kit.Simple(kit.Keys(m.Option("group"), m.Option("index")), arg[3:])
|
||||
if m.Set(ice.MSG_RESULT); !m.Right(cmds) {
|
||||
m.Render("status", 403, "not auth")
|
||||
return
|
||||
}
|
||||
m.Add("option", "_option", "data", "name")
|
||||
m.Cmdy(_action_proxy(m), cmds).Option("cmds", cmds)
|
||||
}
|
||||
|
||||
func _action_proxy(m *ice.Message) (proxy []string) {
|
||||
if m.Option("pod") != "" {
|
||||
@ -75,26 +103,9 @@ func _action_action(m *ice.Message, action string, arg ...string) bool {
|
||||
msg := m.Cmd(ice.WEB_STORY, "upload")
|
||||
m.Option("name", msg.Append("name"))
|
||||
m.Option("data", msg.Append("data"))
|
||||
m.Debug("what", m.Option("name"))
|
||||
m.Debug("what", m.Option("data"))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func _action_order(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 3 && arg[3] == "action" && _action_action(m, arg[4], arg[5:]...) {
|
||||
return
|
||||
}
|
||||
|
||||
cmds := kit.Simple(kit.Keys(m.Option("group"), m.Option("index")), arg[3:])
|
||||
if m.Set(ice.MSG_RESULT); !m.Right(cmds) {
|
||||
m.Render("status", 403, "not auth")
|
||||
return
|
||||
}
|
||||
m.Add("option", "_option", "data", "name")
|
||||
m.Cmdy(_action_proxy(m), cmds).Option("cmds", cmds)
|
||||
}
|
||||
|
||||
func _action_select(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
prefix := kit.Keys(kit.MDB_HASH, arg[0], "tool", kit.MDB_HASH, arg[1])
|
||||
m.Grows(ice.CHAT_RIVER, prefix, "", "", func(index int, value map[string]interface{}) {
|
||||
@ -116,7 +127,6 @@ func _action_select(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
"/action": {Name: "/action", Help: "工作台", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
@ -125,7 +135,6 @@ func init() {
|
||||
_action_share_create(m, arg...)
|
||||
return
|
||||
}
|
||||
|
||||
if len(arg) == 0 || arg[0] == "" {
|
||||
if m.Option("share") != "" {
|
||||
if len(arg) < 3 {
|
||||
@ -177,14 +186,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
if m.Option("_action") == "上传" {
|
||||
msg := m.Cmd(ice.WEB_CACHE, "upload")
|
||||
m.Option("_data", msg.Append("data"))
|
||||
m.Option("_name", msg.Append("name"))
|
||||
m.Cmd(ice.WEB_FAVOR, "upload", msg.Append("type"), msg.Append("name"), msg.Append("data"))
|
||||
m.Option("_option", m.Optionv("option"))
|
||||
}
|
||||
|
||||
// 查询命令
|
||||
cmds := []string{}
|
||||
m.Grows(ice.CHAT_RIVER, prefix, kit.MDB_ID, kit.Format(kit.Int(arg[2])+1), func(index int, value map[string]interface{}) {
|
||||
|
@ -212,7 +212,7 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
|
||||
})
|
||||
}},
|
||||
"plan": {Name: "plan scale:select=day|week|month|year begin_time=@date end_time=@date auto", Help: "计划", Meta: kit.Dict(
|
||||
"display", "local/team/plan", "detail", []string{"process", "finish", "cancel"},
|
||||
"display", "/plugin/local/team/plan.js", "detail", []string{"process", "finish", "cancel"},
|
||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
// 起始日期
|
||||
first := time.Now()
|
||||
|
@ -194,14 +194,15 @@ func init() {
|
||||
"project": {Name: "project path", Help: "项目", Hand: func(m *ice.Message, arg ...string) {
|
||||
_inner_list(m, path.Join("./", kit.Select("", arg, 0))+"/")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == "action" {
|
||||
if m.Cmdy(kit.Split(arg[1])); !m.Hand {
|
||||
m.Cmdy(ice.CLI_SYSTEM, kit.Split(arg[1]))
|
||||
"find": {Name: "find word", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||
web.FavorList(m, arg[0], arg[1], arg[2:]...)
|
||||
}},
|
||||
"action": {Name: "action path", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(kit.Split(arg[0])); !m.Hand {
|
||||
m.Cmdy(ice.CLI_SYSTEM, kit.Split(arg[0]))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_inner_main(m, arg...)
|
||||
}},
|
||||
|
||||
|
2
info.go
2
info.go
@ -33,7 +33,7 @@ func (m *Message) log(level string, str string, arg ...interface{}) *Message {
|
||||
}
|
||||
|
||||
switch level {
|
||||
case LOG_CMDS, LOG_INFO, LOG_WARN, LOG_AUTH, LOG_COST:
|
||||
case LOG_CMDS, LOG_INFO, LOG_WARN:
|
||||
default:
|
||||
_, file, line, _ := runtime.Caller(2)
|
||||
ls := strings.Split(file, "/")
|
||||
|
@ -99,7 +99,7 @@ var Index = &ice.Context{Name: "chrome", Help: "浏览器",
|
||||
"/favor": {Name: "/favor", Help: "收藏", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
// 添加收藏
|
||||
m.Cmdy(ice.WEB_FAVOR, m.Option("tab"), ice.TYPE_SPIDE, m.Option("note"), arg[0])
|
||||
web.FavorInsert(m, m.Option("tab"), ice.TYPE_SPIDE, m.Option("note"), arg[0])
|
||||
return
|
||||
}
|
||||
}},
|
||||
|
14
type.go
14
type.go
@ -85,21 +85,31 @@ func (c *Context) Run(m *Message, cmd *Command, key string, arg ...string) *Mess
|
||||
action, args = arg[1], arg[2:]
|
||||
}
|
||||
|
||||
p := reflect.ValueOf(cmd.Hand)
|
||||
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(p.Pointer(), 3))
|
||||
if m.Hand = true; len(arg) > 1 && action != "" && cmd.Action != nil {
|
||||
if h, ok := cmd.Action[action]; ok {
|
||||
p := reflect.ValueOf(h.Hand)
|
||||
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(p.Pointer(), 3))
|
||||
h.Hand(m, args...)
|
||||
return m
|
||||
}
|
||||
for _, h := range cmd.Action {
|
||||
if h.Name == action || h.Help == action {
|
||||
p := reflect.ValueOf(h.Hand)
|
||||
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(p.Pointer(), 3))
|
||||
h.Hand(m, args...)
|
||||
return m
|
||||
}
|
||||
}
|
||||
if h, ok := cmd.Action["action"]; ok {
|
||||
p := reflect.ValueOf(h.Hand)
|
||||
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(p.Pointer(), 3))
|
||||
h.Hand(m, arg[1:]...)
|
||||
return m
|
||||
}
|
||||
}
|
||||
|
||||
p := reflect.ValueOf(cmd.Hand)
|
||||
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(p.Pointer(), 3))
|
||||
cmd.Hand(m, c, key, arg...)
|
||||
return m
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user