1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-26 01:24:05 +08:00

add template.go

This commit is contained in:
IT 老营长 @云轩领航-创始人 2022-01-22 10:12:22 +08:00
parent c2ff6a5b08
commit 9919e3bcdf
2 changed files with 29 additions and 1 deletions

View File

@ -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("")
}

26
core/code/template.go Normal file
View File

@ -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)
}}},
})
}