From 07156e688efa03a7a961a1063fa33c1cb33756d8 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Wed, 4 Aug 2021 21:16:49 +0800 Subject: [PATCH] opt some --- base/mdb/hash.go | 5 ++++- conf.go | 1 + core/chat/action.go | 2 +- core/chat/cmd.go | 6 +++++- core/code/case.go | 2 +- core/team/task.go | 4 ++-- core/wiki/json.go | 8 +++----- misc/trash/web/_favor.go | 2 +- option.go | 4 ++++ 9 files changed, 22 insertions(+), 12 deletions(-) diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 312b27f5..a8d72e4a 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -130,6 +130,9 @@ func _hash_inputs(m *ice.Message, prefix, chain string, field, value string) { if field == kit.MDB_HASH { list[key]++ } else { + if kit.Format(val["count"]) != "" { + list[kit.Format(val[field])] = kit.Int(val["count"]) + } list[kit.Format(val[field])]++ } }) @@ -137,7 +140,7 @@ func _hash_inputs(m *ice.Message, prefix, chain string, field, value string) { m.Push(field, k) m.Push(kit.MDB_COUNT, i) } - m.Sort(kit.MDB_COUNT, "int_r") + m.SortIntR(kit.MDB_COUNT) } func HashAction(fields ...string) map[string]*ice.Action { diff --git a/conf.go b/conf.go index b0a5f2a9..4f17aac5 100644 --- a/conf.go +++ b/conf.go @@ -146,6 +146,7 @@ const ( // PROCESS PROCESS_LOCATION = "_location" PROCESS_REFRESH = "_refresh" PROCESS_REWRITE = "_rewrite" + PROCESS_DISPLAY = "_display" PROCESS_FIELD = "_field" PROCESS_INNER = "_inner" diff --git a/core/chat/action.go b/core/chat/action.go index 6f70abdd..78b7c329 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -86,7 +86,7 @@ func _action_show(m *ice.Message, river, storm, index string, arg ...string) { m.Cmdy(cmds, arg) // 执行命令 } } -func _action_upload(m *ice.Message, arg ...string) { +func _action_upload(m *ice.Message) { msg := m.Cmd(web.CACHE, web.UPLOAD) m.Option(ice.MSG_UPLOAD, msg.Append(kit.MDB_HASH), msg.Append(kit.MDB_NAME), msg.Append(kit.MDB_SIZE)) } diff --git a/core/chat/cmd.go b/core/chat/cmd.go index e9c2044f..f2b9e161 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -55,7 +55,11 @@ func init() { m.RenderDownload(p) } }}, - CMD: {Name: "cmd path auto up home", Help: "命令", Action: map[string]*ice.Action{ + CMD: {Name: "cmd path auto upload up home", Help: "命令", Action: map[string]*ice.Action{ + web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) { + _action_upload(m) + m.Upload(path.Join(m.Conf(CMD, kit.META_PATH), strings.TrimPrefix(path.Dir(m.R.URL.Path), "/cmd"))) + }}, "home": {Name: "home", Help: "根目录", Hand: func(m *ice.Message, arg ...string) { m.ProcessLocation("/chat/cmd/") }}, diff --git a/core/code/case.go b/core/code/case.go index a11a698f..3d7c19dd 100644 --- a/core/code/case.go +++ b/core/code/case.go @@ -26,7 +26,7 @@ func init() { m.Echo(kit.Formats(kit.UnMarshal(m.Cmdx(web.SPIDE, web.SPIDE_DEV, web.SPIDE_RAW, m.Option(cli.CMD), m.Option(cli.API), web.SPIDE_DATA, m.Option(cli.ARG))))) m.Info(`curl "` + m.Option(cli.API) + `" -H "Content-Type: application/json"` + ` -d '` + m.Option(cli.ARG) + `'`) - m.ProcessInner() + m.ProcessDisplay("/plugin/local/wiki/json.js") }}, cli.CHECK: {Name: "check", Help: "检查", Hand: func(m *ice.Message, arg ...string) { if m.ProcessInner(); len(arg) > 0 { diff --git a/core/team/task.go b/core/team/task.go index ea8e19f5..da6362f5 100644 --- a/core/team/task.go +++ b/core/team/task.go @@ -142,7 +142,7 @@ func init() { ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Cmd(mdb.SEARCH, mdb.CREATE, TASK, m.Prefix(TASK)) }}, - TASK: {Name: "task zone id auto insert export import", Help: "任务", Action: map[string]*ice.Action{ + TASK: {Name: "task zone id auto insert export import", Help: "任务", Action: ice.MergeAction(map[string]*ice.Action{ mdb.INSERT: {Name: "insert zone type=once,step,week name text begin_time@date close_time@date", Help: "添加", Hand: func(m *ice.Message, arg ...string) { _task_create(m, arg[1]) _task_insert(m, arg[1], arg[2:]...) @@ -181,7 +181,7 @@ func init() { END: {Name: "end", Help: "完成", Hand: func(m *ice.Message, arg ...string) { _task_modify(m, STATUS, FINISH) }}, - }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Fields(len(arg), "time,zone,count", m.Conf(TASK, kit.META_FIELD)) if m.Cmdy(mdb.SELECT, m.Prefix(TASK), "", mdb.ZONE, arg); len(arg) == 0 { m.PushAction(mdb.REMOVE) diff --git a/core/wiki/json.go b/core/wiki/json.go index d463babb..157f4422 100644 --- a/core/wiki/json.go +++ b/core/wiki/json.go @@ -11,14 +11,12 @@ const JSON = "json" func init() { Index.Merge(&ice.Context{ Configs: map[string]*ice.Config{ - JSON: {Name: JSON, Help: "数据表格", Value: kit.Data( - kit.MDB_PATH, ice.USR_LOCAL_EXPORT, kit.MDB_REGEXP, ".*\\.csv", + JSON: {Name: JSON, Help: "数据结构", Value: kit.Data( + kit.MDB_PATH, ice.USR_LOCAL_EXPORT, kit.MDB_REGEXP, ".*\\.json", )}, }, Commands: map[string]*ice.Command{ - JSON: {Name: "json path auto", Help: "数据结构", Meta: kit.Dict( - ice.Display("/plugin/local/wiki/json.js"), - ), Action: map[string]*ice.Action{ + JSON: {Name: "json path auto", Help: "数据结构", Meta: kit.Dict(ice.Display("/plugin/local/wiki/json.js")), Action: map[string]*ice.Action{ nfs.SAVE: {Name: "save path text", Help: "保存", Hand: func(m *ice.Message, arg ...string) { _wiki_save(m, JSON, arg[0], arg[1]) }}, diff --git a/misc/trash/web/_favor.go b/misc/trash/web/_favor.go index 460cf61d..3168656f 100644 --- a/misc/trash/web/_favor.go +++ b/misc/trash/web/_favor.go @@ -26,7 +26,7 @@ func _favor_list(m *ice.Message, zone, id string, fields ...string) { // 列表信息 m.Push(zone, value, fields, val) }) - m.Sort(kit.MDB_ID, "int_r") + m.SortIntR(kit.MDB_ID) return } m.Grows(FAVOR, kit.Keys(kit.MDB_HASH, key), kit.MDB_ID, id, func(index int, value map[string]interface{}) { diff --git a/option.go b/option.go index a9702e92..f5db5c50 100644 --- a/option.go +++ b/option.go @@ -172,6 +172,10 @@ func (m *Message) ProcessField(arg ...interface{}) { m.Process(PROCESS_FIELD) m.Option("_prefix", arg...) } +func (m *Message) ProcessDisplay(arg ...interface{}) { + m.Process(PROCESS_DISPLAY) + m.Option("_display", arg...) +} func (m *Message) ProcessInner() { m.Process(PROCESS_INNER) } func (m *Message) ProcessHold() { m.Process(PROCESS_HOLD) } func (m *Message) ProcessBack() { m.Process(PROCESS_BACK) }