diff --git a/core/code/inner.go b/core/code/inner.go index 6892dd8e..172d6168 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -151,6 +151,7 @@ func init() { }}, FAVOR: {Name: "favor", Help: "收藏"}, }, ctx.CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + arg[0] = strings.Split(arg[0], ice.FS)[0] if !strings.HasSuffix(arg[0], ice.PS) { arg[1] = kit.Slice(strings.Split(arg[0], ice.PS), -1)[0] arg[0] = strings.TrimSuffix(arg[0], arg[1]) @@ -161,7 +162,8 @@ func init() { nfs.Dir(m, nfs.PATH) return } - m.Option("exts", "inner/search.js?a=1,inner/favor.js") + arg[1] = strings.Split(arg[1], ice.FS)[0] + m.Option("exts", "inner/search.js?a=1,inner/favor.js,inner/template.js") if _inner_list(m, kit.Ext(arg[1]), arg[1], arg[0]); m.IsErrNotFound() { m.SetResult("") } diff --git a/core/code/template.go b/core/code/template.go new file mode 100644 index 00000000..09fe3d59 --- /dev/null +++ b/core/code/template.go @@ -0,0 +1,26 @@ +package code + +import ( + "path" + + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" +) + +func init() { + const TEMPLATE = "template" + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + TEMPLATE: {Name: "template name auto create", Help: "模板", Action: ice.MergeAction( + map[string]*ice.Action{ + mdb.CREATE: {Name: "create type name text args", Help: "创建"}, + nfs.DEFS: {Name: "defs file", Help: "生成", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(nfs.DEFS, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), m.Option(mdb.TEXT)) + }}, + }, mdb.HashAction(mdb.SHORT, "name", mdb.FIELD, "time,type,name,text,args"), + ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + mdb.HashSelect(m, arg...) + m.PushAction(nfs.DEFS, mdb.REMOVE) + }}}, + }) +}