From fd14318f8e792ace9498944b98ac8d8b13666208 Mon Sep 17 00:00:00 2001 From: bergyu Date: Tue, 10 Aug 2021 18:51:21 +0800 Subject: [PATCH] opt chrome --- base/web/space.go | 2 +- misc/alpha/alpha.go | 3 +++ misc/chrome/chrome.shy | 1 + misc/chrome/field.go | 36 ++++++++++++++++++++++++++++++++++++ misc/chrome/page.go | 22 +++++----------------- 5 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 misc/chrome/field.go diff --git a/base/web/space.go b/base/web/space.go index b1b56bdd..15c65439 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -107,7 +107,7 @@ func _space_send(m *ice.Message, space string, arg ...string) { } } m.Optionv(ice.MSG_OPTS, m.Optionv(ice.MSG_OPTS)) - m.Optionv(ice.MSG_OPTION, nil) + m.Optionv(ice.MSG_OPTION, m.Optionv(ice.MSG_OPTS)) // 构造路由 frame := m.Target().Server().(*Frame) diff --git a/misc/alpha/alpha.go b/misc/alpha/alpha.go index e1c20ba0..9dcc42e9 100644 --- a/misc/alpha/alpha.go +++ b/misc/alpha/alpha.go @@ -96,6 +96,9 @@ var Index = &ice.Context{Name: ALPHA, Help: "英汉词典", m.Cmdy(mdb.SELECT, m.Prefix("_cache"), "", mdb.HASH) }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) < 2 { + return + } defer m.StatusTimeCount() m.OptionFields("id,word,translation,definition") if m.Cmdy(mdb.SELECT, m.Prefix("_cache"), "", mdb.HASH, "mw", arg[0]+arg[1]); len(m.Appendv("id")) > 0 { diff --git a/misc/chrome/chrome.shy b/misc/chrome/chrome.shy index 82edc334..ed6ba865 100644 --- a/misc/chrome/chrome.shy +++ b/misc/chrome/chrome.shy @@ -10,6 +10,7 @@ field chrome web.code.chrome.chrome chapter "应用" field "同步流" web.code.chrome.sync field "收藏夹" web.code.chrome.favor +field "工具箱" web.code.chrome.field field "样式表" web.code.chrome.style field "蜘蛛侠" web.code.chrome.spide field "缓存池" web.code.chrome.cache diff --git a/misc/chrome/field.go b/misc/chrome/field.go new file mode 100644 index 00000000..67632022 --- /dev/null +++ b/misc/chrome/field.go @@ -0,0 +1,36 @@ +package chrome + +import ( + ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" + "github.com/shylinux/icebergs/base/web" + kit "github.com/shylinux/toolkits" +) + +const FIELD = "field" + +func init() { + Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ + FIELD: {Name: "field", Help: "工具", Value: kit.Data( + kit.MDB_SHORT, "zone", kit.MDB_FIELD, "time,id,index,args,style,left,top,selection", + )}, + }, Commands: map[string]*ice.Command{ + FIELD: {Name: "field zone id auto insert", Help: "工具", Action: ice.MergeAction(map[string]*ice.Action{ + mdb.INSERT: {Name: "insert zone=golang.google.cn index=cli.system args=pwd", Help: "添加"}, + SYNC: {Name: "sync hostname", Help: "同步", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(FIELD, m.Option("hostname")).Table(func(index int, value map[string]string, head []string) { + m.Option(ice.MSG_OPTS, head) + for k, v := range value { + m.Option(k, v) + } + m.Cmd(web.SPACE, CHROME, CHROME, "1", m.Option("tid"), FIELD, value["index"], value["args"], value["top"]) + }) + }}, + }, mdb.ZoneAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Fields(len(arg), mdb.ZONE_FIELD, m.Conf(FIELD, kit.META_FIELD)) + if m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.ZONE, arg); len(arg) == 0 { + m.PushAction(mdb.REMOVE) + } + }}, + }}) +} diff --git a/misc/chrome/page.go b/misc/chrome/page.go index 8943cc36..331b1b9b 100644 --- a/misc/chrome/page.go +++ b/misc/chrome/page.go @@ -16,27 +16,15 @@ func init() { "/page": {Name: "/page", Help: "网页", Action: map[string]*ice.Action{ ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { - m.Cmdy(STYLE, SYNC, m.OptionSimple("hostname")) - - switch m.Option("hostname") { - case "golang.google.cn": - m.Option("top", "200") - m.Option("selection", "word") - m.Result("web.wiki.alpha.alpha") - - case "music.163.com": - m.Option("top", "200") - m.Result(SPIDE, "", m.Option("tid")) - case "localhost", "fib.woa.com": - return - } - return - m.Option("top", "200") - m.Echo("cli.runtime") + m.Cmdy(STYLE, SYNC, m.OptionSimple("hostname"), ice.OptionFields("")) + m.Cmdy(FIELD, SYNC, m.OptionSimple("hostname"), ice.OptionFields("")) return } m.Cmdy(ctx.COMMAND, arg) }}, + FIELD: {Name: "field", Help: "执行", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(FIELD, arg) + }}, cli.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(arg) }},